kauron/estraba
Archived
1
0
Fork 0

fixed task initialization, and some minor fixed, started with CSS stuff

This commit is contained in:
Jesús Vélez Palacios 2016-05-21 19:55:45 +02:00
parent 94f4a8ebee
commit a92c429a95
10 changed files with 42 additions and 35 deletions

View file

@ -110,6 +110,9 @@ public class DashboardController implements Initializable, MapComponentInitializ
loadTrack(bundle); loadTrack(bundle);
} }
private String randomMotivation() {
return App.GENERAL_BUNDLE.getString("label.welcome");
}
private void loadTrack(DataBundle bundle) { private void loadTrack(DataBundle bundle) {
valueHRAvg.setText(bundle.HRAvg); valueHRAvg.setText(bundle.HRAvg);
valueHRMax.setText(bundle.HRMax); valueHRMax.setText(bundle.HRMax);
@ -126,7 +129,6 @@ public class DashboardController implements Initializable, MapComponentInitializ
valueElevation.setText(bundle.elevation); valueElevation.setText(bundle.elevation);
valueAscent.setText(bundle.ascent); valueAscent.setText(bundle.ascent);
valueDescent.setText(bundle.descent); valueDescent.setText(bundle.descent);
zoneChart.setData(bundle.pieData); zoneChart.setData(bundle.pieData);
// populate the charts // populate the charts

View file

@ -50,8 +50,7 @@ public class SplashController implements Initializable{
private File file; private File file;
@FXML @FXML
private void loadGPXFile(ActionEvent event) { private void loadGPXFile(ActionEvent event) throws Exception {
buttonLoad.setVisible(false); buttonLoad.setVisible(false);
labelWelcome.setVisible(false); labelWelcome.setVisible(false);
spinner.setVisible(true); spinner.setVisible(true);
@ -59,40 +58,42 @@ public class SplashController implements Initializable{
snackbar.show("Loading file", 5000); snackbar.show("Loading file", 5000);
FileChooser fileChooser = new FileChooser(); FileChooser fileChooser = new FileChooser();
fileChooser.getExtensionFilters().add( fileChooser.getExtensionFilters().add(
new FileChooser.ExtensionFilter(App.GENERAL_BUNDLE.getString("app.extension.filter.name"), "*.gpx")); new FileChooser.ExtensionFilter(App.GENERAL_BUNDLE.getString("app.extension"), "*.gpx"));
file = fileChooser.showOpenDialog(root.getScene().getWindow()); file = fileChooser.showOpenDialog(root.getScene().getWindow());
if (file == null) { if (file == null) {
errorLoading(); errorLoading();
return; return;
} }
Task<DataBundle> task = new Task<DataBundle>() {
Task<DataBundle> t = new Task<DataBundle>() {
@Override @Override
protected DataBundle call() throws Exception { protected DataBundle call() throws Exception {
try { DataBundle db = DataBundle.loadFrom(file);
updateValue(DataBundle.loadFrom(file)); System.out.println("done");
succeeded(); updateProgress(1, 1);
} catch (IOException e) { return db;
updateValue(null);
errorLoading();
}
return getValue();
} }
}; };
Thread t = new Thread(task);
t.setDaemon(true); t.setOnSucceeded(ev -> {
t.start(); DataBundle bundle = t.getValue();
task.setOnSucceeded(state -> {
DataBundle bundle = (DataBundle) state.getSource().getValue();
if (bundle == null) errorLoading(); if (bundle == null) errorLoading();
FXMLLoader loader = new FXMLLoader( FXMLLoader loader = new FXMLLoader(
App.class.getResource("fxml/Dashboard.fxml"), App.GENERAL_BUNDLE); App.class.getResource("fxml/Dashboard.fxml"), App.GENERAL_BUNDLE);
Parent parent = null; Parent parent = null;
try { try {
parent = loader.load(); parent = loader.load();
} catch (IOException e) {errorLoading();} } catch (IOException e) {
errorLoading();
}
loader.<DashboardController>getController().postInit(bundle); loader.<DashboardController>getController().postInit(bundle);
((Stage) root.getScene().getWindow()).setScene(new Scene(parent)); ((Stage) root.getScene().getWindow()).setScene(new Scene(parent));
}); });
Thread th = new Thread(t);
th.setDaemon(true);
th.start();
} }
@Override @Override

View file

@ -26,15 +26,11 @@ public class DataBundle {
public String HRAvg, HRMax, HRMin, speedAvg, speedMax, cadenceAvg, cadenceMax; public String HRAvg, HRMax, HRMin, speedAvg, speedMax, cadenceAvg, cadenceMax;
public String date, time, activeTime, totalTime, distance, elevation, ascent, descent; public String date, time, activeTime, totalTime, distance, elevation, ascent, descent;
public XYChart.Series<Double, Double> elevationSeries = new XYChart.Series<>(), public XYChart.Series<Double, Double> elevationSeries, speedSeries, hrSeries, cadenceSeries;
speedSeries = new XYChart.Series<>(), public ObservableList<PieChart.Data> pieData;
hrSeries = new XYChart.Series<>(),
cadenceSeries = new XYChart.Series<>();
public ObservableList<PieChart.Data> pieData = FXCollections.emptyObservableList();
public ObservableList<Chunk> chunks; public ObservableList<Chunk> chunks;
public static DataBundle loadFrom(File file) throws Exception { public static DataBundle loadFrom(File file) throws Exception {
String name = file.getName();
JAXBElement<Object> jaxbElement; JAXBElement<Object> jaxbElement;
JAXBContext jaxbContext = JAXBContext.newInstance(GpxType.class, TrackPointExtensionT.class); JAXBContext jaxbContext = JAXBContext.newInstance(GpxType.class, TrackPointExtensionT.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
@ -46,8 +42,9 @@ public class DataBundle {
} }
private DataBundle(TrackData track) { private DataBundle(TrackData track) {
HRAvg = track.getAverageHeartrate() + App.GENERAL_BUNDLE.getString("unit.bpm"); HRAvg = track.getAverageHeartrate() + App.GENERAL_BUNDLE.getString("unit.bpm");
HRMax = (track.getMaxHeartrate() + App.GENERAL_BUNDLE.getString("unit.bpm")); HRMax = track.getMaxHeartrate() + App.GENERAL_BUNDLE.getString("unit.bpm");
HRMin = track.getMinHeartRate() + App.GENERAL_BUNDLE.getString("unit.bpm"); HRMin = track.getMinHeartRate() + App.GENERAL_BUNDLE.getString("unit.bpm");
// speed is given as m/s // speed is given as m/s
@ -77,6 +74,13 @@ public class DataBundle {
chunks = track.getChunks(); chunks = track.getChunks();
double currentDistance = 0.0; double currentDistance = 0.0;
double currentHeight = chunks.get(0).getFirstPoint().getElevation(); double currentHeight = chunks.get(0).getFirstPoint().getElevation();
elevationSeries = new XYChart.Series<>();
cadenceSeries = new XYChart.Series<>();
hrSeries = new XYChart.Series<>();
speedSeries = new XYChart.Series<>();
pieData = FXCollections.observableArrayList();
for (Chunk chunk : chunks) { for (Chunk chunk : chunks) {
currentDistance += chunk.getDistance(); currentDistance += chunk.getDistance();
if (chunk.getDistance() < DISTANCE_EPSILON) continue; if (chunk.getDistance() < DISTANCE_EPSILON) continue;

View file

@ -61,7 +61,7 @@
</font> </font>
<styleClass> <styleClass>
<String fx:value=".estraba.dashboard.label" /> <String fx:value=".estraba.dashboard.label" />
<String fx:value=".estraba.dashboard.label.HR" /> <String fx:value=".estraba.dashboard.label.hr" />
</styleClass> </styleClass>
</Label> </Label>
<Label fx:id="valueHRAvg" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER"> <Label fx:id="valueHRAvg" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER">
@ -118,7 +118,7 @@
</font> </font>
<styleClass> <styleClass>
<String fx:value=".estraba.dashboard.label" /> <String fx:value=".estraba.dashboard.label" />
<String fx:value=".estraba.dashboard.label.HR" /> <String fx:value=".estraba.dashboard.label.speed" />
</styleClass> </styleClass>
</Label> </Label>
<Label fx:id="valueSpeedAvg" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER"> <Label fx:id="valueSpeedAvg" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER">
@ -160,7 +160,7 @@
</font> </font>
<styleClass> <styleClass>
<String fx:value=".estraba.dashboard.label" /> <String fx:value=".estraba.dashboard.label" />
<String fx:value=".estraba.dashboard.label.HR" /> <String fx:value=".estraba.dashboard.label.cadence" />
</styleClass> </styleClass>
</Label> </Label>
<Label fx:id="valueCadenceAvg" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER"> <Label fx:id="valueCadenceAvg" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER">
@ -260,7 +260,7 @@
</font> </font>
<styleClass> <styleClass>
<String fx:value=".estraba.dashboard.label" /> <String fx:value=".estraba.dashboard.label" />
<String fx:value=".estraba.dashboard.label.HR" /> <String fx:value=".estraba.dashboard.label.distance" />
</styleClass> </styleClass>
</Label> </Label>
<Label fx:id="valueDistance" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER"> <Label fx:id="valueDistance" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER">
@ -289,7 +289,7 @@
</font> </font>
<styleClass> <styleClass>
<String fx:value=".estraba.dashboard.label" /> <String fx:value=".estraba.dashboard.label" />
<String fx:value=".estraba.dashboard.label.HR" /> <String fx:value=".estraba.dashboard.label.elevation" />
</styleClass> </styleClass>
</Label> </Label>
<Label fx:id="valueElevation" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER"> <Label fx:id="valueElevation" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER">
@ -356,7 +356,7 @@
<padding> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>
<StackPane prefHeight="150.0" prefWidth="200.0"> <StackPane prefHeight="150.0" prefWidth="200.0" VBox.vgrow="ALWAYS" >
<children> <children>
<GoogleMapView fx:id="mapView" /> <GoogleMapView fx:id="mapView" />
<JFXSpinner fx:id="mapSpinner" /> <JFXSpinner fx:id="mapSpinner" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -1,4 +1,4 @@
app.extension.filter.name=GPX data files app.extension=GPX data files
app.title=ESTRABA app.title=ESTRABA
label.cadence=Cadence label.cadence=Cadence
label.distance=Distance label.distance=Distance

View file

@ -1,4 +1,4 @@
app.extension.filter.name=Arxius GPX app.extension=Arxius GPX
app.title=ESTRABA app.title=ESTRABA
label.cadence=Cadencia label.cadence=Cadencia
label.distance=Distancia label.distance=Distancia

View file

@ -1,4 +1,4 @@
app.extension.filter.name=Archivos de datos GPX app.extension=Archivos de datos GPX
app.title=ESTRABA app.title=ESTRABA
label.cadence=Cadencia label.cadence=Cadencia
label.distance=Distancia label.distance=Distancia