Skip to content

Commit

Permalink
fixed gnss 3d view not showing in javafx
Browse files Browse the repository at this point in the history
fix is not very pretty at the moment

Signed-off-by: vstarlinger <valentin@starlinger.net>
  • Loading branch information
vstarlinger committed Aug 24, 2017
1 parent ed6abd0 commit fbe2cae
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void initialize(){
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

gnssPanel = new GNSSPanel();
gnssPanel = null;//new GNSSPanel();
dataTabs.addTab("Graphs", jsp);
dataTabs.addTab("GNSS 3D View", gnssPanel);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
package com.ksatstuttgart.usoc.gui.controller;
package com.ksatstuttgart.usoc.gui.controller;

import com.ksatstuttgart.usoc.controller.DataModification;
import java.net.URL;
import java.net.URL;
import com.ksatstuttgart.usoc.controller.MainController;
import com.ksatstuttgart.usoc.controller.MessageController;
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.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.XYChart;
import com.ksatstuttgart.usoc.gui.worldwind.GNSSPanel;
import javafx.embed.swing.SwingNode;
import javafx.fxml.FXML;
import javafx.scene.layout.Pane;
import javax.swing.SwingUtilities;

/**
*
* @author Victor
*/
import javafx.scene.layout.StackPane;

public class MainPanelController extends DataController implements Initializable {
/**
*
* @author Victor
*/
public class MainPanelController extends DataController implements Initializable {

@FXML
public LineChart<Number, Number> lineChart1;
Expand All @@ -40,7 +36,6 @@ public class MainPanelController extends DataController implements Initializable
@Override
public void updateData(MessageController mc, USOCEvent e) {


lineChart1.getXAxis().setAutoRanging(true);
lineChart1.getYAxis().setAutoRanging(true);

Expand Down Expand Up @@ -71,7 +66,7 @@ public void updateData(MessageController mc, USOCEvent e) {
//thermocouple sensors have only one variable with the current
//data scheme it uses the sensor name as variable name
for (Var var : adjusted.getVars()) {
addVarToChart(var,lineChart1);
addVarToChart(var, lineChart1);
}
}

Expand All @@ -80,7 +75,7 @@ public void updateData(MessageController mc, USOCEvent e) {
//pressure sensors have only one variable with the current
//data scheme and it uses the sensor name as variable name
for (Var var : adjusted.getVars()) {
addVarToChart(var,lineChart2);
addVarToChart(var, lineChart2);
}
}

Expand All @@ -89,7 +84,7 @@ public void updateData(MessageController mc, USOCEvent e) {
//pressure sensors have only one variable with the current
//data scheme and it uses the sensor name as variable name
for (Var var : adjusted.getVars()) {
addVarToChart(var,lineChart3);
addVarToChart(var, lineChart3);
}
}

Expand All @@ -98,7 +93,7 @@ public void updateData(MessageController mc, USOCEvent e) {
//voltage sensors have only one variable with the current
//data scheme and it uses the sensor name as variable name
for (Var var : adjusted.getVars()) {
addVarToChart(var,lineChart4);
addVarToChart(var, lineChart4);
}
}

Expand All @@ -107,21 +102,19 @@ public void updateData(MessageController mc, USOCEvent e) {
for (Var var : adjusted.getVars()) {
//only visualize quaternion data ignore calibration data
//for chart
addVarToChart(var,lineChart5);
addVarToChart(var, lineChart5);
}
}
}
}


private void addVarToChart(Var var, LineChart<Number, Number> chart) {
XYChart.Series series = getSeriesForChart(var, chart);
for (Long time : var.getValues().keySet()) {
series.getData().add(new XYChart.Data<>(time, var.getValues().get(time)));
}
}


private XYChart.Series getSeriesForChart(Var var, LineChart<Number, Number> chart) {
for (XYChart.Series<Number, Number> series : chart.getData()) {
if (series.getName().equals(var.getDataName())) {
Expand All @@ -134,24 +127,14 @@ private XYChart.Series getSeriesForChart(Var var, LineChart<Number, Number> char
return series;
}

@FXML private Pane pane;
public SwingNode buildWW() {
final SwingNode node = new SwingNode();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
node.setContent(new GNSSPanel());
}
});
return node;
}
@FXML
private StackPane pane;

@Override
public void initialize(URL url, ResourceBundle rb) {
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
MainController.getInstance().addDataUpdateListener(new UpdateListener());

pane.getChildren().add(buildWW());

new GNSSPanel(pane);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import gov.nasa.worldwind.Model;
import gov.nasa.worldwind.WorldWind;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.awt.WorldWindowGLCanvas;
import gov.nasa.worldwind.awt.WorldWindowGLJPanel;
import gov.nasa.worldwind.geom.Angle;
import gov.nasa.worldwind.geom.Matrix;
import gov.nasa.worldwind.geom.Position;
Expand All @@ -60,11 +60,13 @@
import gov.nasa.worldwind.view.ViewUtil;
import gov.nasa.worldwind.view.orbit.BasicOrbitView;
import java.awt.BorderLayout;
import javafx.geometry.Insets;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.TreeMap;
import javafx.embed.swing.SwingNode;
import javafx.scene.layout.StackPane;
import javax.swing.BoxLayout;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

Expand All @@ -74,7 +76,7 @@
*/
public class GNSSPanel extends DataPanel {

WorldWindowGLCanvas wwp_big, wwp_topView, wwp_sideView;
WorldWindowGLJPanel wwp_big, wwp_topView, wwp_sideView;
BasicOrbitView bov_big, bov_topView, bov_sideView;

StatusBar statusBar;
Expand All @@ -83,10 +85,12 @@ public class GNSSPanel extends DataPanel {
MarkerLayer markerLayer;

JPanel sidePanel;

SwingNode sn_bot, sn_top;

private static final boolean OFFLINEMODE = true;

public GNSSPanel() {
public GNSSPanel(StackPane pane) {
super();

boolean networkUnavailable = WorldWind.getNetworkStatus().isNetworkUnavailable();
Expand All @@ -97,27 +101,22 @@ public GNSSPanel() {
pathLayer = new RenderableLayer();
markerLayer = new MarkerLayer();

wwp_big = new WorldWindowGLCanvas();
wwp_topView = new WorldWindowGLCanvas();
wwp_sideView = new WorldWindowGLCanvas();

JLayeredPane jlp = new JLayeredPane();
wwp_big = new WorldWindowGLJPanel();
wwp_topView = new WorldWindowGLJPanel();
wwp_sideView = new WorldWindowGLJPanel();

sidePanel = new JPanel();
sidePanel.setOpaque(true);
sidePanel.setSize(200, 200);
sidePanel.setLayout(new BoxLayout(sidePanel, BoxLayout.Y_AXIS));
sidePanel.add(wwp_topView);
sidePanel.add(wwp_sideView);

jlp.add(wwp_big, JLayeredPane.MODAL_LAYER);
jlp.add(sidePanel, JLayeredPane.DEFAULT_LAYER);


wwp_big.setBounds(0, 0, 600, 600);
sidePanel.setBounds(400, 0, 200, 200);

this.setLayout(new BorderLayout());
this.add(jlp);
this.add(wwp_big);
statusBar = new StatusBar();
statusBar.setBorder(new EmptyBorder(5, 5, 5, 5));

Expand Down Expand Up @@ -160,6 +159,14 @@ public GNSSPanel() {
bov_topView = new BasicOrbitView();
bov_topView.setGlobe(flatEarth);
wwp_topView.setView(bov_topView);

sn_bot = new SwingNode();
sn_bot.setContent(this);

sn_top = new SwingNode();
sn_top.setContent(sidePanel);

pane.getChildren().addAll(sn_bot,sn_top);
}

/**
Expand Down Expand Up @@ -187,13 +194,13 @@ public void resizeComponents() {
//getting the width and height for the big world window
int width = this.getWidth();
int height = this.getHeight() - statusBar.getHeight();
wwp_big.setBounds(0, 0, width, height);
//setting the height and width of the sidePanel to a third of the big window
int spHeight = height / 3;
int spWidth = width / 3;
//setting the sidePanel in the upper right corner with the respective width
//and height
sidePanel.setBounds(width - spWidth, 0, spWidth, spHeight);

StackPane.setMargin(sn_top, new Insets(0,0,height-spHeight,width-spWidth));
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?xml version="1.0" encoding="UTF-8"?>

<TabPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller = "com.ksatstuttgart.usoc.gui.controller.MainPanelController" tabClosingPolicy="UNAVAILABLE" BorderPane.alignment="CENTER">
<?import java.lang.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<TabPane tabClosingPolicy="UNAVAILABLE" BorderPane.alignment="CENTER" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ksatstuttgart.usoc.gui.controller.MainPanelController">
<tabs>
<Tab text="Graphs">
<content>
Expand All @@ -19,39 +22,39 @@
<RowConstraints maxHeight="400.0" minHeight="200.0" prefHeight="300.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<LineChart fx:id="lineChart1" title="Thermocouples" GridPane.columnIndex="0" GridPane.rowIndex="0" maxHeight="400.0" minHeight="200.0" GridPane.halignment="CENTER" GridPane.valignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.vgrow="SOMETIMES">
<LineChart fx:id="lineChart1" maxHeight="400.0" minHeight="200.0" title="Thermocouples" GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.rowIndex="0" GridPane.valignment="CENTER" GridPane.vgrow="SOMETIMES">
<xAxis>
<NumberAxis label="Time [s]" side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis label="Temperature [°C]" side="LEFT" />
</yAxis>
</LineChart>
<LineChart fx:id="lineChart2" title="Pressuresensors" GridPane.columnIndex="1" GridPane.rowIndex="0" maxHeight="400.0" minHeight="200.0" GridPane.halignment="CENTER" GridPane.valignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.vgrow="SOMETIMES">
<LineChart fx:id="lineChart2" maxHeight="400.0" minHeight="200.0" title="Pressuresensors" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.rowIndex="0" GridPane.valignment="CENTER" GridPane.vgrow="SOMETIMES">
<xAxis>
<NumberAxis label="Time [s]" side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis label="Pressure [kPa]" side="LEFT" />
</yAxis>
</LineChart>
<LineChart fx:id="lineChart3" title="Time Signal" GridPane.columnIndex="0" GridPane.rowIndex="1" maxHeight="400.0" minHeight="200.0" GridPane.halignment="CENTER" GridPane.valignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.vgrow="SOMETIMES">
<LineChart fx:id="lineChart3" maxHeight="400.0" minHeight="200.0" title="Time Signal" GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.rowIndex="1" GridPane.valignment="CENTER" GridPane.vgrow="SOMETIMES">
<xAxis>
<NumberAxis label="Time [s]" side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis label="Time" side="LEFT" />
</yAxis>
</LineChart>
<LineChart fx:id="lineChart4" title="Battery Voltage" GridPane.columnIndex="1" GridPane.rowIndex="1" maxHeight="400.0" minHeight="200.0" GridPane.halignment="CENTER" GridPane.valignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.vgrow="SOMETIMES">
<LineChart fx:id="lineChart4" maxHeight="400.0" minHeight="200.0" title="Battery Voltage" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.rowIndex="1" GridPane.valignment="CENTER" GridPane.vgrow="SOMETIMES">
<xAxis>
<NumberAxis label="Time [s]" side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis label="Voltage [V]" side="LEFT" />
</yAxis>
</LineChart>
<LineChart fx:id="lineChart5" title="IMU" GridPane.columnIndex="0" GridPane.rowIndex="2" maxHeight="400.0" minHeight="200.0" GridPane.halignment="CENTER" GridPane.valignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.vgrow="SOMETIMES">
<LineChart fx:id="lineChart5" maxHeight="400.0" minHeight="200.0" title="IMU" GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.rowIndex="2" GridPane.valignment="CENTER" GridPane.vgrow="SOMETIMES">
<xAxis>
<NumberAxis label="Time [s]" side="BOTTOM" />
</xAxis>
Expand All @@ -67,14 +70,10 @@
</Tab>
<Tab text="GNSS 3D View">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Pane fx:id="pane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
</Pane>
</children>
</AnchorPane>
<StackPane fx:id="pane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="180.0" prefWidth="200.0">

</StackPane>
</content>
</Tab>
</tabs>
</TabPane>

0 comments on commit fbe2cae

Please sign in to comment.