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

Tracker Thread to static

parent 1ed0153f
...@@ -27,7 +27,6 @@ import java.awt.GridLayout; ...@@ -27,7 +27,6 @@ import java.awt.GridLayout;
public class satelliteStatus extends JInternalFrame { public class satelliteStatus extends JInternalFrame {
TrackerThread tracker = new TrackerThread();
SatelliteTrack curSat = null; SatelliteTrack curSat = null;
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Database"); DefaultMutableTreeNode root = new DefaultMutableTreeNode("Database");
JTree tree = new JTree(root); JTree tree = new JTree(root);
...@@ -54,7 +53,7 @@ public class satelliteStatus extends JInternalFrame { ...@@ -54,7 +53,7 @@ public class satelliteStatus extends JInternalFrame {
btnStartTracking.addMouseListener(new MouseAdapter() { btnStartTracking.addMouseListener(new MouseAdapter() {
@Override @Override
public void mousePressed(MouseEvent arg0) { public void mousePressed(MouseEvent arg0) {
tracker.startTrack(curSat.getTLE().getName(), "Albuquerque"); TrackerThread.startTrack(curSat.getTLE().getName(), "Albuquerque");
//thread.setSatellite(curSat); //thread.setSatellite(curSat);
//(new Thread(new thread())).start(); //(new Thread(new thread())).start();
} }
...@@ -64,6 +63,14 @@ public class satelliteStatus extends JInternalFrame { ...@@ -64,6 +63,14 @@ public class satelliteStatus extends JInternalFrame {
JButton btnStopTracking = new JButton("Stop Tracking"); JButton btnStopTracking = new JButton("Stop Tracking");
btnStopTracking.setBounds(257, 390, 161, 48); 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); panel.add(btnStopTracking);
JLabel lblLatitude = new JLabel("Latitude"); JLabel lblLatitude = new JLabel("Latitude");
......
...@@ -7,18 +7,22 @@ public class TrackerThread{ ...@@ -7,18 +7,22 @@ public class TrackerThread{
//trackerThread.setSatellite(curSat); //trackerThread.setSatellite(curSat);
//(new Thread(new trackerThread())).start(); //(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); int satNum = SatelliteDB.getSatIndex(sat);
SatelliteTrack satellite = SatelliteDB.sat(satNum); SatelliteTrack satellite = SatelliteDB.sat(satNum);
threadList.add(new thread(satellite)); threadList.add(new tracker(satellite));
threadList.get(threadList.size()-1).run(); threadList.get(threadList.size()-1).start();
} }
public void stopTrack(String sat){ 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){ private void searchThread(String sat){
...@@ -28,13 +32,14 @@ public class TrackerThread{ ...@@ -28,13 +32,14 @@ public class TrackerThread{
} }
} }
} }
private class thread implements Runnable{
public thread(SatelliteTrack satellite){ private class tracker extends Thread{
public tracker(SatelliteTrack satellite){
sat = satellite; sat = satellite;
name = satellite.getTLE().getName(); name = satellite.getTLE().getName();
} }
String name; public String name;
SatelliteTrack sat; SatelliteTrack sat;
int seconds = 0; int seconds = 0;
public void run(){ 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