diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 74810cf..560e612 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,7 +1,6 @@ - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 95fd914..da4371a 100644 --- a/pom.xml +++ b/pom.xml @@ -93,11 +93,6 @@ jfxtras-fxml 8.0-r4 - - org.jfxtras - jfxtras-roboto - 8.0-r4 - com.jfoenix jfoenix diff --git a/src/main/java/es/kauron/estraba/App.java b/src/main/java/es/kauron/estraba/App.java index 8a2461c..d8d4243 100644 --- a/src/main/java/es/kauron/estraba/App.java +++ b/src/main/java/es/kauron/estraba/App.java @@ -24,6 +24,7 @@ package es.kauron.estraba; +import es.kauron.estraba.controller.DashboardController; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; @@ -56,5 +57,6 @@ public class App extends Application { stage.setScene(new Scene(root)); stage.setResizable(true); stage.show(); + loader.getController().postinit(); } } diff --git a/src/main/java/es/kauron/estraba/controller/DashboardController.java b/src/main/java/es/kauron/estraba/controller/DashboardController.java index 3c08db8..336475d 100644 --- a/src/main/java/es/kauron/estraba/controller/DashboardController.java +++ b/src/main/java/es/kauron/estraba/controller/DashboardController.java @@ -2,18 +2,34 @@ package es.kauron.estraba.controller; import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXListView; -import com.jfoenix.controls.JFXTabPane; +import com.jfoenix.controls.JFXSnackbar; import com.lynden.gmapsfx.GoogleMapView; +import com.lynden.gmapsfx.javascript.object.GoogleMap; import es.kauron.estraba.App; +import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.chart.AreaChart; import javafx.scene.chart.LineChart; +import javafx.scene.chart.PieChart; +import javafx.scene.control.Label; import javafx.scene.control.Tab; import javafx.scene.image.Image; import javafx.scene.image.ImageView; +import javafx.scene.layout.AnchorPane; +import javafx.stage.FileChooser; +import jgpx.model.analysis.Chunk; +import jgpx.model.analysis.TrackData; +import jgpx.model.gpx.Track; +import jgpx.model.jaxb.GpxType; +import jgpx.model.jaxb.TrackPointExtensionT; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import java.io.File; import java.net.URL; import java.util.ResourceBundle; @@ -25,11 +41,23 @@ import java.util.ResourceBundle; public class DashboardController implements Initializable { @FXML - private JFXTabPane root; + private AnchorPane root; @FXML private Tab tabDashboard; + @FXML + private JFXListView listLeft; + + @FXML + private PieChart zoneChart; + + @FXML + private JFXListView listRight; + + @FXML + private Label motivationLabel; + @FXML private Tab tabMap; @@ -55,31 +83,87 @@ public class DashboardController implements Initializable { 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 GoogleMap map; + private TrackData trackData; + private JFXSnackbar snackbar; + @Override public void initialize(URL location, ResourceBundle resources) { ((ImageView)elevationButton.getGraphic()).setImage(new Image(App.class.getResourceAsStream("img/elevation.png"))); ((ImageView)speedButton.getGraphic()).setImage(new Image(App.class.getResourceAsStream("img/speed.png"))); ((ImageView)hrButton.getGraphic()).setImage(new Image(App.class.getResourceAsStream("img/hr.png"))); ((ImageView)cadenceButton.getGraphic()).setImage(new Image(App.class.getResourceAsStream("img/cadence.png"))); + + + trackData.getStartTime(); + trackData.getTotalDuration(); + trackData.getMovingTime(); + trackData.getTotalDistance(); + trackData.getTotalAscent(); + trackData.getTotalDescend(); + trackData.getMaxSpeed(); + trackData.getAverageSpeed(); + trackData.getMaxHeartrate(); + trackData.getMinHeartRate(); + trackData.getAverageHeartrate(); + trackData.getMaxCadence(); + trackData.getAverageCadence(); + + // populate charts + ObservableList chunks = trackData.getChunks(); + double lastDistance = Double.MIN_VALUE; + for (Chunk chunk : chunks) { + //elevationChart (range min-max+10) + //speedChart (range 0-max+10) + //hrChart (range 30-200) + //cadenceChart (range 0-200 (rollapalluza)) + } + } @FXML private void onMapButton(ActionEvent event){ System.out.println(((JFXButton)event.getSource()).getId()); } + + public void postinit() { + snackbar = new JFXSnackbar(); + snackbar.registerSnackbarContainer(root); + } + + @FXML + private void load(ActionEvent event) throws JAXBException { + FileChooser fileChooser = new FileChooser(); + File file = fileChooser.showOpenDialog(root.getScene().getWindow()); + if (file == null) return; + + String name = file.getName(); + JAXBContext jaxbContext = JAXBContext.newInstance(GpxType.class, TrackPointExtensionT.class); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + JAXBElement jaxbElement = (JAXBElement) unmarshaller.unmarshal(file); + GpxType gpx = (GpxType) jaxbElement.getValue(); + + if (gpx != null) { + trackData = new TrackData(new Track(gpx.getTrk().get(0))); + snackbar.show("GPX file: " + name + "successfully loaded", 3000); + } else { + 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 9698d01..e903d24 100644 --- a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml +++ b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml @@ -9,6 +9,7 @@ + @@ -17,65 +18,122 @@ - - - - - - - - - - - - - - - + + + + + + + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -83,56 +141,35 @@ + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/src/main/resources/es/kauron/estraba/img/climb.png b/src/main/resources/es/kauron/estraba/img/ascent.png similarity index 100% rename from src/main/resources/es/kauron/estraba/img/climb.png rename to src/main/resources/es/kauron/estraba/img/ascent.png diff --git a/src/main/resources/es/kauron/estraba/img/downclimb.png b/src/main/resources/es/kauron/estraba/img/descent.png similarity index 100% rename from src/main/resources/es/kauron/estraba/img/downclimb.png rename to src/main/resources/es/kauron/estraba/img/descent.png diff --git a/src/main/resources/general.properties b/src/main/resources/general.properties index 5782bdd..9befe30 100644 --- a/src/main/resources/general.properties +++ b/src/main/resources/general.properties @@ -1,4 +1,4 @@ -label.welcome=Welcome! +label.motivation=Welcome! tab.dashboard=Dashboard tab.graph=Stats tab.map=Your Route diff --git a/src/main/resources/general_ca.properties b/src/main/resources/general_ca.properties index 9e731ae..a75e239 100644 --- a/src/main/resources/general_ca.properties +++ b/src/main/resources/general_ca.properties @@ -1,4 +1,4 @@ -label.welcome=¡Benvinguts! +label.motivation=¡Benvinguts! tab.dashboard=Sumari tab.graph=Estadístiques tab.map=La teva ruta diff --git a/src/main/resources/general_es.properties b/src/main/resources/general_es.properties index 580a08e..5416bb4 100644 --- a/src/main/resources/general_es.properties +++ b/src/main/resources/general_es.properties @@ -1,4 +1,4 @@ -label.welcome=¡Bienvenido! +label.motivation=¡Bienvenido! tab.dashboard=Resúmen tab.graph=Estadísticas tab.map=Tu ruta