Permalink
Browse files

MainPanelController has been updated

Signed-off-by: Victor Hertel <victor.hertel@web.de>
  • Loading branch information...
vhertel committed Aug 21, 2017
1 parent 936352f commit a863e3b96b2f7309454edcc99e88491ca57644cd
@@ -419,11 +419,11 @@ public static boolean rebuildGui(String path, String pathMod, Stage stage) throw
// Regenerats the entire GUI if RESET is set to true
if (Boolean.parseBoolean(config.getProperty("RESET"))) {
GuiBuilder.setExperimentName(stage, "config/config.properties");
GuiBuilder.mainPanelBuilder("fxml/ChartPanel.fxml", path);
GuiBuilder.mainPanelBuilder("fxml/MainPanel.fxml", path);
GuiBuilder.mainPanelControlBuilder("gui/controller/MainPanelController.java", path);
GuiBuilder.logPanelBuilder("fxml/LogPanel.fxml", path);
GuiBuilder.logPanelControlBuilder("gui/controller/LogPanelController.java", path);
//GuiBuilder.mainFrameBuilder("fxml/MainFrame.fxml", path);
GuiBuilder.mainFrameBuilder("fxml/MainFrame.fxml", path);
GuiBuilder.currentStateBuilder("fxml/CurrentStatePanel.fxml", path);
System.out.println("FXML has been reseted and regenerated completely.");
@@ -441,7 +441,7 @@ public static boolean rebuildGui(String path, String pathMod, Stage stage) throw
}
// Checks if CHART PROPERTIES has been modified since last compilation
if (mainPanelMod) {
GuiBuilder.mainPanelBuilder("fxml/ChartPanel.fxml", path);
GuiBuilder.mainPanelBuilder("fxml/MainPanel.fxml", path);
GuiBuilder.mainPanelControlBuilder("gui/controller/MainPanelController.java", path);
}
// Checks if LOG PROPERTIES has been modified since last compilation
@@ -451,7 +451,7 @@ public static boolean rebuildGui(String path, String pathMod, Stage stage) throw
}
// Checks if STATE PROPERTIES has been modified since last compilation
if (statePanelMod) {
//GuiBuilder.mainFrameBuilder("fxml/MainFrame.fxml", path);
GuiBuilder.mainFrameBuilder("fxml/MainFrame.fxml", path);
GuiBuilder.currentStateBuilder("fxml/CurrentStatePanel.fxml", path);
}
rebuildGui = true;
@@ -157,42 +157,24 @@ public static void mainFrameBuilder(String filePath, String configPath) throws I
+ "<?import java.lang.*?> \n"
+ "<?import javafx.scene.control.*?> \n"
+ "<?import javafx.scene.layout.*?> \n");
writer.println("<BorderPane maxHeight=\"1.7976931348623157E308\" maxWidth=\"1.7976931348623157E308\" minHeight=\"-Infinity\" minWidth=\"-Infinity\" prefHeight=\"700.0\" prefWidth=\"1180.0\" xmlns=\"http://javafx.com/javafx/8\" xmlns:fx=\"http://javafx.com/fxml/1\" fx:controller = \"com.ksatstuttgart.usoc.gui.controller.LogController\"> \n\n"
+ " <top> \n"
+ " <MenuBar BorderPane.alignment=\"CENTER\"> \n"
+ " <menus> \n"
+ " <Menu mnemonicParsing=\"false\" text=\"File\"> \n"
+ " <items> \n"
+ " <MenuItem mnemonicParsing=\"false\" text=\"Close\" /> \n"
+ " </items> \n"
+ " </Menu> \n"
+ " <Menu mnemonicParsing=\"false\" text=\"Edit\"> \n"
+ " <items> \n"
+ " <MenuItem mnemonicParsing=\"false\" text=\"Delete\" /> \n"
+ " </items> \n"
+ " </Menu> \n"
+ " <Menu mnemonicParsing=\"false\" text=\"Help\"> \n"
+ " <items> \n"
+ " <MenuItem mnemonicParsing=\"false\" text=\"About\" /> \n"
+ " </items> \n"
+ " </Menu> \n"
+ " </menus> \n"
+ " </MenuBar> \n"
+ " </top> \n");
writer.println("<BorderPane maxHeight=\"1.7976931348623157E308\" maxWidth=\"1.7976931348623157E308\" minHeight=\"-Infinity\" minWidth=\"-Infinity\" prefHeight=\"700.0\" prefWidth=\"1180.0\" xmlns=\"http://javafx.com/javafx/8\" xmlns:fx=\"http://javafx.com/fxml/1\">\n");
if (statePanel) {
writer.println(" <left> \n"
+ " <fx:include source = \"/fxml/CurrentStatePanel.fxml\" /> \n"
+ " </left> \n");
}
writer.println(" <center> \n"
+ " <fx:include source = \"/fxml/ChartPanel.fxml\" /> \n"
+ " <fx:include source = \"/fxml/MainPanel.fxml\" /> \n"
+ " </center> \n\n"
+ " <right> \n"
+ " <fx:include source = \"/fxml/LogPanel.fxml\" /> \n"
+ " </right> \n\n"
+ "</BorderPane> \n");
writer.close();
// Prints status update
System.out.println("MainFrame.fxml has been updated!");
}
/**
@@ -278,7 +260,7 @@ public static void mainPanelBuilder(String filePath, String configPath) throws I
writer.close();
// Prints status update
System.out.println("Chart panel has been updated!");
System.out.println("MainPanel.fxml has been updated!");
}
/**
@@ -304,16 +286,18 @@ public static void mainPanelControlBuilder(String filePath, String configPath) t
writer.println("import java.net.URL; \n"
+ "import com.ksatstuttgart.usoc.controller.MainController;\n"
+ "import com.ksatstuttgart.usoc.controller.MessageController;\n"
+ "import com.ksatstuttgart.usoc.data.USOCEvent;"
+ "import com.ksatstuttgart.usoc.gui.worldwind.GNSSPanel;\n"
+ "import com.ksatstuttgart.usoc.data.USOCEvent;\n"
+ "import java.util.ResourceBundle;\n"
+ "import javafx.embed.swing.SwingNode;\n"
+ "import javafx.fxml.FXML;\n"
+ "import javafx.fxml.Initializable;\n"
+ "import javafx.scene.chart.LineChart;\n"
+ "import javafx.scene.chart.XYChart;\n"
+ "import javafx.scene.layout.Pane;\n"
+ "import javax.swing.SwingUtilities;\n");
+ "import javafx.scene.chart.XYChart;");
if (GNSS3dView) {
writer.println("import com.ksatstuttgart.usoc.gui.worldwind.GNSSPanel;\n"
+ "import javafx.embed.swing.SwingNode;\n"
+ "import javafx.fxml.FXML;\n"
+ "import javafx.scene.layout.Pane;\n"
+ "import javax.swing.SwingUtilities;\n");
}
writer.println("/** \n"
+ " * \n"
+ " * @author Victor \n"
@@ -322,7 +306,7 @@ public static void mainPanelControlBuilder(String filePath, String configPath) t
for (int i = 1; i <= numberOfCharts; i++) {
writer.println(" public LineChart<Integer, Integer> lineChart" + i + ";");
}
writer.println("\n public void setData() {");
writer.println("\n public void setData(MessageController msgController, USOCEvent e) {\n");
for (int i = 1; i <= numberOfCharts; i++) {
writer.println(" lineChart" + i + ".getXAxis().setAutoRanging(true); \n"
+ " lineChart" + i + ".getYAxis().setAutoRanging(true); \n"
@@ -334,10 +318,8 @@ public static void mainPanelControlBuilder(String filePath, String configPath) t
writer.println(" } \n\n"
+ " @Override\n"
+ " public void updateData(MessageController msgController, USOCEvent e) {\n"
+ " setData();\n"
+ " setData(msgController, e);\n"
+ " }\n");
if (GNSS3dView) {
writer.println(" @FXML private Pane pane;\n"
+ " public SwingNode buildWW() {\n"
@@ -351,7 +333,6 @@ public static void mainPanelControlBuilder(String filePath, String configPath) t
+ " return node;\n"
+ " }\n");
}
writer.println(" @Override \n"
+ " public void initialize(URL url, ResourceBundle rb) { \n"
+ " // TODO\n"
@@ -364,6 +345,9 @@ public static void mainPanelControlBuilder(String filePath, String configPath) t
+ "}");
writer.close();
// Prints status update
System.out.println("mainPanelController.java has been updated!");
}
/**
@@ -510,7 +494,7 @@ public static void logPanelBuilder(String filePath, String configPath) throws Fi
writer.close();
// Prints status update
System.out.println("Log panel has been updated!");
System.out.println("LogPanel.fxml has been updated!");
}
/**
@@ -684,6 +668,9 @@ public static void logPanelControlBuilder(String filePath, String configPath) th
+ "}");
writer.close();
// Prints status update
System.out.println("LogPanelController.java has been updated!");
}
/**
@@ -761,5 +748,8 @@ public static void currentStateBuilder(String filePath, String configPath) throw
writer.println("");
}
writer.close();
// Prints status update
System.out.println("CurrentStatePanel.fxml has been updated!");
}
}
@@ -1,92 +1,116 @@
package com.ksatstuttgart.usoc.gui.controller;
import com.ksatstuttgart.usoc.controller.DataModification;
import java.net.URL;
import com.ksatstuttgart.usoc.controller.MainController;
import com.ksatstuttgart.usoc.controller.MessageController;
import com.ksatstuttgart.usoc.data.USOCEvent;import com.ksatstuttgart.usoc.gui.worldwind.GNSSPanel;
import com.ksatstuttgart.usoc.data.ErrorEvent;
import com.ksatstuttgart.usoc.data.USOCEvent;
import com.ksatstuttgart.usoc.data.message.Var;
import com.ksatstuttgart.usoc.data.message.dataPackage.Sensor;
import java.util.Map;
import java.util.ResourceBundle;
import javafx.embed.swing.SwingNode;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.XYChart;
import javafx.scene.layout.Pane;
import javax.swing.SwingUtilities;
/**
*
* @author Victor
*/
public class MainPanelController extends DataController implements Initializable {
public LineChart<Integer, Integer> lineChart1;
public LineChart<Integer, Integer> lineChart2;
public LineChart<Integer, Integer> lineChart3;
public LineChart<Integer, Integer> lineChart4;
public LineChart<Integer, Integer> lineChart5;
public LineChart<Integer, Integer> lineChart6;
public void setData() {
public LineChart<Long, Object> lineChart1;
public XYChart.Series series1;
public LineChart<Long, Object> lineChart2;
public XYChart.Series series2;
public LineChart<Long, Object> lineChart3;
public XYChart.Series series3;
public LineChart<Long, Object> lineChart4;
public XYChart.Series series4;
public LineChart<Long, Object> lineChart5;
public XYChart.Series series5;
public LineChart<Long, Object> lineChart6;
public XYChart.Series series6;
@Override
public void updateData(MessageController mc, USOCEvent e) {
lineChart1.getXAxis().setAutoRanging(true);
lineChart1.getYAxis().setAutoRanging(true);
XYChart.Series series1 = new XYChart.Series<>();
series1.getData().add(new XYChart.Data<>(5, 23));
series1.getData().add(new XYChart.Data<>(6, 15));
lineChart1.getData().add(series1);
lineChart1.getYAxis().setAutoRanging(true);
lineChart2.getXAxis().setAutoRanging(true);
lineChart2.getYAxis().setAutoRanging(true);
XYChart.Series series2 = new XYChart.Series<>();
series2.getData().add(new XYChart.Data<>(5, 23));
series2.getData().add(new XYChart.Data<>(6, 15));
lineChart2.getData().add(series2);
lineChart3.getXAxis().setAutoRanging(true);
lineChart3.getYAxis().setAutoRanging(true);
XYChart.Series series3 = new XYChart.Series<>();
series3.getData().add(new XYChart.Data<>(5, 23));
series3.getData().add(new XYChart.Data<>(6, 15));
lineChart3.getData().add(series3);
lineChart4.getXAxis().setAutoRanging(true);
lineChart4.getYAxis().setAutoRanging(true);
XYChart.Series series4 = new XYChart.Series<>();
series4.getData().add(new XYChart.Data<>(5, 23));
series4.getData().add(new XYChart.Data<>(6, 15));
lineChart4.getData().add(series4);
lineChart4.getYAxis().setAutoRanging(true);
lineChart5.getXAxis().setAutoRanging(true);
lineChart5.getYAxis().setAutoRanging(true);
XYChart.Series series5 = new XYChart.Series<>();
series5.getData().add(new XYChart.Data<>(5, 23));
series5.getData().add(new XYChart.Data<>(6, 15));
lineChart5.getData().add(series5);
lineChart6.getXAxis().setAutoRanging(true);
lineChart6.getYAxis().setAutoRanging(true);
XYChart.Series series6 = new XYChart.Series<>();
series6.getData().add(new XYChart.Data<>(5, 23));
series6.getData().add(new XYChart.Data<>(6, 15));
lineChart6.getData().add(series6);
}
@Override
public void updateData(MessageController msgController, USOCEvent e) {
setData();
}
//in case this is an error event, ignore it
if(e instanceof ErrorEvent){
return;
}
//go through the data and update the charts
for (Sensor sensor : mc.getData().getSensors()) {
//adjust values for the sensor specific to the current experiment
Sensor adjusted = DataModification.adjustSensorData(sensor);
//search for thermocouple sensors
if (adjusted.getSensorName().startsWith("Thermocouple")) {
//thermocouple sensors have only one variable with the current
//data scheme it uses the sensor name as variable name
//TODO: this needs to be fixed
Map.Entry<Long, Object> entry = adjusted.getVars().get(0).getValues().lastEntry();
series1.getData().add(new XYChart.Data(entry.getKey(), entry.getValue()));
lineChart1.getData().add(series1);
}
@FXML private Pane pane;
public SwingNode buildWW() {
final SwingNode node = new SwingNode();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
node.setContent(new GNSSPanel());
//search for pressure sensors
if (adjusted.getSensorName().contains("Pressure")) {
//pressure sensors have only one variable with the current
//data scheme and it uses the sensor name as variable name
//TODO: this needs to be fixed
Map.Entry<Long, Object> entry = adjusted.getVars().get(0).getValues().lastEntry();
series2.getData().add(new XYChart.Data(entry.getKey(), entry.getValue()));
lineChart2.getData().add(series2);
}
});
return node;
//search for pressure sensors
if (adjusted.getSensorName().contains("GNSS TIME")) {
//pressure sensors have only one variable with the current
//data scheme and it uses the sensor name as variable name
//TODO: this needs to be fixed
Map.Entry<Long, Object> entry = adjusted.getVars().get(0).getValues().lastEntry();
series3.getData().add(new XYChart.Data(entry.getKey(), entry.getValue()));
lineChart3.getData().add(series3);
}
//search for voltage sensors
if (adjusted.getSensorName().startsWith("Battery")) {
//voltage sensors have only one variable with the current
//data scheme and it uses the sensor name as variable name
//TODO: this needs to be fixed
Map.Entry<Long, Object> entry = adjusted.getVars().get(0).getValues().lastEntry();
series4.getData().add(new XYChart.Data(entry.getKey(), entry.getValue()));
lineChart4.getData().add(series4);
}
//search for IMU data
if (adjusted.getSensorName().contains("IMU")){
for (Var var : adjusted.getVars()) {
//only visualize quaternion data ignore calibration data
//for chart
Map.Entry<Long, Object> entry = adjusted.getVars().get(0).getValues().lastEntry();
series5.getData().add(new XYChart.Data(entry.getKey(), entry.getValue()));
lineChart5.getData().add(series5);
}
}
}
}
@Override
@@ -95,7 +119,5 @@ public void initialize(URL url, ResourceBundle rb) {
MainController.getInstance().addDataUpdateListener(new UpdateListener());
//setData();
pane.getChildren().add(buildWW());
}
}
@@ -32,14 +32,14 @@
# This option can be used to regenerate the entire GUI,
# including FXML files and controllers.
# After compiling once, set the option to false again.
RESET = true
RESET = false
#
#
statePanel = false
GNSS3dView = true
GNSS3dView = false
@@ -38,7 +38,7 @@ promptText[2][5]=Prompt Text 3
textArea[1]=true
y[3]=Height [m]
y[6]=Height [m]
GNSS3dView=true
GNSS3dView=false
experimentName=PAPELL
iridiumPanel=true
keyword[1][1]=Safe
Oops, something went wrong.

0 comments on commit a863e3b

Please sign in to comment.