From bb377effea5c2840f927ff1e40d918204aa06b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20V=C3=A9lez=20Palacios?= Date: Thu, 19 May 2016 11:22:11 +0200 Subject: [PATCH] dashboard redesign --- .../controller/DashboardController.java | 27 +++++++----- .../es/kauron/estraba/fxml/Dashboard.fxml | 43 ++++++++++--------- src/main/resources/general.properties | 8 +++- src/main/resources/general_ca.properties | 24 +++++++---- src/main/resources/general_es.properties | 16 ++++--- 5 files changed, 71 insertions(+), 47 deletions(-) diff --git a/src/main/java/es/kauron/estraba/controller/DashboardController.java b/src/main/java/es/kauron/estraba/controller/DashboardController.java index e46b541..c2cfef2 100644 --- a/src/main/java/es/kauron/estraba/controller/DashboardController.java +++ b/src/main/java/es/kauron/estraba/controller/DashboardController.java @@ -2,6 +2,7 @@ package es.kauron.estraba.controller; import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXSnackbar; +import com.lynden.gmapsfx.GoogleMapView; import es.kauron.estraba.App; import javafx.collections.ObservableList; import javafx.event.ActionEvent; @@ -122,8 +123,8 @@ public class DashboardController implements Initializable { @FXML private Tab tabMap; - //@FXML - //private GoogleMapView mapView; + @FXML + private GoogleMapView mapView; @FXML private JFXButton elevationButton; @@ -160,6 +161,7 @@ public class DashboardController implements Initializable { private JFXSnackbar snackbar; private final double DISTANCE_EPSILON = 10; + private final double KILOMETER_CUTOFF = 10000; @Override public void initialize(URL location, ResourceBundle resources) { @@ -180,7 +182,6 @@ public class DashboardController implements Initializable { @FXML private void onMapButton(ActionEvent event){ - mapChart.getData().clear(); switch (((JFXButton)event.getSource()).getId()) { case "elevationButton": mapChart.setData(elevationChart.getData()); @@ -229,8 +230,13 @@ public class DashboardController implements Initializable { + LocalTime.MIDNIGHT.plus(track.getTotalDuration()) .format(DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM))); - valueDistance.setText(track.getTotalDistance() - + App.GENERAL_BUNDLE.getString("unit.m")); + if (track.getTotalDistance() > KILOMETER_CUTOFF) { + valueDistance.setText(String.format("%.2f", track.getTotalDistance() / 1000) + + App.GENERAL_BUNDLE.getString("unit.km")); + } else { + valueDistance.setText(String.format("%.2f", track.getTotalDistance()) + + App.GENERAL_BUNDLE.getString("unit.m")); + } valueElevation.setText((int)(track.getTotalAscent() - track.getTotalDescend()) + App.GENERAL_BUNDLE.getString("unit.m")); @@ -252,7 +258,6 @@ public class DashboardController implements Initializable { 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(); @@ -264,11 +269,11 @@ public class DashboardController implements Initializable { 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"; + if (chunk.getAvgHeartRate() > 170) zone = App.GENERAL_BUNDLE.getString("zone.anaerobic"); + else if (chunk.getAvgHeartRate() > 150) zone = App.GENERAL_BUNDLE.getString("zone.threshold"); + else if (chunk.getAvgHeartRate() > 130) zone = App.GENERAL_BUNDLE.getString("zone.tempo"); + else if (chunk.getAvgHeartRate() > 110) zone = App.GENERAL_BUNDLE.getString("zone.endurance"); + else zone = App.GENERAL_BUNDLE.getString("zone.recovery"); boolean pieFound = false; for (PieChart.Data d : zoneChart.getData()){ diff --git a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml index 833c3ef..55813f5 100644 --- a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml +++ b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml @@ -2,6 +2,7 @@ + @@ -61,7 +62,7 @@ -