kauron/estraba
Archived
1
0
Fork 0
This commit is contained in:
Jesús Vélez Palacios 2016-05-18 13:01:11 +02:00
parent dbbe15ec9e
commit 169b8a8396
15 changed files with 243 additions and 193 deletions

View file

@ -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.<DashboardController>getController().postinit();
}
}

View file

@ -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<Double, Double> elevationChart;
private AreaChart<Number, Number> elevationChart;
@FXML
private LineChart<Double, Double> speedChart;
private LineChart<Number, Number> speedChart;
@FXML
private LineChart<Double, Double> hrChart;
private LineChart<Number, Number> hrChart;
@FXML
private LineChart<Double, Double> cadenceChart;
private LineChart<Number, Number> 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<Chunk> 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<Object> jaxbElement = (JAXBElement<Object>) 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);
}
}
}

View file

@ -9,6 +9,7 @@
<?import javafx.scene.chart.CategoryAxis?>
<?import javafx.scene.chart.LineChart?>
<?import javafx.scene.chart.NumberAxis?>
<?import javafx.scene.chart.PieChart?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.image.ImageView?>
@ -17,65 +18,122 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<JFXTabPane fx:id="root" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.76-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="es.kauron.estraba.controller.DashboardController">
<tabs>
<Tab fx:id="tabDashboard" text="%tab.dashboard">
<content>
<AnchorPane>
<children>
<Label alignment="CENTER" text="%label.welcome" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Roboto" size="50.0" />
</font>
</Label>
</children></AnchorPane>
</content>
</Tab>
<Tab fx:id="tabMap" text="%tab.map">
<content>
<VBox>
<children>
<HBox VBox.vgrow="ALWAYS">
<AnchorPane fx:id="root" xmlns="http://javafx.com/javafx/8.0.76-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="es.kauron.estraba.controller.DashboardController">
<children>
<JFXTabPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<tabs>
<Tab fx:id="tabDashboard" text="%tab.dashboard">
<content>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<GoogleMapView fx:id="mapView" HBox.hgrow="ALWAYS" />
<JFXListView fx:id="mapSummary" minWidth="100.0" />
</children>
</HBox>
<HBox minHeight="128.0" prefHeight="0.0">
<children>
<VBox prefHeight="128.0" prefWidth="100.0" HBox.hgrow="ALWAYS">
<HBox prefHeight="100.0" prefWidth="200.0" VBox.vgrow="ALWAYS">
<children>
<JFXButton fx:id="elevationButton" minHeight="32.0" minWidth="32.0" onAction="#onMapButton">
<graphic>
<ImageView fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true" />
</graphic>
<VBox.margin>
<Insets />
</VBox.margin></JFXButton>
<JFXButton fx:id="speedButton" layoutX="10.0" layoutY="10.0" minHeight="32.0" minWidth="32.0" onAction="#onMapButton">
<graphic>
<ImageView fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true" />
</graphic>
<VBox.margin>
<Insets />
</VBox.margin></JFXButton>
<JFXButton fx:id="hrButton" layoutX="10.0" layoutY="10.0" minHeight="32.0" minWidth="32.0" onAction="#onMapButton">
<graphic>
<ImageView fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true" />
</graphic>
<VBox.margin>
<Insets />
</VBox.margin></JFXButton>
<JFXButton fx:id="cadenceButton" layoutX="10.0" layoutY="42.0" minHeight="32.0" minWidth="32.0" onAction="#onMapButton">
<graphic>
<ImageView fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true" />
</graphic>
<VBox.margin>
<Insets />
</VBox.margin></JFXButton>
<VBox minHeight="375.0" minWidth="180.0">
<children>
<HBox prefHeight="75.0" prefWidth="180.0" />
<HBox layoutX="10.0" layoutY="10.0" prefHeight="75.0" prefWidth="180.0" />
<HBox layoutX="10.0" layoutY="10.0" prefHeight="75.0" prefWidth="180.0" />
<HBox layoutX="10.0" layoutY="110.0" prefHeight="75.0" prefWidth="180.0" />
<HBox layoutX="10.0" layoutY="102.0" prefHeight="75.0" prefWidth="180.0" />
</children>
</VBox>
<PieChart fx:id="zoneChart" legendVisible="false" minHeight="375.0" minWidth="0.0" HBox.hgrow="ALWAYS" />
<VBox layoutX="10.0" layoutY="10.0" minHeight="375.0" minWidth="180.0" />
</children>
</VBox>
<LineChart minHeight="100.0" prefWidth="9999.0">
</HBox>
<Label fx:id="motivationLabel" alignment="CENTER" focusTraversable="false" maxWidth="1.7976931348623157E308" text="%label.motivation">
<font>
<Font name="Roboto" size="56.0" />
</font>
<VBox.margin>
<Insets bottom="60.0" top="55.0" />
</VBox.margin>
</Label>
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</VBox>
</content>
</Tab>
<Tab fx:id="tabMap" text="%tab.map">
<content>
<VBox>
<children>
<HBox VBox.vgrow="ALWAYS">
<children>
<GoogleMapView fx:id="mapView" HBox.hgrow="ALWAYS" />
<JFXListView fx:id="mapSummary" minWidth="180.0" />
</children>
</HBox>
<HBox minHeight="128.0" prefHeight="0.0">
<children>
<VBox prefHeight="128.0" prefWidth="100.0" HBox.hgrow="ALWAYS">
<children>
<JFXButton fx:id="elevationButton" minHeight="32.0" minWidth="32.0" onAction="#onMapButton">
<graphic>
<ImageView fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true" />
</graphic>
<VBox.margin>
<Insets />
</VBox.margin>
</JFXButton>
<JFXButton fx:id="speedButton" layoutX="10.0" layoutY="10.0" minHeight="32.0" minWidth="32.0" onAction="#onMapButton">
<graphic>
<ImageView fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true" />
</graphic>
<VBox.margin>
<Insets />
</VBox.margin>
</JFXButton>
<JFXButton fx:id="hrButton" layoutX="10.0" layoutY="10.0" minHeight="32.0" minWidth="32.0" onAction="#onMapButton">
<graphic>
<ImageView fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true" />
</graphic>
<VBox.margin>
<Insets />
</VBox.margin>
</JFXButton>
<JFXButton fx:id="cadenceButton" layoutX="10.0" layoutY="42.0" minHeight="32.0" minWidth="32.0" onAction="#onMapButton">
<graphic>
<ImageView fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true" />
</graphic>
<VBox.margin>
<Insets />
</VBox.margin>
</JFXButton>
</children>
</VBox>
<LineChart minHeight="100.0" prefWidth="9999.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
</children>
</HBox>
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</VBox>
</content>
</Tab>
<Tab fx:id="tabGraph" text="%tab.graph">
<content>
<VBox>
<children>
<AreaChart fx:id="elevationChart" minHeight="100.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</AreaChart>
<LineChart fx:id="speedChart" minHeight="100.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
@ -83,56 +141,35 @@
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
<LineChart fx:id="hrChart" minHeight="100.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
<LineChart fx:id="cadenceChart" minHeight="100.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
</children>
</HBox>
</children>
</VBox>
</content>
</Tab>
<Tab fx:id="tabGraph" text="%tab.graph">
<content>
<VBox>
<children>
<AreaChart fx:id="elevationChart" minHeight="100.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</AreaChart>
<LineChart fx:id="speedChart" minHeight="100.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
<LineChart fx:id="hrChart" minHeight="100.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
<LineChart fx:id="cadenceChart" minHeight="100.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
</children>
</VBox>
</content>
</Tab>
<Tab fx:id="tabSettings" text="%tab.settings">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
</tabs>
</JFXTabPane>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</VBox>
</content>
</Tab>
<Tab fx:id="tabSettings" text="%tab.settings">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
</tabs>
</JFXTabPane>
</children>
</AnchorPane>

View file

Before

Width:  |  Height:  |  Size: 922 B

After

Width:  |  Height:  |  Size: 922 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 857 B

After

Width:  |  Height:  |  Size: 857 B

Before After
Before After

View file

@ -1,4 +1,4 @@
label.welcome=Welcome!
label.motivation=Welcome!
tab.dashboard=Dashboard
tab.graph=Stats
tab.map=Your Route

View file

@ -1,4 +1,4 @@
label.welcome=¡Benvinguts!
label.motivation=¡Benvinguts!
tab.dashboard=Sumari
tab.graph=Estadístiques
tab.map=La teva ruta

View file

@ -1,4 +1,4 @@
label.welcome=¡Bienvenido!
label.motivation=¡Bienvenido!
tab.dashboard=Resúmen
tab.graph=Estadísticas
tab.map=Tu ruta