fixed task initialization, and some minor fixed, started with CSS stuff
This commit is contained in:
parent
94f4a8ebee
commit
a92c429a95
10 changed files with 42 additions and 35 deletions
|
@ -110,6 +110,9 @@ public class DashboardController implements Initializable, MapComponentInitializ
|
|||
loadTrack(bundle);
|
||||
}
|
||||
|
||||
private String randomMotivation() {
|
||||
return App.GENERAL_BUNDLE.getString("label.welcome");
|
||||
}
|
||||
private void loadTrack(DataBundle bundle) {
|
||||
valueHRAvg.setText(bundle.HRAvg);
|
||||
valueHRMax.setText(bundle.HRMax);
|
||||
|
@ -126,7 +129,6 @@ public class DashboardController implements Initializable, MapComponentInitializ
|
|||
valueElevation.setText(bundle.elevation);
|
||||
valueAscent.setText(bundle.ascent);
|
||||
valueDescent.setText(bundle.descent);
|
||||
|
||||
zoneChart.setData(bundle.pieData);
|
||||
|
||||
// populate the charts
|
||||
|
|
|
@ -50,8 +50,7 @@ public class SplashController implements Initializable{
|
|||
private File file;
|
||||
|
||||
@FXML
|
||||
private void loadGPXFile(ActionEvent event) {
|
||||
|
||||
private void loadGPXFile(ActionEvent event) throws Exception {
|
||||
buttonLoad.setVisible(false);
|
||||
labelWelcome.setVisible(false);
|
||||
spinner.setVisible(true);
|
||||
|
@ -59,40 +58,42 @@ public class SplashController implements Initializable{
|
|||
snackbar.show("Loading file", 5000);
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
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());
|
||||
if (file == null) {
|
||||
errorLoading();
|
||||
return;
|
||||
}
|
||||
Task<DataBundle> task = new Task<DataBundle>() {
|
||||
|
||||
Task<DataBundle> t = new Task<DataBundle>() {
|
||||
@Override
|
||||
protected DataBundle call() throws Exception {
|
||||
try {
|
||||
updateValue(DataBundle.loadFrom(file));
|
||||
succeeded();
|
||||
} catch (IOException e) {
|
||||
updateValue(null);
|
||||
errorLoading();
|
||||
}
|
||||
return getValue();
|
||||
DataBundle db = DataBundle.loadFrom(file);
|
||||
System.out.println("done");
|
||||
updateProgress(1, 1);
|
||||
return db;
|
||||
}
|
||||
};
|
||||
Thread t = new Thread(task);
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
task.setOnSucceeded(state -> {
|
||||
DataBundle bundle = (DataBundle) state.getSource().getValue();
|
||||
|
||||
t.setOnSucceeded(ev -> {
|
||||
DataBundle bundle = t.getValue();
|
||||
if (bundle == null) errorLoading();
|
||||
FXMLLoader loader = new FXMLLoader(
|
||||
App.class.getResource("fxml/Dashboard.fxml"), App.GENERAL_BUNDLE);
|
||||
Parent parent = null;
|
||||
try {
|
||||
parent = loader.load();
|
||||
} catch (IOException e) {errorLoading();}
|
||||
} catch (IOException e) {
|
||||
errorLoading();
|
||||
}
|
||||
loader.<DashboardController>getController().postInit(bundle);
|
||||
((Stage) root.getScene().getWindow()).setScene(new Scene(parent));
|
||||
});
|
||||
|
||||
Thread th = new Thread(t);
|
||||
th.setDaemon(true);
|
||||
th.start();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,15 +26,11 @@ public class DataBundle {
|
|||
|
||||
public String HRAvg, HRMax, HRMin, speedAvg, speedMax, cadenceAvg, cadenceMax;
|
||||
public String date, time, activeTime, totalTime, distance, elevation, ascent, descent;
|
||||
public XYChart.Series<Double, Double> elevationSeries = new XYChart.Series<>(),
|
||||
speedSeries = new XYChart.Series<>(),
|
||||
hrSeries = new XYChart.Series<>(),
|
||||
cadenceSeries = new XYChart.Series<>();
|
||||
public ObservableList<PieChart.Data> pieData = FXCollections.emptyObservableList();
|
||||
public XYChart.Series<Double, Double> elevationSeries, speedSeries, hrSeries, cadenceSeries;
|
||||
public ObservableList<PieChart.Data> pieData;
|
||||
public ObservableList<Chunk> chunks;
|
||||
|
||||
public static DataBundle loadFrom(File file) throws Exception {
|
||||
String name = file.getName();
|
||||
JAXBElement<Object> jaxbElement;
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(GpxType.class, TrackPointExtensionT.class);
|
||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||
|
@ -46,8 +42,9 @@ public class DataBundle {
|
|||
}
|
||||
|
||||
private DataBundle(TrackData track) {
|
||||
|
||||
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");
|
||||
|
||||
// speed is given as m/s
|
||||
|
@ -77,6 +74,13 @@ public class DataBundle {
|
|||
chunks = track.getChunks();
|
||||
double currentDistance = 0.0;
|
||||
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) {
|
||||
currentDistance += chunk.getDistance();
|
||||
if (chunk.getDistance() < DISTANCE_EPSILON) continue;
|
||||
|
|
0
src/main/resources/es/kauron/estraba/css/estraba.css
Normal file
0
src/main/resources/es/kauron/estraba/css/estraba.css
Normal file
|
@ -61,7 +61,7 @@
|
|||
</font>
|
||||
<styleClass>
|
||||
<String fx:value=".estraba.dashboard.label" />
|
||||
<String fx:value=".estraba.dashboard.label.HR" />
|
||||
<String fx:value=".estraba.dashboard.label.hr" />
|
||||
</styleClass>
|
||||
</Label>
|
||||
<Label fx:id="valueHRAvg" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER">
|
||||
|
@ -118,7 +118,7 @@
|
|||
</font>
|
||||
<styleClass>
|
||||
<String fx:value=".estraba.dashboard.label" />
|
||||
<String fx:value=".estraba.dashboard.label.HR" />
|
||||
<String fx:value=".estraba.dashboard.label.speed" />
|
||||
</styleClass>
|
||||
</Label>
|
||||
<Label fx:id="valueSpeedAvg" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER">
|
||||
|
@ -160,7 +160,7 @@
|
|||
</font>
|
||||
<styleClass>
|
||||
<String fx:value=".estraba.dashboard.label" />
|
||||
<String fx:value=".estraba.dashboard.label.HR" />
|
||||
<String fx:value=".estraba.dashboard.label.cadence" />
|
||||
</styleClass>
|
||||
</Label>
|
||||
<Label fx:id="valueCadenceAvg" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER">
|
||||
|
@ -260,7 +260,7 @@
|
|||
</font>
|
||||
<styleClass>
|
||||
<String fx:value=".estraba.dashboard.label" />
|
||||
<String fx:value=".estraba.dashboard.label.HR" />
|
||||
<String fx:value=".estraba.dashboard.label.distance" />
|
||||
</styleClass>
|
||||
</Label>
|
||||
<Label fx:id="valueDistance" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER">
|
||||
|
@ -289,7 +289,7 @@
|
|||
</font>
|
||||
<styleClass>
|
||||
<String fx:value=".estraba.dashboard.label" />
|
||||
<String fx:value=".estraba.dashboard.label.HR" />
|
||||
<String fx:value=".estraba.dashboard.label.elevation" />
|
||||
</styleClass>
|
||||
</Label>
|
||||
<Label fx:id="valueElevation" alignment="CENTER" maxWidth="1.7976931348623157E308" textAlignment="CENTER">
|
||||
|
@ -356,7 +356,7 @@
|
|||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
<StackPane prefHeight="150.0" prefWidth="200.0">
|
||||
<StackPane prefHeight="150.0" prefWidth="200.0" VBox.vgrow="ALWAYS" >
|
||||
<children>
|
||||
<GoogleMapView fx:id="mapView" />
|
||||
<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 |
|
@ -1,4 +1,4 @@
|
|||
app.extension.filter.name=GPX data files
|
||||
app.extension=GPX data files
|
||||
app.title=ESTRABA
|
||||
label.cadence=Cadence
|
||||
label.distance=Distance
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
app.extension.filter.name=Arxius GPX
|
||||
app.extension=Arxius GPX
|
||||
app.title=ESTRABA
|
||||
label.cadence=Cadencia
|
||||
label.distance=Distancia
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
app.extension.filter.name=Archivos de datos GPX
|
||||
app.extension=Archivos de datos GPX
|
||||
app.title=ESTRABA
|
||||
label.cadence=Cadencia
|
||||
label.distance=Distancia
|
||||
|
|
Reference in a new issue