Commit 93010059 authored by Christopher Reis's avatar Christopher Reis

Fixed JTree and added info field to satellite track

parent d070e754
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -79,13 +79,13 @@ public class Application { ...@@ -79,13 +79,13 @@ public class Application {
satTree.setClosable(true); satTree.setClosable(true);
satTree.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); satTree.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
satTree.setResizable(true); satTree.setResizable(true);
satTree.setBounds(21, 70, 867, 495); satTree.setBounds(10, 52, 867, 495);
desktopPane.add(satTree); desktopPane.add(satTree);
JMenuBar menuBar = new JMenuBar(); JMenuBar menuBar = new JMenuBar();
frmSatelliteTracker.setJMenuBar(menuBar); frmSatelliteTracker.setJMenuBar(menuBar);
JMenu mnFile = new JMenu("FIle"); JMenu mnFile = new JMenu("File");
mnFile.setIcon(null); mnFile.setIcon(null);
menuBar.add(mnFile); menuBar.add(mnFile);
......
package GUI; package GUI;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.util.Enumeration;
import javax.swing.JInternalFrame; import javax.swing.JInternalFrame;
import javax.swing.JFrame; import javax.swing.JFrame;
...@@ -15,11 +16,19 @@ import javax.swing.JLabel; ...@@ -15,11 +16,19 @@ import javax.swing.JLabel;
import javax.swing.JTextField; import javax.swing.JTextField;
import satellite.*; import satellite.*;
import java.awt.Component;
import javax.swing.Box;
import javax.swing.SwingConstants;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
public class satelliteTree extends JInternalFrame { public class satelliteTree extends JInternalFrame {
private JTextField textField; private JTextField textField;
JTree tree = new JTree(); DefaultMutableTreeNode root = new DefaultMutableTreeNode("Database");
JTree tree = new JTree(root);
/** /**
* Create the frame. * Create the frame.
*/ */
...@@ -27,20 +36,24 @@ public class satelliteTree extends JInternalFrame { ...@@ -27,20 +36,24 @@ public class satelliteTree extends JInternalFrame {
setMaximizable(true); setMaximizable(true);
setClosable(true); setClosable(true);
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setBounds(100, 100, 872, 640); setBounds(100, 100, 862, 519);
root.add(new DefaultMutableTreeNode("Other"));
JDesktopPane desktopPane = new JDesktopPane(); JDesktopPane desktopPane = new JDesktopPane();
getContentPane().add(desktopPane, BorderLayout.CENTER); getContentPane().add(desktopPane, BorderLayout.CENTER);
JScrollPane treescroll = new JScrollPane(tree);
treescroll.setBounds(0, 0, 254, 481);
desktopPane.add(treescroll);
tree.setBounds(0, 0, 254, 588);
desktopPane.add(tree);
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setBounds(252, 0, 604, 588); panel.setBounds(252, 0, 596, 481);
desktopPane.add(panel); desktopPane.add(panel);
JLabel lblNewLabel = new JLabel("New label"); JLabel lblNewLabel = new JLabel("New label");
lblNewLabel.setHorizontalAlignment(SwingConstants.LEFT);
panel.add(lblNewLabel); panel.add(lblNewLabel);
textField = new JTextField(); textField = new JTextField();
...@@ -50,11 +63,30 @@ public class satelliteTree extends JInternalFrame { ...@@ -50,11 +63,30 @@ public class satelliteTree extends JInternalFrame {
} }
public void updateTree(SatelliteDB satellites){ public void updateTree(SatelliteDB satellites){
//Iterate through sat database
for(int i = 0;i<satellites.getSize();i++){ for(int i = 0;i<satellites.getSize();i++){
DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); boolean b_set = false;
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); //pull constellation from satellite
model.insertNodeInto(new DefaultMutableTreeNode(satellites.sat(i).getTLE().getName()), root, root.getChildCount()); String constillation = satellites.sat(i).getConstillation();
//pull nodes from Jtree
int count = root.getChildCount();
System.out.println(count);
for(int j = 0; j<count;j++){
System.out.println(root.getChildCount());
DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(j);
if(node.toString().equalsIgnoreCase(constillation.trim())){
node.add(new DefaultMutableTreeNode(satellites.sat(i).getTLE().getName()));
System.out.println("added to existing");
b_set = true;
}
}
if(!b_set) {
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(constillation);
newNode.add(new DefaultMutableTreeNode(satellites.sat(i).getTLE().getName()));
root.add(newNode);
}
} }
} }
} }
...@@ -155,6 +155,18 @@ public class SatelliteDB { ...@@ -155,6 +155,18 @@ public class SatelliteDB {
databaseSet = true; databaseSet = true;
} }
public void getSatellites_Iridium(){
downloadTLE("https://celestrak.com/NORAD/elements/iridium.txt","Iridium");
//TLEReader("noaa.txt");
databaseSet = true;
}
public void getSatellites_GEO(){
downloadTLE("https://celestrak.com/NORAD/elements/geo.txt","Geostationary");
//TLEReader("noaa.txt");
databaseSet = true;
}
public int getSatIndex(String sat){ public int getSatIndex(String sat){
for(int i=0;i<database.size();i++){ for(int i=0;i<database.size();i++){
...@@ -246,6 +258,11 @@ public class SatelliteDB { ...@@ -246,6 +258,11 @@ public class SatelliteDB {
constellation.appendChild(doc.createTextNode(database.get(i).getConstillation())); constellation.appendChild(doc.createTextNode(database.get(i).getConstillation()));
satellite.appendChild(constellation); satellite.appendChild(constellation);
//Constellation
Element info = doc.createElement("info");
constellation.appendChild(doc.createTextNode(database.get(i).getInfo()));
satellite.appendChild(info);
rootElement.appendChild(satellite); rootElement.appendChild(satellite);
} }
...@@ -304,6 +321,7 @@ public class SatelliteDB { ...@@ -304,6 +321,7 @@ public class SatelliteDB {
String constellation = eElement.getElementsByTagName("constellation").item(0).getTextContent(); String constellation = eElement.getElementsByTagName("constellation").item(0).getTextContent();
String image = eElement.getElementsByTagName("satImage").item(0).getTextContent(); String image = eElement.getElementsByTagName("satImage").item(0).getTextContent();
String guiVisible = eElement.getElementsByTagName("GUIVisible").item(0).getTextContent(); String guiVisible = eElement.getElementsByTagName("GUIVisible").item(0).getTextContent();
String info = eElement.getElementsByTagName("info").item(0).getTextContent();
System.out.println(name); System.out.println(name);
System.out.println(TLE1); System.out.println(TLE1);
...@@ -319,6 +337,7 @@ public class SatelliteDB { ...@@ -319,6 +337,7 @@ public class SatelliteDB {
sat.setConstillation(constellation); sat.setConstillation(constellation);
sat.setImage(image); sat.setImage(image);
sat.setVisibleGUI(Boolean.valueOf(guiVisible)); sat.setVisibleGUI(Boolean.valueOf(guiVisible));
sat.setInfo(info);
database.add(sat); database.add(sat);
//Debug print out //Debug print out
...@@ -331,6 +350,7 @@ public class SatelliteDB { ...@@ -331,6 +350,7 @@ public class SatelliteDB {
System.out.println("Constellation : " + sat.getDownlinkFreq()); System.out.println("Constellation : " + sat.getDownlinkFreq());
System.out.println("Image : " + sat.getDownlinkFreq()); System.out.println("Image : " + sat.getDownlinkFreq());
System.out.println("Visible in GUI : " + sat.getDownlinkFreq()); System.out.println("Visible in GUI : " + sat.getDownlinkFreq());
System.out.println("Info : "+sat.getInfo());
} }
} }
......
...@@ -20,6 +20,7 @@ public class SatelliteTrack { ...@@ -20,6 +20,7 @@ public class SatelliteTrack {
private String image = "/satellite.png"; //not implemented private String image = "/satellite.png"; //not implemented
private String trackColor = "white"; //not implemented private String trackColor = "white"; //not implemented
private String constellation = ""; private String constellation = "";
private String info = "";
private ArrayList<satPosition> dayOrbit; private ArrayList<satPosition> dayOrbit;
private ArrayList<satPosition> singleOrbit; private ArrayList<satPosition> singleOrbit;
private ArrayList<satPosition> doubleOrbit; private ArrayList<satPosition> doubleOrbit;
...@@ -120,6 +121,14 @@ public class SatelliteTrack { ...@@ -120,6 +121,14 @@ public class SatelliteTrack {
return tle2; return tle2;
} }
public String getInfo(){
return info;
}
public void setInfo(String info){
this.info = info;
}
public Boolean isVisibleGUI() { public Boolean isVisibleGUI() {
return isVisibleGUI; return isVisibleGUI;
} }
......
...@@ -11,10 +11,13 @@ public class tracker { ...@@ -11,10 +11,13 @@ public class tracker {
satellites.getSatellites_GPS(); satellites.getSatellites_GPS();
satellites.getSatellites_NOAA(); satellites.getSatellites_NOAA();
satellites.getSatellites_Stations(); satellites.getSatellites_Stations();
satellites.getSatellites_GEO();
satellites.getSatellites_Iridium();
satellites.writeToXML(); satellites.writeToXML();
System.out.println("There are " + satellites.getSize() + " in the database!");
} }
......
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