diff --git a/src/main/java/es/kauron/estraba/controller/DashboardController.java b/src/main/java/es/kauron/estraba/controller/DashboardController.java index 7ef8099..e46b541 100644 --- a/src/main/java/es/kauron/estraba/controller/DashboardController.java +++ b/src/main/java/es/kauron/estraba/controller/DashboardController.java @@ -2,12 +2,6 @@ package es.kauron.estraba.controller; import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXSnackbar; -import com.lynden.gmapsfx.GoogleMapView; -import com.lynden.gmapsfx.javascript.object.GoogleMap; -import com.lynden.gmapsfx.javascript.object.LatLong; -import com.lynden.gmapsfx.javascript.object.MVCArray; -import com.lynden.gmapsfx.shapes.Polyline; -import com.lynden.gmapsfx.shapes.PolylineOptions; import es.kauron.estraba.App; import javafx.collections.ObservableList; import javafx.event.ActionEvent; @@ -128,8 +122,8 @@ public class DashboardController implements Initializable { @FXML private Tab tabMap; - @FXML - private GoogleMapView mapView; + //@FXML + //private GoogleMapView mapView; @FXML private JFXButton elevationButton; @@ -143,26 +137,29 @@ public class DashboardController implements Initializable { @FXML private JFXButton cadenceButton; + @FXML + private LineChart mapChart; + @FXML private Tab tabGraph; @FXML - private AreaChart elevationChart; + private AreaChart elevationChart; @FXML - private LineChart speedChart; + private LineChart speedChart; @FXML - private LineChart hrChart; + private LineChart hrChart; @FXML - private LineChart cadenceChart; + private LineChart cadenceChart; @FXML private Tab tabSettings; private JFXSnackbar snackbar; - private final double DISTANCE_EPSILON = 1; + private final double DISTANCE_EPSILON = 10; @Override public void initialize(URL location, ResourceBundle resources) { @@ -179,12 +176,25 @@ public class DashboardController implements Initializable { 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 onMapButton(ActionEvent event){ - System.out.println(((JFXButton)event.getSource()).getId()); + mapChart.getData().clear(); + switch (((JFXButton)event.getSource()).getId()) { + case "elevationButton": + mapChart.setData(elevationChart.getData()); + break; + case "speedButton": + mapChart.setData(speedChart.getData()); + break; + case "hrButton": + mapChart.setData(hrChart.getData()); + break; + case "cadenceButton": + mapChart.setData(cadenceChart.getData()); + break; + } } public void postinit() { @@ -230,24 +240,44 @@ public class DashboardController implements Initializable { + App.GENERAL_BUNDLE.getString("unit.m")); // create charts data - XYChart.Series elevationChartData = new XYChart.Series<>(); - XYChart.Series speedChartData = new XYChart.Series<>(); - XYChart.Series hrChartData = new XYChart.Series<>(); - XYChart.Series cadenceChartData = new XYChart.Series<>(); - MVCArray pathArray = new MVCArray(); + XYChart.Series elevationChartData = new XYChart.Series<>(); + XYChart.Series speedChartData = new XYChart.Series<>(); + XYChart.Series hrChartData = new XYChart.Series<>(); + XYChart.Series cadenceChartData = new XYChart.Series<>(); + // MVCArray pathArray = new MVCArray(); + // traverse the chunks ObservableList chunks = track.getChunks(); double currentDistance = 0.0; + double currentHeight = 0.0; for (Chunk chunk : chunks) { + System.err.println(chunk.getDistance()); currentDistance += chunk.getDistance(); if (chunk.getDistance() < DISTANCE_EPSILON) continue; + currentHeight += chunk.getAscent() - chunk.getDescend(); - pathArray.push(new LatLong(chunk.getLastPoint().getLatitude(), chunk.getLastPoint().getLongitude())); - elevationChartData.getData().add(new XYChart.Data<>(currentDistance, chunk.getAscent())); + // pathArray.push(new LatLong(chunk.getLastPoint().getLatitude(), chunk.getLastPoint().getLongitude())); + elevationChartData.getData().add(new XYChart.Data<>(currentDistance, currentHeight)); speedChartData.getData().add(new XYChart.Data<>(currentDistance, chunk.getSpeed())); hrChartData.getData().add(new XYChart.Data<>(currentDistance, chunk.getAvgHeartRate())); cadenceChartData.getData().add(new XYChart.Data<>(currentDistance, chunk.getAvgCadence())); + + String zone; + if (chunk.getAvgHeartRate() > 170) zone = "Zone 4"; + else if (chunk.getAvgHeartRate() > 150) zone = "Zone 3"; + else if (chunk.getAvgHeartRate() > 130) zone = "Zone 2"; + else if (chunk.getAvgHeartRate() > 110) zone = "Zone 1"; + else zone = "Zone 0"; + + boolean pieFound = false; + for (PieChart.Data d : zoneChart.getData()){ + if (d.getName().equals(zone)) { + pieFound = true; + d.setPieValue(d.getPieValue() + 1); + } + } + if (!pieFound) zoneChart.getData().add( new PieChart.Data(zone, 1) ); } // populate the charts @@ -257,13 +287,13 @@ public class DashboardController implements Initializable { cadenceChart.getData().add(cadenceChartData); // populate and render the map - GoogleMap map = mapView.createMap(); - map.addMapShape(new Polyline( - new PolylineOptions() - .path(pathArray) - .strokeColor("red") - .strokeWeight(2)) - ); + //GoogleMap map = mapView.createMap(); + //map.addMapShape(new Polyline( + // new PolylineOptions() + // .path(pathArray) + // .strokeColor("red") + // .strokeWeight(2)) + //); } @@ -282,9 +312,9 @@ public class DashboardController implements Initializable { if (gpx != null) { loadTrack(new TrackData(new Track(gpx.getTrk().get(0)))); - snackbar.show("GPX file: " + name + "successfully loaded", 3000); + //snackbar.show("GPX file: " + name + "successfully loaded", 3000); } else { - snackbar.show("Error loading GPX file: " + name, 3000); + //snackbar.show("Error loading GPX file: " + name, 3000); } } diff --git a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml index 4dd08c3..833c3ef 100644 --- a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml +++ b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml @@ -2,11 +2,9 @@ - - @@ -19,389 +17,333 @@ - - + + - + - @@ -409,61 +351,50 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -472,44 +403,44 @@ - + - + - + - + - + - + - + - + - + - + diff --git a/src/main/resources/general.properties b/src/main/resources/general.properties index 9befe30..f1c72d3 100644 --- a/src/main/resources/general.properties +++ b/src/main/resources/general.properties @@ -1,5 +1,15 @@ +label.cadence=Cadence +label.distance=Distance +label.elevation=Elevation +label.hr=Heart rate label.motivation=Welcome! +label.speed=Speed tab.dashboard=Dashboard tab.graph=Stats tab.map=Your Route -tab.settings=Settings \ No newline at end of file +tab.settings=Settings +time.of=of +unit.bpm=\ bpm +unit.hz=\ Hz +unit.kmph=\ kmph +unit.m=\ m \ No newline at end of file diff --git a/src/main/resources/general_ca.properties b/src/main/resources/general_ca.properties index a75e239..72a53be 100644 --- a/src/main/resources/general_ca.properties +++ b/src/main/resources/general_ca.properties @@ -1,5 +1,15 @@ +label.cadence=Cadencia +label.distance=Distancia +label.elevation=Elevacion +label.hr=YOLO label.motivation=¡Benvinguts! +label.speed=Speed tab.dashboard=Sumari tab.graph=Estadístiques tab.map=La teva ruta -tab.settings=Ajustos \ No newline at end of file +tab.settings=Ajustos +time.of=de +unit.bpm=\ ppm +unit.hz=\ Hz +unit.kmph=\ kmph +unit.m=\ m \ No newline at end of file diff --git a/src/main/resources/general_es.properties b/src/main/resources/general_es.properties index 5416bb4..21b2aa6 100644 --- a/src/main/resources/general_es.properties +++ b/src/main/resources/general_es.properties @@ -1,5 +1,15 @@ +label.cadence=Cadencia +label.distance=Distancia +label.elevation=Elevacion +label.hr=Pulsaciónes label.motivation=¡Bienvenido! +label.speed=Velocidad tab.dashboard=Resúmen tab.graph=Estadísticas tab.map=Tu ruta -tab.settings=Ajustes \ No newline at end of file +tab.settings=Ajustes +time.of=de +unit.bpm=\ ppm +unit.hz=\ Hz +unit.kmph=\ kmph +unit.m=\ m \ No newline at end of file