From 74bb277cf2e18dbb212e272ef8a01892ccfe0a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20V=C3=A9lez=20Palacios?= Date: Sat, 21 May 2016 20:59:11 +0200 Subject: [PATCH] cleanliness + minor fixes + copyright --- pom.xml | 2 + src/main/java/es/kauron/estraba/App.java | 1 + .../controller/DashboardController.java | 38 +++++++---- .../estraba/controller/SplashController.java | 44 +++++++++++-- .../es/kauron/estraba/model/DataBundle.java | 51 +++++++++++---- .../es/kauron/estraba/css/estraba.css | 25 +++++++ .../es/kauron/estraba/css/palette.css | 25 +++++++ .../es/kauron/estraba/fxml/Dashboard.fxml | 61 ++++++++++-------- .../es/kauron/estraba/fxml/Splash.fxml | 34 ++++++++-- .../{strava-transparent.png => header.png} | Bin src/main/resources/general.properties | 25 +++++++ src/main/resources/general_ca.properties | 25 +++++++ src/main/resources/general_es.properties | 25 +++++++ 13 files changed, 297 insertions(+), 59 deletions(-) rename src/main/resources/es/kauron/estraba/img/{strava-transparent.png => header.png} (100%) diff --git a/pom.xml b/pom.xml index da4371a..e77cdb3 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ ~ THE SOFTWARE. ~ ~ If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. + ~ --> 1.0 jar ${basedir}/lib/jGPX.jar + ${basedir}/lib/jGPX_javadoc.zip diff --git a/src/main/java/es/kauron/estraba/App.java b/src/main/java/es/kauron/estraba/App.java index 3df4f27..c691ae8 100644 --- a/src/main/java/es/kauron/estraba/App.java +++ b/src/main/java/es/kauron/estraba/App.java @@ -20,6 +20,7 @@ * THE SOFTWARE. * * If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. + * */ package es.kauron.estraba; diff --git a/src/main/java/es/kauron/estraba/controller/DashboardController.java b/src/main/java/es/kauron/estraba/controller/DashboardController.java index 59be425..d2cb440 100644 --- a/src/main/java/es/kauron/estraba/controller/DashboardController.java +++ b/src/main/java/es/kauron/estraba/controller/DashboardController.java @@ -1,7 +1,31 @@ +/* + * Copyright (c) 2016 Jesús "baudlord" Vélez Palacios, Carlos "kauron" Santiago Galindo Jiménez + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. + * + */ + package es.kauron.estraba.controller; import com.jfoenix.controls.JFXButton; -import com.jfoenix.controls.JFXSnackbar; import com.jfoenix.controls.JFXSpinner; import com.lynden.gmapsfx.GoogleMapView; import com.lynden.gmapsfx.MapComponentInitializedListener; @@ -66,8 +90,6 @@ public class DashboardController implements Initializable, MapComponentInitializ @FXML private LineChart speedChart, hrChart, cadenceChart, mapChart; - private JFXSnackbar snackbar; - @Override public void initialize(URL location, ResourceBundle resources) { // populate map icons @@ -83,8 +105,6 @@ public class DashboardController implements Initializable, MapComponentInitializ imgDate.setImage(new Image(App.class.getResourceAsStream("img/date.png"))); imgDistance.setImage(new Image(App.class.getResourceAsStream("img/distance.png"))); imgElevation.setImage(new Image(App.class.getResourceAsStream("img/elevation.png"))); - - snackbar = new JFXSnackbar(); } @FXML @@ -105,15 +125,11 @@ public class DashboardController implements Initializable, MapComponentInitializ } } - void postInit(DataBundle bundle) { - snackbar.registerSnackbarContainer(root); - loadTrack(bundle); - } - private String randomMotivation() { return App.GENERAL_BUNDLE.getString("label.welcome"); } - private void loadTrack(DataBundle bundle) { + + public void load(DataBundle bundle) { valueHRAvg.setText(bundle.HRAvg); valueHRMax.setText(bundle.HRMax); valueHRMin.setText(bundle.HRMin); diff --git a/src/main/java/es/kauron/estraba/controller/SplashController.java b/src/main/java/es/kauron/estraba/controller/SplashController.java index 814fe0e..4796cc5 100644 --- a/src/main/java/es/kauron/estraba/controller/SplashController.java +++ b/src/main/java/es/kauron/estraba/controller/SplashController.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2016 Jesús "baudlord" Vélez Palacios, Carlos "kauron" Santiago Galindo Jiménez + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. + * + */ + package es.kauron.estraba.controller; import com.jfoenix.controls.JFXButton; @@ -19,8 +44,10 @@ import javafx.scene.layout.AnchorPane; import javafx.stage.FileChooser; import javafx.stage.Stage; +import java.awt.*; import java.io.File; import java.io.IOException; +import java.net.URI; import java.net.URL; import java.util.ResourceBundle; @@ -68,8 +95,7 @@ public class SplashController implements Initializable{ Thread th = new Thread(new Task() { @Override protected DataBundle call() throws Exception { - DataBundle db = DataBundle.loadFrom(file); - return db; + return DataBundle.loadFrom(file); } @Override @@ -79,10 +105,10 @@ public class SplashController implements Initializable{ if (bundle == null) errorLoading(); FXMLLoader loader = new FXMLLoader( App.class.getResource("fxml/Dashboard.fxml"), App.GENERAL_BUNDLE); - Parent parent = null; + Parent parent; try { parent = loader.load(); - loader.getController().postInit(bundle); + loader.getController().load(bundle); ((Stage) root.getScene().getWindow()).setScene(new Scene(parent)); } catch (IOException e) { errorLoading(); @@ -97,8 +123,16 @@ public class SplashController implements Initializable{ @Override public void initialize(URL location, ResourceBundle resources) { - imgLogo.setImage(new Image(App.class.getResourceAsStream("img/strava-transparent.png"))); + imgLogo.setImage(new Image(App.class.getResourceAsStream("img/header.png"))); snackbar = new JFXSnackbar(); + + imgLogo.setOnMouseClicked(e -> { + try { + Desktop.getDesktop().browse(URI.create("https://www.github.com/kauron/estraba")); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + }); } private void errorLoading() { diff --git a/src/main/java/es/kauron/estraba/model/DataBundle.java b/src/main/java/es/kauron/estraba/model/DataBundle.java index 8e5aa6e..2a2a548 100644 --- a/src/main/java/es/kauron/estraba/model/DataBundle.java +++ b/src/main/java/es/kauron/estraba/model/DataBundle.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2016 Jesús "baudlord" Vélez Palacios, Carlos "kauron" Santiago Galindo Jiménez + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. + * + */ + package es.kauron.estraba.model; import es.kauron.estraba.App; @@ -30,17 +55,6 @@ public class DataBundle { public ObservableList pieData; public ObservableList chunks; - public static DataBundle loadFrom(File file) throws Exception { - JAXBElement jaxbElement; - JAXBContext jaxbContext = JAXBContext.newInstance(GpxType.class, TrackPointExtensionT.class); - Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); - jaxbElement = (JAXBElement) unmarshaller.unmarshal(file); - GpxType gpx = (GpxType) jaxbElement.getValue(); - - if (gpx == null) throw new Exception(); - return new DataBundle(new TrackData(new Track(gpx.getTrk().get(0)))); - } - private DataBundle(TrackData track) { HRAvg = track.getAverageHeartrate() + App.GENERAL_BUNDLE.getString("unit.bpm"); @@ -67,8 +81,8 @@ public class DataBundle { } elevation = (int)(track.getTotalAscent() - track.getTotalDescend()) + App.GENERAL_BUNDLE.getString("unit.m"); - ascent = (int)track.getTotalAscent() + App.GENERAL_BUNDLE.getString("unit.m"); - descent = (int)track.getTotalDescend() + App.GENERAL_BUNDLE.getString("unit.m"); + ascent = "+ " + (int) track.getTotalAscent() + App.GENERAL_BUNDLE.getString("unit.m"); + descent = "- " + (int) track.getTotalDescend() + App.GENERAL_BUNDLE.getString("unit.m"); // traverse the chunks chunks = track.getChunks(); @@ -108,4 +122,15 @@ public class DataBundle { if (!pieFound) pieData.add( new PieChart.Data(zone, 1) ); } } + + public static DataBundle loadFrom(File file) throws Exception { + JAXBElement jaxbElement; + JAXBContext jaxbContext = JAXBContext.newInstance(GpxType.class, TrackPointExtensionT.class); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + jaxbElement = (JAXBElement) unmarshaller.unmarshal(file); + GpxType gpx = (GpxType) jaxbElement.getValue(); + + if (gpx == null) throw new Exception(); + return new DataBundle(new TrackData(new Track(gpx.getTrk().get(0)))); + } } diff --git a/src/main/resources/es/kauron/estraba/css/estraba.css b/src/main/resources/es/kauron/estraba/css/estraba.css index e69de29..94c101c 100644 --- a/src/main/resources/es/kauron/estraba/css/estraba.css +++ b/src/main/resources/es/kauron/estraba/css/estraba.css @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2016 Jesús "baudlord" Vélez Palacios, Carlos "kauron" Santiago Galindo Jiménez + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. + * + */ + diff --git a/src/main/resources/es/kauron/estraba/css/palette.css b/src/main/resources/es/kauron/estraba/css/palette.css index 0747de4..7107358 100644 --- a/src/main/resources/es/kauron/estraba/css/palette.css +++ b/src/main/resources/es/kauron/estraba/css/palette.css @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2016 Jesús "baudlord" Vélez Palacios, Carlos "kauron" Santiago Galindo Jiménez + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. + * + */ + /* Palette generated by Material Palette - materialpalette.com/deep-orange/indigo */ .background { -fx-background-color: #FFFFFF; } diff --git a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml index 2d5eac0..9f53176 100644 --- a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml +++ b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml @@ -1,26 +1,41 @@ - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + @@ -49,7 +64,6 @@ - - - - @@ -275,7 +286,6 @@ - @@ -332,7 +342,6 @@ - diff --git a/src/main/resources/es/kauron/estraba/fxml/Splash.fxml b/src/main/resources/es/kauron/estraba/fxml/Splash.fxml index edc5b7d..fded0bd 100644 --- a/src/main/resources/es/kauron/estraba/fxml/Splash.fxml +++ b/src/main/resources/es/kauron/estraba/fxml/Splash.fxml @@ -1,14 +1,40 @@ + + - - - - + + diff --git a/src/main/resources/es/kauron/estraba/img/strava-transparent.png b/src/main/resources/es/kauron/estraba/img/header.png similarity index 100% rename from src/main/resources/es/kauron/estraba/img/strava-transparent.png rename to src/main/resources/es/kauron/estraba/img/header.png diff --git a/src/main/resources/general.properties b/src/main/resources/general.properties index e425662..111715e 100644 --- a/src/main/resources/general.properties +++ b/src/main/resources/general.properties @@ -1,3 +1,28 @@ +# +# Copyright (c) 2016 Jesús "baudlord" Vélez Palacios, Carlos "kauron" Santiago Galindo Jiménez +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. +# +# + app.extension=GPX data files app.title=ESTRABA label.cadence=Cadence diff --git a/src/main/resources/general_ca.properties b/src/main/resources/general_ca.properties index 7201ff8..41e1d05 100644 --- a/src/main/resources/general_ca.properties +++ b/src/main/resources/general_ca.properties @@ -1,3 +1,28 @@ +# +# Copyright (c) 2016 Jesús "baudlord" Vélez Palacios, Carlos "kauron" Santiago Galindo Jiménez +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. +# +# + app.extension=Arxius GPX app.title=ESTRABA label.cadence=Cadencia diff --git a/src/main/resources/general_es.properties b/src/main/resources/general_es.properties index 05c5894..1e10e76 100644 --- a/src/main/resources/general_es.properties +++ b/src/main/resources/general_es.properties @@ -1,3 +1,28 @@ +# +# Copyright (c) 2016 Jesús "baudlord" Vélez Palacios, Carlos "kauron" Santiago Galindo Jiménez +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. +# +# + app.extension=Archivos de datos GPX app.title=ESTRABA label.cadence=Cadencia