Commit 8839b482 authored by Christopher Reis's avatar Christopher Reis

Tracker Thread to static

parent 1ed0153f
......@@ -27,7 +27,6 @@ import java.awt.GridLayout;
public class satelliteStatus extends JInternalFrame {
TrackerThread tracker = new TrackerThread();
SatelliteTrack curSat = null;
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Database");
JTree tree = new JTree(root);
......@@ -54,7 +53,7 @@ public class satelliteStatus extends JInternalFrame {
btnStartTracking.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
tracker.startTrack(curSat.getTLE().getName(), "Albuquerque");
TrackerThread.startTrack(curSat.getTLE().getName(), "Albuquerque");
//thread.setSatellite(curSat);
//(new Thread(new thread())).start();
}
......@@ -64,6 +63,14 @@ public class satelliteStatus extends JInternalFrame {
JButton btnStopTracking = new JButton("Stop Tracking");
btnStopTracking.setBounds(257, 390, 161, 48);
btnStopTracking.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
tracker.stopTrack(curSat.getTLE().getName());
//thread.setSatellite(curSat);
//(new Thread(new thread())).start();
}
});
panel.add(btnStopTracking);
JLabel lblLatitude = new JLabel("Latitude");
......
......@@ -7,18 +7,22 @@ public class TrackerThread{
//trackerThread.setSatellite(curSat);
//(new Thread(new trackerThread())).start();
private static List<thread> threadList = new ArrayList<thread>();
private static List<tracker> threadList = new ArrayList<tracker>();
public void startTrack(String sat, String gs){
public static void startTrack(String sat, String gs){
int satNum = SatelliteDB.getSatIndex(sat);
SatelliteTrack satellite = SatelliteDB.sat(satNum);
threadList.add(new thread(satellite));
threadList.get(threadList.size()-1).run();
threadList.add(new tracker(satellite));
threadList.get(threadList.size()-1).start();
}
public void stopTrack(String sat){
for(int i = 0;i<threadList.size();i++){
if(threadList.get(i).name.equals(sat)){
threadList.get(i).stop();
}
}
}
private void searchThread(String sat){
......@@ -28,13 +32,14 @@ public class TrackerThread{
}
}
}
private class thread implements Runnable{
private class tracker extends Thread{
public thread(SatelliteTrack satellite){
public tracker(SatelliteTrack satellite){
sat = satellite;
name = satellite.getTLE().getName();
}
String name;
public String name;
SatelliteTrack sat;
int seconds = 0;
public void run(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment