From 5c6f8db4da5af05bd1a1e4c3352c2703ab5b99b1 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Wed, 25 May 2016 11:44:14 +0200 Subject: [PATCH] Added toggle for time/distance --- .../controller/DashboardController.java | 26 +- .../es/kauron/estraba/fxml/Dashboard.fxml | 319 +++++++++--------- src/main/resources/general.properties | 1 + src/main/resources/general_ca.properties | 1 + src/main/resources/general_es.properties | 1 + 5 files changed, 176 insertions(+), 172 deletions(-) diff --git a/src/main/java/es/kauron/estraba/controller/DashboardController.java b/src/main/java/es/kauron/estraba/controller/DashboardController.java index df4e21c..3133438 100644 --- a/src/main/java/es/kauron/estraba/controller/DashboardController.java +++ b/src/main/java/es/kauron/estraba/controller/DashboardController.java @@ -45,12 +45,13 @@ import javafx.scene.Scene; import javafx.scene.chart.AreaChart; import javafx.scene.chart.LineChart; import javafx.scene.chart.PieChart; +import javafx.scene.control.ChoiceBox; import javafx.scene.control.Label; import javafx.scene.control.Tab; import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.StackPane; import javafx.stage.Stage; import jgpx.model.analysis.Chunk; @@ -65,8 +66,8 @@ import java.util.ResourceBundle; public class DashboardController implements Initializable, MapComponentInitializedListener { - final int N = 0, S = 1, E = 2, W = 3; - final double[] coord = new double[4]; + private final int N = 0, S = 1, E = 2, W = 3; + private final double[] coord = new double[4]; @FXML private AnchorPane root; @FXML @@ -100,6 +101,12 @@ public class DashboardController implements Initializable, MapComponentInitializ @FXML private LineChart speedTChart, hrTChart, cadenceTChart; + @FXML + private ChoiceBox choiceBox; + + @FXML + private StackPane charts; + @Override public void initialize(URL location, ResourceBundle resources) { mapView.setVisible(false); @@ -116,13 +123,14 @@ public class DashboardController implements Initializable, MapComponentInitializ imgDate.setImage(new Image(App.class.getResourceAsStream("img/date.png"))); imgDistance.setImage(new Image(App.class.getResourceAsStream("img/distance.png"))); imgElevation.setImage(new Image(App.class.getResourceAsStream("img/elevation.png"))); - } - @FXML - private void toggleChart(MouseEvent e) { - System.out.println("hi"); - for (Node n : ((Node) e.getSource()).getParent().getChildrenUnmodifiable()) - n.setVisible(!n.isVisible()); + choiceBox.getItems().add(App.GENERAL_BUNDLE.getString("label.distance")); + choiceBox.getItems().add(App.GENERAL_BUNDLE.getString("label.time")); + choiceBox.setValue(choiceBox.getItems().get(0)); + choiceBox.valueProperty().addListener((observableValue, s, t1) -> { + for (Node n : charts.getChildrenUnmodifiable()) + n.setVisible(!n.isVisible()); + }); } @FXML diff --git a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml index 6f15eee..bb69099 100644 --- a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml +++ b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml @@ -25,17 +25,27 @@ ~ --> - + + + - - - - - - - - + + + + + + + + + + + + + + + + + @@ -50,8 +60,8 @@ - - + + @@ -63,8 +73,7 @@ - + @@ -98,9 +107,9 @@ - - - + + + - + - + @@ -217,8 +224,8 @@ - - + + @@ -232,8 +239,8 @@ - - + + - + @@ -274,8 +280,8 @@ - - + + - + @@ -303,8 +308,8 @@ - - + + @@ -326,9 +331,9 @@ - - - + + + - + @@ -417,96 +421,85 @@ - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/general.properties b/src/main/resources/general.properties index d0c31b1..fff17c3 100644 --- a/src/main/resources/general.properties +++ b/src/main/resources/general.properties @@ -37,6 +37,7 @@ label.loadGPX=Load GPX file label.maxHR=Max. heart rate label.motivation=Welcome! label.speed=Speed +label.time=Time label.welcome=Welcome! tab.dashboard=Dashboard tab.graph=Stats diff --git a/src/main/resources/general_ca.properties b/src/main/resources/general_ca.properties index 6c05642..87795fe 100644 --- a/src/main/resources/general_ca.properties +++ b/src/main/resources/general_ca.properties @@ -37,6 +37,7 @@ label.loadGPX=Obrir arxiu GPX label.maxHR=Max. pulsacions/min label.motivation=\u00a1Benvinguts! label.speed=Speed +label.time=Temps label.welcome=Benvingut! tab.dashboard=Sumari tab.graph=Estad\u00edstiques diff --git a/src/main/resources/general_es.properties b/src/main/resources/general_es.properties index 6d68538..5d6c81d 100644 --- a/src/main/resources/general_es.properties +++ b/src/main/resources/general_es.properties @@ -37,6 +37,7 @@ label.loadGPX=Abrir archivo GPX label.maxHR=Max. pulsaciones/min label.motivation=\u00a1Bienvenido! label.speed=Velocidad +label.time=Tiempo label.welcome=¡Bienvenido! tab.dashboard=Res\u00famen tab.graph=Estad\u00edsticas