diff --git a/.gitignore b/.gitignore index 0f182a0..698c199 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,2 @@ +# compiled classes *.class - -# Package Files # -*.jar -*.war -*.ear diff --git a/lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT-javadoc.jar b/lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT-javadoc.jar new file mode 100644 index 0000000..3600ced Binary files /dev/null and b/lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT-javadoc.jar differ diff --git a/lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT-sources.jar b/lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT-sources.jar new file mode 100644 index 0000000..1f02fe9 Binary files /dev/null and b/lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT-sources.jar differ diff --git a/lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT.jar b/lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT.jar new file mode 100644 index 0000000..24205c8 Binary files /dev/null and b/lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT.jar differ diff --git a/lib/JFXtras/license.txt b/lib/JFXtras/license.txt new file mode 100644 index 0000000..54b9441 --- /dev/null +++ b/lib/JFXtras/license.txt @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2011-2013, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ \ No newline at end of file diff --git a/lib/controlsfx/controlsfx-8.0.2-developer-preview-1-javadoc.jar b/lib/controlsfx/controlsfx-8.0.2-developer-preview-1-javadoc.jar new file mode 100644 index 0000000..7b6e74f Binary files /dev/null and b/lib/controlsfx/controlsfx-8.0.2-developer-preview-1-javadoc.jar differ diff --git a/lib/controlsfx/controlsfx-8.0.2-developer-preview-1-samples.jar b/lib/controlsfx/controlsfx-8.0.2-developer-preview-1-samples.jar new file mode 100644 index 0000000..067bbb8 Binary files /dev/null and b/lib/controlsfx/controlsfx-8.0.2-developer-preview-1-samples.jar differ diff --git a/lib/controlsfx/controlsfx-8.0.2-developer-preview-1.jar b/lib/controlsfx/controlsfx-8.0.2-developer-preview-1.jar new file mode 100644 index 0000000..0b473a6 Binary files /dev/null and b/lib/controlsfx/controlsfx-8.0.2-developer-preview-1.jar differ diff --git a/lib/controlsfx/license.txt b/lib/controlsfx/license.txt new file mode 100644 index 0000000..e41a491 --- /dev/null +++ b/lib/controlsfx/license.txt @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2013, ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ \ No newline at end of file diff --git a/lib/h2/h2-1.3.173.jar b/lib/h2/h2-1.3.173.jar new file mode 100644 index 0000000..7c3cec3 Binary files /dev/null and b/lib/h2/h2-1.3.173.jar differ diff --git a/lib/h2/h2.bat b/lib/h2/h2.bat new file mode 100644 index 0000000..e60bb5c --- /dev/null +++ b/lib/h2/h2.bat @@ -0,0 +1,2 @@ +@java -cp "h2-1.3.173.jar;%H2DRIVERS%;%CLASSPATH%" org.h2.tools.Console %* +@if errorlevel 1 pause \ No newline at end of file diff --git a/lib/h2/h2.sh b/lib/h2/h2.sh new file mode 100644 index 0000000..697878e --- /dev/null +++ b/lib/h2/h2.sh @@ -0,0 +1,3 @@ +#!/bin/sh +dir=$(dirname "$0") +java -cp "$dir/h2-1.3.173.jar:$H2DRIVERS:$CLASSPATH" org.h2.tools.Console "$@" diff --git a/lib/h2/h2w.bat b/lib/h2/h2w.bat new file mode 100644 index 0000000..5ae9b10 --- /dev/null +++ b/lib/h2/h2w.bat @@ -0,0 +1,2 @@ +@start javaw -cp "h2-1.3.173.jar;%H2DRIVERS%;%CLASSPATH%" org.h2.tools.Console %* +@if errorlevel 1 pause \ No newline at end of file diff --git a/lib/h2/license.txt b/lib/h2/license.txt new file mode 100644 index 0000000..9663bdc --- /dev/null +++ b/lib/h2/license.txt @@ -0,0 +1,4 @@ +This software contains unmodified binary redistributions for H2 database engine (http://www.h2database.com/), +which is dual licensed and available under a modified version of the MPL 1.1 (Mozilla Public License) +or under the (unmodified) EPL 1.0 (Eclipse Public License). +An original copy of the license agreement can be found at: http://www.h2database.com/html/license.html \ No newline at end of file diff --git a/lib/jdom-2/LICENSE.txt b/lib/jdom-2/LICENSE.txt new file mode 100644 index 0000000..c18f7bb --- /dev/null +++ b/lib/jdom-2/LICENSE.txt @@ -0,0 +1,54 @@ +/*-- + + Copyright (C) 2000-2012 Jason Hunter & Brett McLaughlin. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the disclaimer that follows + these conditions in the documentation and/or other materials + provided with the distribution. + + 3. The name "JDOM" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact . + + 4. Products derived from this software may not be called "JDOM", nor + may "JDOM" appear in their name, without prior written permission + from the JDOM Project Management . + + In addition, we request (but do not require) that you include in the + end-user documentation provided with the redistribution and/or in the + software itself an acknowledgement equivalent to the following: + "This product includes software developed by the + JDOM Project (http://www.jdom.org/)." + Alternatively, the acknowledgment may be graphical using the logos + available at http://www.jdom.org/images/logos. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + + This software consists of voluntary contributions made by many + individuals on behalf of the JDOM Project and was originally + created by Jason Hunter and + Brett McLaughlin . For more information + on the JDOM Project, please see . + + */ + diff --git a/lib/jdom-2/jdom-2.0.5-javadoc.jar b/lib/jdom-2/jdom-2.0.5-javadoc.jar new file mode 100644 index 0000000..79f0c19 Binary files /dev/null and b/lib/jdom-2/jdom-2.0.5-javadoc.jar differ diff --git a/lib/jdom-2/jdom-2.0.5-sources.jar b/lib/jdom-2/jdom-2.0.5-sources.jar new file mode 100644 index 0000000..7ccbe80 Binary files /dev/null and b/lib/jdom-2/jdom-2.0.5-sources.jar differ diff --git a/lib/jdom-2/jdom-2.0.5.jar b/lib/jdom-2/jdom-2.0.5.jar new file mode 100644 index 0000000..b6996c7 Binary files /dev/null and b/lib/jdom-2/jdom-2.0.5.jar differ diff --git a/src/de/frosch95/geofrogger/application/ProgressEvent.java b/src/de/frosch95/geofrogger/application/ProgressEvent.java new file mode 100644 index 0000000..3166fb8 --- /dev/null +++ b/src/de/frosch95/geofrogger/application/ProgressEvent.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.application; + +/** + * @author Andreas + */ +public class ProgressEvent { + + public enum State {INITIALIZED, STARTED, RUNNING, FINISHED} + + ; + public static final double INDETERMINATE_PROGRESS = -1.0; + + private final String module; + private final State state; + private final String message; + private final Double progress; + + public ProgressEvent(String module, State state, String message) { + this(module, state, message, INDETERMINATE_PROGRESS); + } + + public ProgressEvent(String module, State state, String message, Double progress) { + this.module = module; + this.state = state; + this.message = message; + this.progress = progress; + } + + public String getModule() { + return module; + } + + public State getState() { + return state; + } + + public String getMessage() { + return message; + } + + public Double getProgress() { + return progress; + } +} diff --git a/src/de/frosch95/geofrogger/application/ProgressListener.java b/src/de/frosch95/geofrogger/application/ProgressListener.java new file mode 100644 index 0000000..067ad00 --- /dev/null +++ b/src/de/frosch95/geofrogger/application/ProgressListener.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.application; + +/** + * @author Andreas + */ +public interface ProgressListener { + void progress(ProgressEvent event); +} diff --git a/src/de/frosch95/geofrogger/application/ServiceManager.java b/src/de/frosch95/geofrogger/application/ServiceManager.java new file mode 100644 index 0000000..6926831 --- /dev/null +++ b/src/de/frosch95/geofrogger/application/ServiceManager.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.application; + +import de.frosch95.geofrogger.gpx.GPXReader; +import de.frosch95.geofrogger.gpx.GroundspeakGPXReader; +import de.frosch95.geofrogger.service.CacheService; +import de.frosch95.geofrogger.service.CacheServiceImpl; +import de.frosch95.geofrogger.sql.DatabaseService; +import de.frosch95.geofrogger.sql.DatabaseServiceImpl; + +/** + * @author Andreas + */ +public class ServiceManager { + + private static final ServiceManager INSTANCE = new ServiceManager(); + + private GPXReader gpxReader; + private DatabaseService databaseService; + private CacheService cacheService; + + private ServiceManager() { + // private for singleton pattern + } + + public static ServiceManager getInstance() { + return INSTANCE; + } + + public synchronized GPXReader getGPXReader() { + if (gpxReader == null) { + gpxReader = new GroundspeakGPXReader(); + } + return gpxReader; + } + + public synchronized DatabaseService getDatabaseService() { + if (databaseService == null) { + databaseService = new DatabaseServiceImpl(); + } + return databaseService; + } + + public synchronized CacheService getCacheService() { + if (cacheService == null) { + cacheService = new CacheServiceImpl(); + } + return cacheService; + } + +} diff --git a/src/de/frosch95/geofrogger/application/SessionContext.java b/src/de/frosch95/geofrogger/application/SessionContext.java new file mode 100644 index 0000000..33f97e7 --- /dev/null +++ b/src/de/frosch95/geofrogger/application/SessionContext.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.application; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @author Andreas + */ +public class SessionContext { + + private static final SessionContext INSTANCE = new SessionContext(); + private final Map map = new ConcurrentHashMap<>(); + private final Map> sessionListeners = new HashMap<>(); + + private SessionContext() { + } + + public static SessionContext getInstance() { + return INSTANCE; + } + + public void setData(String key, Object value) { + if (value == null && map.containsKey(key)) { + map.remove(key); + } else if (value != null) { + map.put(key, value); + } + fireSessionEvent(key); + } + + public Object getData(String key) { + if (map.containsKey(key)) { + return map.get(key); + } else { + return null; + } + } + + public void addListener(String key, SessionContextListener sessionListener) { + + List listenerList; + if (sessionListeners.containsKey(key)) { + listenerList = sessionListeners.get(key); + } else { + listenerList = new ArrayList<>(); + sessionListeners.put(key, listenerList); + } + + if (!listenerList.contains(sessionListener)) { + listenerList.add(sessionListener); + } + } + + private void fireSessionEvent(String key) { + if (sessionListeners.containsKey(key)) { + final List listenerList = sessionListeners.get(key); + for (final SessionContextListener listener : listenerList) { + listener.sessionContextChanged(); + } + } + } +} diff --git a/src/de/frosch95/geofrogger/application/SessionContextListener.java b/src/de/frosch95/geofrogger/application/SessionContextListener.java new file mode 100644 index 0000000..551069b --- /dev/null +++ b/src/de/frosch95/geofrogger/application/SessionContextListener.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.application; + +/** + * @author Andreas + */ +public interface SessionContextListener { + void sessionContextChanged(); +} diff --git a/src/de/frosch95/geofrogger/fx/CacheDetailsController.java b/src/de/frosch95/geofrogger/fx/CacheDetailsController.java new file mode 100644 index 0000000..f543377 --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/CacheDetailsController.java @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx; + +import de.frosch95.geofrogger.application.SessionContext; +import de.frosch95.geofrogger.application.SessionContextListener; +import de.frosch95.geofrogger.fx.components.GeocachingIcons; +import de.frosch95.geofrogger.fx.components.IconManager; +import de.frosch95.geofrogger.model.Cache; +import javafx.animation.FadeTransition; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.Node; +import javafx.scene.control.*; +import javafx.scene.image.ImageView; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.BorderPane; +import javafx.scene.web.WebEngine; +import javafx.scene.web.WebView; +import javafx.util.Duration; +import jfxtras.labs.map.render.ImageMapMarker; +import jfxtras.labs.map.render.MapMarkable; + +import java.net.URL; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.ResourceBundle; + +/** + * FXML Controller class + * + * @author Andreas + */ +public class CacheDetailsController implements Initializable, SessionContextListener { + + @FXML + private AnchorPane cacheDetailPane; + @FXML + private Label cacheNameHeader; + @FXML + private Label detailsIconHeader; + @FXML + private TextField cacheName; + @FXML + private Slider difficultySlider; + @FXML + private Slider terrainSlider; + @FXML + private TextField placedByTextfield; + @FXML + private TextField ownerTextfield; + @FXML + private MapPaneWrapper mapPaneWrapper; + @FXML + private DatePicker date; + @FXML + private TextField typeTextfield; + @FXML + private TextField containerTextfield; + @FXML + private BorderPane shortDescriptionPane; + @FXML + private BorderPane longDescriptionPane; + @FXML + private CheckBox shortDescriptionHtml; + @FXML + private CheckBox longDescriptionHtml; + + private ImageView icon; + private FadeTransition ft; + private TextArea shortDescriptionField; + private TextArea longDescriptionField; + private WebView shortDescriptionWebView; + private WebView longDescriptionWebView; + + private final SessionContext sessionContext = SessionContext.getInstance(); + + /** + * Initializes the controller class. + * + * @param url + * @param rb + */ + @Override + public void initialize(URL url, ResourceBundle rb) { + setSessionListener(); + cacheNameHeader.textProperty().bind(cacheName.textProperty()); + detailsIconHeader.getStyleClass().add("cache-list-icon"); + icon = new ImageView(); + detailsIconHeader.setGraphic(icon); + cacheDetailPane.setOpacity(0.3); + shortDescriptionWebView = new WebView(); + longDescriptionWebView = new WebView(); + shortDescriptionField = new TextArea(); + longDescriptionField = new TextArea(); + editableForm(false); + initFading(); + } + + + @Override + public void sessionContextChanged() { + Cache currentCache = (Cache) sessionContext.getData("current-cache"); + if (currentCache != null) { + fillForm(currentCache); + fadeIn(); + } else { + resetForm(); + fadeOut(); + } + } + + private void setSessionListener() { + sessionContext.addListener("current-cache", this); + } + + private void initFading() { + ft = new FadeTransition(Duration.millis(1000), cacheDetailPane); + ft.setCycleCount(1); + ft.setAutoReverse(false); + } + + private void fadeIn() { + ft.setFromValue(0.3); + ft.setToValue(1.0); + ft.playFromStart(); + } + + private void fadeOut() { + ft.setFromValue(1.0); + ft.setToValue(0.3); + ft.playFromStart(); + } + + private void resetForm() { + cacheName.setText(""); + difficultySlider.setValue(1.0); + terrainSlider.setValue(1.0); + detailsIconHeader.setText(""); + placedByTextfield.setText(""); + ownerTextfield.setText(""); + date.setValue(LocalDate.now()); + typeTextfield.setText(""); + containerTextfield.setText(""); + shortDescriptionPane.setCenter(null); + longDescriptionPane.setCenter(null); +// final double lat = currentCache.getMainWayPoint().getLatitude(); +// final double lon = currentCache.getMainWayPoint().getLongitude(); +// mapPaneWrapper.setDisplayPositionByLatLon(lat, lon, 15); +// +// MapMarkable marker = new ImageMapMarker(GeocachingIcons.getMapIcon(currentCache, IconManager.IconSize.BIG), lat, lon); +// mapPaneWrapper.setMapMarkerList(Arrays.asList(marker)); + } + + private void fillForm(Cache currentCache) throws NumberFormatException { + cacheName.setText(currentCache.getName()); + difficultySlider.setValue(Double.parseDouble(currentCache.getDifficulty())); + terrainSlider.setValue(Double.parseDouble(currentCache.getTerrain())); + icon.setImage(GeocachingIcons.getIcon(currentCache)); + placedByTextfield.setText(currentCache.getPlacedBy()); + ownerTextfield.setText(currentCache.getOwner().getName()); + date.setValue(currentCache.getMainWayPoint().getTime().toLocalDate()); + typeTextfield.setText(currentCache.getType()); + containerTextfield.setText(currentCache.getContainer()); + fillShortDescription(currentCache); + fillLongDescription(currentCache); + + fillMap(currentCache); + } + + private void fillMap(Cache currentCache) { + final double lat = currentCache.getMainWayPoint().getLatitude(); + final double lon = currentCache.getMainWayPoint().getLongitude(); + mapPaneWrapper.setDisplayPositionByLatLon(lat, lon, 15); + + MapMarkable marker = new ImageMapMarker(GeocachingIcons.getMapIcon(currentCache, IconManager.IconSize.BIG), lat, lon); + mapPaneWrapper.setMapMarkerList(Arrays.asList(marker)); + } + + private void fillShortDescription(Cache currentCache) { + Node shortDescriptionNode; + if (currentCache.isShortDescriptionHtml()) { + final WebEngine webEngine = shortDescriptionWebView.getEngine(); + webEngine.loadContent(currentCache.getShortDescription()); + shortDescriptionNode = shortDescriptionWebView; + } else { + shortDescriptionField.setText(currentCache.getShortDescription()); + shortDescriptionNode = shortDescriptionField; + } + shortDescriptionPane.setCenter(shortDescriptionNode); + shortDescriptionHtml.setSelected(currentCache.isShortDescriptionHtml()); + } + + private void fillLongDescription(Cache currentCache) { + Node longDescriptionNode; + if (currentCache.isLongDescriptionHtml()) { + final WebEngine webEngine = longDescriptionWebView.getEngine(); + webEngine.loadContent(currentCache.getLongDescription()); + longDescriptionNode = longDescriptionWebView; + } else { + longDescriptionField.setText(currentCache.getLongDescription()); + longDescriptionNode = longDescriptionField; + } + longDescriptionPane.setCenter(longDescriptionNode); + longDescriptionHtml.setSelected(currentCache.isLongDescriptionHtml()); + } + + private void editableForm(boolean editable) { + cacheName.setEditable(editable); + difficultySlider.setDisable(!editable); + terrainSlider.setDisable(!editable); + placedByTextfield.setEditable(editable); + ownerTextfield.setEditable(editable); + date.setDisable(!editable); + typeTextfield.setEditable(editable); + containerTextfield.setEditable(editable); + shortDescriptionHtml.setDisable(!editable); + longDescriptionHtml.setDisable(!editable); + shortDescriptionField.setEditable(editable); + longDescriptionField.setEditable(editable); + } + +} diff --git a/src/de/frosch95/geofrogger/fx/CacheListController.java b/src/de/frosch95/geofrogger/fx/CacheListController.java new file mode 100644 index 0000000..cbabf62 --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/CacheListController.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx; + +import de.frosch95.geofrogger.application.SessionContext; +import de.frosch95.geofrogger.application.SessionContextListener; +import de.frosch95.geofrogger.fx.components.AwesomeIcons; +import de.frosch95.geofrogger.fx.components.CacheListCell; +import de.frosch95.geofrogger.model.Cache; +import javafx.application.Platform; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Label; +import javafx.scene.control.ListView; +import javafx.scene.text.Font; +import javafx.scene.text.FontWeight; +import javafx.util.Callback; + +import java.net.URL; +import java.util.List; +import java.util.ResourceBundle; + +import static de.frosch95.geofrogger.fx.JavaFXUtils.addClasses; + +/** + * FXML Controller class + * + * @author Andreas + */ +public class CacheListController implements Initializable, SessionContextListener { + + private static final String FONT_AWESOME = "FontAwesome"; + private static final String CACHE_LIST_ACTION_ICONS = "cache-list-action-icons"; + private final SessionContext sessionContext = SessionContext.getInstance(); + + @FXML + private ListView cacheListView; + + @FXML + private Label cacheNumber; + + @FXML + private Label filterIcon; + + @FXML + private Label sortIcon; + + /** + * Initializes the controller class. + * + * @param url + * @param rb + */ + @Override + public void initialize(URL url, ResourceBundle rb) { + setSessionListener(); + setCellFactory(); + + cacheListView.getSelectionModel().selectedItemProperty().addListener( + (ChangeListener) (ObservableValue ov, Cache oldValue, Cache newValue) -> + { + sessionContext.setData("current-cache", newValue); + } + ); + + filterIcon.setFont(Font.font(FONT_AWESOME, FontWeight.NORMAL, 16)); + filterIcon.setText(AwesomeIcons.ICON_FILTER.toString()); + addClasses(filterIcon, CACHE_LIST_ACTION_ICONS); + + sortIcon.setFont(Font.font(FONT_AWESOME, FontWeight.NORMAL, 16)); + sortIcon.setText(AwesomeIcons.ICON_SORT.toString()); + addClasses(sortIcon, CACHE_LIST_ACTION_ICONS); + } + + @Override + public void sessionContextChanged() { + List caches = (List) sessionContext.getData("cache-list"); + Platform.runLater(() -> { + cacheNumber.setText("(" + caches.size() + ")"); + cacheListView.getItems().setAll(caches); + }); + } + + private void setCellFactory() { + cacheListView.setCellFactory( + (Callback, CacheListCell>) + (ListView p) -> new CacheListCell()); + } + + private void setSessionListener() { + sessionContext.addListener("cache-list", this); + } + +} diff --git a/src/de/frosch95/geofrogger/fx/GeoFroggerFXMain.java b/src/de/frosch95/geofrogger/fx/GeoFroggerFXMain.java new file mode 100644 index 0000000..6802072 --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/GeoFroggerFXMain.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx; + +import de.frosch95.geofrogger.application.ServiceManager; +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.text.Font; +import javafx.stage.Stage; + +import java.sql.SQLException; +import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * @author Andreas + */ +public class GeoFroggerFXMain extends Application { + + @Override + public void start(Stage stage) throws Exception { + Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/fontawesome-webfont.ttf").toExternalForm(), 12); + Parent root = FXMLLoader.load(getClass().getResource("geofrogger.fxml"), ResourceBundle.getBundle("de.frosch95.geofrogger.fx.geofrogger")); + Scene scene = new Scene(root); + stage.setScene(scene); + stage.show(); + } + + @Override + public void stop() throws Exception { + try { + ServiceManager.getInstance().getDatabaseService().getConnection().close(); + } catch (SQLException ex) { + Logger.getLogger(GeofroggerController.class.getName()).log(Level.SEVERE, null, ex); + } + super.stop(); + } + + + /** + * The main() method is ignored in correctly deployed JavaFX application. + * main() serves only as fallback in case the application can not be + * launched through deployment artifacts, e.g., in IDEs with limited FX + * support. NetBeans ignores main(). + * + * @param args the command line arguments + */ + public static void main(String[] args) { + launch(args); + } +} diff --git a/src/de/frosch95/geofrogger/fx/GeofroggerController.java b/src/de/frosch95/geofrogger/fx/GeofroggerController.java new file mode 100644 index 0000000..6d4f5ce --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/GeofroggerController.java @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx; + +import de.frosch95.geofrogger.application.ProgressEvent; +import de.frosch95.geofrogger.application.ServiceManager; +import de.frosch95.geofrogger.application.SessionContext; +import de.frosch95.geofrogger.gpx.GPXReader; +import de.frosch95.geofrogger.model.Cache; +import de.frosch95.geofrogger.service.CacheService; +import javafx.application.Platform; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.concurrent.Service; +import javafx.concurrent.Task; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Label; +import javafx.scene.control.ProgressBar; +import javafx.scene.control.ProgressIndicator; +import javafx.scene.control.TextArea; +import javafx.stage.FileChooser; +import org.controlsfx.dialog.Dialog; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.sql.SQLException; +import java.util.List; +import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * FXML Controller class + * + * @author Andreas + */ +public class GeofroggerController implements Initializable { + + private static final String LICENSE = "/*\n" + + " * Copyright (c) 2013, Andreas Billmann \n" + + " * All rights reserved.\n" + + " *\n" + + " * Redistribution and use in source and binary forms, with or without\n" + + " * modification, are permitted provided that the following conditions are met:\n" + + " *\n" + + " * * Redistributions of source code must retain the above copyright notice, this\n" + + " * list of conditions and the following disclaimer.\n" + + " * * Redistributions in binary form must reproduce the above copyright notice,\n" + + " * this list of conditions and the following disclaimer in the documentation\n" + + " * and/or other materials provided with the distribution.\n" + + " *\n" + + " * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n" + + " * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n" + + " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n" + + " * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n" + + " * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n" + + " * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n" + + " * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n" + + " * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n" + + " * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n" + + " * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n" + + " * POSSIBILITY OF SUCH DAMAGE.\n" + + " */"; + + private static final String MASTHEAD_TEXT = "GeoFroggerFX by Andreas Billmann "; + private static final String ABOUT_TEXT = "Used libs:\n" + + "\t- JFXtras 8.0 r1\n" + + "\t- ControlsFX 8.0.2 developer preview 1\n" + + "\t- jdom 2.x\n" + + "\t- H2 1.3.173\n" + + "\t- Font Awesome by Dave Gandy\n" + + "\t- Icons by http://iconmonstr.com/\n"; + + private final SessionContext sessionContext = SessionContext.getInstance(); + private final LoadCachesFromFileService loadService = new LoadCachesFromFileService(); + private final LoadCachesFromDatabaseService loadFromDBService = new LoadCachesFromDatabaseService(); + + private final GPXReader gpxReader = ServiceManager.getInstance().getGPXReader(); + private final CacheService cacheService = ServiceManager.getInstance().getCacheService(); + + @FXML + private Label leftStatus; + + @FXML + private ProgressBar progress; + + /** + * Initializes the controller class. + * + * @param url + * @param rb + */ + @Override + public void initialize(URL url, ResourceBundle rb) { + gpxReader.addListener((ProgressEvent event) -> { + updateStatus(event.getMessage(), event.getProgress()); + }); + + cacheService.addListener((ProgressEvent event) -> { + updateStatus(event.getMessage(), event.getProgress()); + }); + + loadFromDBService.start(); + } + + @FXML + public void importGpx(ActionEvent actionEvent) { + final FileChooser fileChooser = new FileChooser(); + + //Set extension filter + final FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("GPX files (*.gpx)", "*.gpx"); + fileChooser.getExtensionFilters().add(extFilter); + + //Show open file dialog + final File file = fileChooser.showOpenDialog(null); + loadService.setFile(file); + loadService.restart(); + } + + @FXML + public void showAboutDialog(ActionEvent actionEvent) { + Dialog dialog = new Dialog(null, "About"); + dialog.setMasthead(MASTHEAD_TEXT); + dialog.setContent(ABOUT_TEXT); + dialog.setExpandableContent(new TextArea(LICENSE)); + dialog.show(); + } + + @FXML + public void exit(ActionEvent actionEvent) { + try { + ServiceManager.getInstance().getDatabaseService().getConnection().close(); + } catch (SQLException ex) { + Logger.getLogger(GeofroggerController.class.getName()).log(Level.SEVERE, null, ex); + } + Platform.exit(); + } + + private void updateStatus(String text, double progressValue) { + Platform.runLater(() -> { + leftStatus.setText(text); + progress.setProgress(progressValue); + }); + } + + private class LoadCachesFromDatabaseService extends Service { + + @Override + protected Task createTask() { + return new Task() { + @Override + protected Void call() throws Exception { + updateStatus("Load caches from database.", ProgressIndicator.INDETERMINATE_PROGRESS); + sessionContext.setData("cache-list", cacheService.getAllCaches()); + updateStatus("All caches loaded.", 0); + return null; + } + }; + } + + } + + private class LoadCachesFromFileService extends Service { + + private final ObjectProperty file = new SimpleObjectProperty(); + + public final void setFile(File value) { + file.set(value); + } + + public final File getFile() { + return file.get(); + } + + public final ObjectProperty fileProperty() { + return file; + } + + @Override + protected Task createTask() { + return new Task() { + @Override + protected Void call() throws Exception { + try { + final List cacheList = gpxReader.load(file.get().getAbsolutePath()); + if (cacheList != null && !cacheList.isEmpty()) { + + updateStatus("Store caches in database", ProgressIndicator.INDETERMINATE_PROGRESS); + cacheService.storeCaches(cacheList); + updateStatus("All caches are stored in database", 0); + + updateStatus("Load caches from database.", ProgressIndicator.INDETERMINATE_PROGRESS); + sessionContext.setData("cache-list", cacheService.getAllCaches()); + updateStatus("All caches loaded.", 0); + } + } catch (IOException ex) { + Logger.getLogger(GeofroggerController.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } + }; + } + + } + +} diff --git a/src/de/frosch95/geofrogger/fx/JavaFXUtils.java b/src/de/frosch95/geofrogger/fx/JavaFXUtils.java new file mode 100644 index 0000000..25901cf --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/JavaFXUtils.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx; + +import javafx.scene.Node; + +import java.util.List; + +/** + * @author Andreas Billmann + */ +public class JavaFXUtils { + + public static void addClasses(Node node, String... classes) { + for (String styleClass : classes) { + List nodeClasses = node.getStyleClass(); + if (!nodeClasses.contains(styleClass)) { + nodeClasses.add(styleClass); + } + } + } + + public static void removeClasses(Node node, String... classes) { + for (String styleClass : classes) { + List nodeClasses = node.getStyleClass(); + if (nodeClasses.contains(styleClass)) { + nodeClasses.remove(styleClass); + } + } + } +} diff --git a/src/de/frosch95/geofrogger/fx/MapPaneWrapper.java b/src/de/frosch95/geofrogger/fx/MapPaneWrapper.java new file mode 100644 index 0000000..668b73e --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/MapPaneWrapper.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx; + +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.scene.layout.Pane; +import jfxtras.labs.map.MapPane; +import jfxtras.labs.map.render.MapMarkable; +import jfxtras.labs.map.tile.OsmTileSourceFactory; + +import java.util.List; + +/** + * @author Andreas Billmann + */ +public class MapPaneWrapper extends Pane { + public static final String MAP_PANE_WRAPPER_CLASS = "map-pane-wrapper"; + + private final MapPane mapPane; + + public MapPaneWrapper() { + mapPane = new MapPane(new OsmTileSourceFactory().create()); + + JavaFXUtils.addClasses(this, MAP_PANE_WRAPPER_CLASS); + + setSizeListener(); + this.getChildren().add(mapPane); + setDisplayPositionByLatLon(32.81729, -117.215905, 9); + mapPane.setMapMarkerVisible(true); + } + + public final void setDisplayPositionByLatLon(double lat, double lon, int zoom) { + mapPane.setDisplayPositionByLatLon(lat, lon, zoom); + } + + public final void setMapMarkerList(List mapMarkerList) { + mapPane.setMapMarkerList(mapMarkerList); + } + + private void setSizeListener() { + this.widthProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, Object oldValue, Object newValue) { + Double width = (Double) newValue; + mapPane.setMapWidth(width); + } + }); + + this.heightProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, Object oldValue, Object newValue) { + Double height = (Double) newValue; + mapPane.setMapHeight(height); + } + }); + } +} diff --git a/src/de/frosch95/geofrogger/fx/cache_details.fxml b/src/de/frosch95/geofrogger/fx/cache_details.fxml new file mode 100644 index 0000000..06131bc --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/cache_details.fxml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/de/frosch95/geofrogger/fx/cache_list.fxml b/src/de/frosch95/geofrogger/fx/cache_list.fxml new file mode 100644 index 0000000..24124ad --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/cache_list.fxml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/de/frosch95/geofrogger/fx/components/AwesomeGeocachingIcons.java b/src/de/frosch95/geofrogger/fx/components/AwesomeGeocachingIcons.java new file mode 100644 index 0000000..83051eb --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/components/AwesomeGeocachingIcons.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx.components; + +import de.frosch95.geofrogger.model.Cache; + +/** + * @author Andreas + */ +public class AwesomeGeocachingIcons { + + public static AwesomeIcons getIcon(Cache cache) { + + AwesomeIcons icon = AwesomeIcons.ICON_TAG; + + switch (cache.getType()) { + case "Multi-cache": + icon = AwesomeIcons.ICON_TAGS; + break; + + case "Traditional Cache": + icon = AwesomeIcons.ICON_TAG; + break; + + case "Unknown Cache": + icon = AwesomeIcons.ICON_QUESTION_SIGN; + break; + + case "Earthcache": + icon = AwesomeIcons.ICON_GLOBE; + break; + + case "Letterbox Hybrid": + icon = AwesomeIcons.ICON_INBOX; + break; + + case "Event Cache": + icon = AwesomeIcons.ICON_CALENDAR; + break; + + case "Whereigo Cache": + icon = AwesomeIcons.ICON_PLAY_SIGN; + break; + + case "Webcam Cache": + icon = AwesomeIcons.ICON_CAMERA; + break; + + case "Virtual Cache": + icon = AwesomeIcons.ICON_LAPTOP; + break; + + + default: + System.out.println(cache.getType()); + } + + return icon; + } + +} diff --git a/src/de/frosch95/geofrogger/fx/components/AwesomeIcons.java b/src/de/frosch95/geofrogger/fx/components/AwesomeIcons.java new file mode 100644 index 0000000..b66c30a --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/components/AwesomeIcons.java @@ -0,0 +1,299 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx.components; + +/** + * @author Andreas + */ +public enum AwesomeIcons { + + ICON_GLASS('\uf000'), + ICON_MUSIC('\uf001'), + ICON_SEARCH('\uf002'), + ICON_ENVELOPE('\uf003'), + ICON_HEART('\uf004'), + ICON_STAR('\uf005'), + ICON_STAR_EMPTY('\uf006'), + ICON_USER('\uf007'), + ICON_FILM('\uf008'), + ICON_TH_LARGE('\uf009'), + ICON_TH('\uf00a'), + ICON_TH_LIST('\uf00b'), + ICON_OK('\uf00c'), + ICON_REMOVE('\uf00d'), + ICON_ZOOM_IN('\uf00e'), + ICON_ZOOM_OUT('\uf010'), + ICON_OFF('\uf011'), + ICON_SIGNAL('\uf012'), + ICON_COG('\uf013'), + ICON_TRASH('\uf014'), + ICON_HOME('\uf015'), + ICON_FILE('\uf016'), + ICON_TIME('\uf017'), + ICON_ROAD('\uf018'), + ICON_DOWNLOAD_ALT('\uf019'), + ICON_DOWNLOAD('\uf01a'), + ICON_UPLOAD('\uf01b'), + ICON_INBOX('\uf01c'), + ICON_PLAY_CIRCLE('\uf01d'), + ICON_PLAY_SIGN('\uf144'), + ICON_REPEAT('\uf01e'), + ICON_REFRESH('\uf021'), + ICON_LIST_ALT('\uf022'), + ICON_LOCK('\uf023'), + ICON_FLAG('\uf024'), + ICON_HEADPHONES('\uf025'), + ICON_VOLUME_OFF('\uf026'), + ICON_VOLUME_DOWN('\uf027'), + ICON_VOLUME_UP('\uf028'), + ICON_QRCODE('\uf029'), + ICON_BARCODE('\uf02a'), + ICON_TAG('\uf02b'), + ICON_TAGS('\uf02c'), + ICON_BOOK('\uf02d'), + ICON_BOOKMARK('\uf02e'), + ICON_PRINT('\uf02f'), + ICON_CAMERA('\uf030'), + ICON_FONT('\uf031'), + ICON_BOLD('\uf032'), + ICON_ITALIC('\uf033'), + ICON_TEXT_HEIGHT('\uf034'), + ICON_TEXT_WIDTH('\uf035'), + ICON_ALIGN_LEFT('\uf036'), + ICON_ALIGN_CENTER('\uf037'), + ICON_ALIGN_RIGHT('\uf038'), + ICON_ALIGN_JUSTIFY('\uf039'), + ICON_LIST('\uf03a'), + ICON_INDENT_LEFT('\uf03b'), + ICON_INDENT_RIGHT('\uf03c'), + ICON_FACETIME_VIDEO('\uf03d'), + ICON_PICTURE('\uf03e'), + ICON_PENCIL('\uf040'), + ICON_MAP_MARKER('\uf041'), + ICON_ADJUST('\uf042'), + ICON_TINT('\uf043'), + ICON_EDIT('\uf044'), + ICON_SHARE('\uf045'), + ICON_CHECK('\uf046'), + ICON_MOVE('\uf047'), + ICON_STEP_BACKWARD('\uf048'), + ICON_FAST_BACKWARD('\uf049'), + ICON_BACKWARD('\uf04a'), + ICON_PLAY('\uf04b'), + ICON_PAUSE('\uf04c'), + ICON_STOP('\uf04d'), + ICON_FORWARD('\uf04e'), + ICON_FAST_FORWARD('\uf050'), + ICON_STEP_FORWARD('\uf051'), + ICON_EJECT('\uf052'), + ICON_CHEVRON_LEFT('\uf053'), + ICON_CHEVRON_RIGHT('\uf054'), + ICON_PLUS_SIGN('\uf055'), + ICON_MINUS_SIGN('\uf056'), + ICON_REMOVE_SIGN('\uf057'), + ICON_OK_SIGN('\uf058'), + ICON_QUESTION_SIGN('\uf059'), + ICON_QUESTION('\uf128'), + ICON_INFO_SIGN('\uf05a'), + ICON_SCREENSHOT('\uf05b'), + ICON_REMOVE_CIRCLE('\uf05c'), + ICON_OK_CIRCLE('\uf05d'), + ICON_BAN_CIRCLE('\uf05e'), + ICON_ARROW_LEFT('\uf060'), + ICON_ARROW_RIGHT('\uf061'), + ICON_ARROW_UP('\uf062'), + ICON_ARROW_DOWN('\uf063'), + ICON_SHARE_ALT('\uf064'), + ICON_RESIZE_FULL('\uf065'), + ICON_RESIZE_SMALL('\uf066'), + ICON_PLUS('\uf067'), + ICON_MINUS('\uf068'), + ICON_ASTERISK('\uf069'), + ICON_EXCLAMATION_SIGN('\uf06a'), + ICON_GIFT('\uf06b'), + ICON_LEAF('\uf06c'), + ICON_FIRE('\uf06d'), + ICON_EYE_OPEN('\uf06e'), + ICON_EYE_CLOSE('\uf070'), + ICON_WARNING_SIGN('\uf071'), + ICON_PLANE('\uf072'), + ICON_CALENDAR('\uf073'), + ICON_RANDOM('\uf074'), + ICON_COMMENT('\uf075'), + ICON_MAGNET('\uf076'), + ICON_CHEVRON_UP('\uf077'), + ICON_CHEVRON_DOWN('\uf078'), + ICON_RETWEET('\uf079'), + ICON_SHOPPING_CART('\uf07a'), + ICON_FOLDER_CLOSE('\uf07b'), + ICON_FOLDER_OPEN('\uf07c'), + ICON_RESIZE_VERTICAL('\uf07d'), + ICON_RESIZE_HORIZONTAL('\uf07e'), + ICON_BAR_CHART('\uf080'), + ICON_TWITTER_SIGN('\uf081'), + ICON_FACEBOOK_SIGN('\uf082'), + ICON_CAMERA_RETRO('\uf083'), + ICON_KEY('\uf084'), + ICON_COGS('\uf085'), + ICON_COMMENTS('\uf086'), + ICON_THUMBS_UP('\uf087'), + ICON_THUMBS_DOWN('\uf088'), + ICON_STAR_HALF('\uf089'), + ICON_HEART_EMPTY('\uf08a'), + ICON_SIGNOUT('\uf08b'), + ICON_LINKEDIN_SIGN('\uf08c'), + ICON_PUSHPIN('\uf08d'), + ICON_EXTERNAL_LINK('\uf08e'), + ICON_SIGNIN('\uf090'), + ICON_TROPHY('\uf091'), + ICON_GITHUB_SIGN('\uf092'), + ICON_UPLOAD_ALT('\uf093'), + ICON_LEMON('\uf094'), + ICON_PHONE('\uf095'), + ICON_CHECK_EMPTY('\uf096'), + ICON_BOOKMARK_EMPTY('\uf097'), + ICON_PHONE_SIGN('\uf098'), + ICON_TWITTER('\uf099'), + ICON_FACEBOOK('\uf09a'), + ICON_GITHUB('\uf09b'), + ICON_UNLOCK('\uf09c'), + ICON_CREDIT_CARD('\uf09d'), + ICON_RSS('\uf09e'), + ICON_HDD('\uf0a0'), + ICON_BULLHORN('\uf0a1'), + ICON_BELL('\uf0a2'), + ICON_CERTIFICATE('\uf0a3'), + ICON_HAND_RIGHT('\uf0a4'), + ICON_HAND_LEFT('\uf0a5'), + ICON_HAND_UP('\uf0a6'), + ICON_HAND_DOWN('\uf0a7'), + ICON_CIRCLE_ARROW_LEFT('\uf0a8'), + ICON_CIRCLE_ARROW_RIGHT('\uf0a9'), + ICON_CIRCLE_ARROW_UP('\uf0aa'), + ICON_CIRCLE_ARROW_DOWN('\uf0ab'), + ICON_GLOBE('\uf0ac'), + ICON_WRENCH('\uf0ad'), + ICON_TASKS('\uf0ae'), + ICON_FILTER('\uf0b0'), + ICON_BRIEFCASE('\uf0b1'), + ICON_FULLSCREEN('\uf0b2'), + ICON_GROUP('\uf0c0'), + ICON_LINK('\uf0c1'), + ICON_CLOUD('\uf0c2'), + ICON_BEAKER('\uf0c3'), + ICON_CUT('\uf0c4'), + ICON_COPY('\uf0c5'), + ICON_PAPER_CLIP('\uf0c6'), + ICON_SAVE('\uf0c7'), + ICON_SIGN_BLANK('\uf0c8'), + ICON_REORDER('\uf0c9'), + ICON_LIST_UL('\uf0ca'), + ICON_LIST_OL('\uf0cb'), + ICON_STRIKETHROUGH('\uf0cc'), + ICON_UNDERLINE('\uf0cd'), + ICON_TABLE('\uf0ce'), + ICON_MAGIC('\uf0d0'), + ICON_TRUCK('\uf0d1'), + ICON_PINTEREST('\uf0d2'), + ICON_PINTEREST_SIGN('\uf0d3'), + ICON_GOOGLE_PLUS_SIGN('\uf0d4'), + ICON_GOOGLE_PLUS('\uf0d5'), + ICON_MONEY('\uf0d6'), + ICON_CARET_DOWN('\uf0d7'), + ICON_CARET_UP('\uf0d8'), + ICON_CARET_LEFT('\uf0d9'), + ICON_CARET_RIGHT('\uf0da'), + ICON_COLUMNS('\uf0db'), + ICON_SORT('\uf0dc'), + ICON_SORT_DOWN('\uf0dd'), + ICON_SORT_UP('\uf0de'), + ICON_ENVELOPE_ALT('\uf0e0'), + ICON_LINKEDIN('\uf0e1'), + ICON_UNDO('\uf0e2'), + ICON_LEGAL('\uf0e3'), + ICON_DASHBOARD('\uf0e4'), + ICON_COMMENT_ALT('\uf0e5'), + ICON_COMMENTS_ALT('\uf0e6'), + ICON_BOLT('\uf0e7'), + ICON_SITEMAP('\uf0e8'), + ICON_UMBRELLA('\uf0e9'), + ICON_PASTE('\uf0ea'), + ICON_LIGHTBULB('\uf0eb'), + ICON_EXCHANGE('\uf0ec'), + ICON_CLOUD_DOWNLOAD('\uf0ed'), + ICON_CLOUD_UPLOAD('\uf0ee'), + ICON_USER_MD('\uf0f0'), + ICON_STETHOSCOPE('\uf0f1'), + ICON_SUITCASE('\uf0f2'), + ICON_BELL_ALT('\uf0f3'), + ICON_COFFEE('\uf0f4'), + ICON_FOOD('\uf0f5'), + ICON_FILE_ALT('\uf0f6'), + ICON_BUILDING('\uf0f7'), + ICON_HOSPITAL('\uf0f8'), + ICON_AMBULANCE('\uf0f9'), + ICON_MEDKIT('\uf0fa'), + ICON_FIGHTER_JET('\uf0fb'), + ICON_BEER('\uf0fc'), + ICON_H_SIGN('\uf0fd'), + ICON_PLUS_SIGN_ALT('\uf0fe'), + ICON_DOUBLE_ANGLE_LEFT('\uf100'), + ICON_DOUBLE_ANGLE_RIGHT('\uf101'), + ICON_DOUBLE_ANGLE_UP('\uf102'), + ICON_DOUBLE_ANGLE_DOWN('\uf103'), + ICON_ANGLE_LEFT('\uf104'), + ICON_ANGLE_RIGHT('\uf105'), + ICON_ANGLE_UP('\uf106'), + ICON_ANGLE_DOWN('\uf107'), + ICON_DESKTOP('\uf108'), + ICON_LAPTOP('\uf109'), + ICON_TABLET('\uf10a'), + ICON_MOBILE_PHONE('\uf10b'), + ICON_CIRCLE_BLANK('\uf10c'), + ICON_QUOTE_LEFT('\uf10d'), + ICON_QUOTE_RIGHT('\uf10e'), + ICON_SPINNER('\uf110'), + ICON_CIRCLE('\uf111'), + ICON_REPLY('\uf112'), + ICON_GITHUB_ALT('\uf113'), + ICON_FOLDER_CLOSE_ALT('\uf114'), + ICON_FOLDER_OPEN_ALT('\uf115'); + + private final Character character; + + private AwesomeIcons(Character character) { + this.character = character; + } + + public Character character() { + return character; + } + + @Override + public String toString() { + return character.toString(); + } +} \ No newline at end of file diff --git a/src/de/frosch95/geofrogger/fx/components/CacheListCell.java b/src/de/frosch95/geofrogger/fx/components/CacheListCell.java new file mode 100644 index 0000000..795c72e --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/components/CacheListCell.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx.components; + +import de.frosch95.geofrogger.model.Cache; +import de.frosch95.geofrogger.model.CacheUtils; +import javafx.geometry.Insets; +import javafx.scene.control.Label; +import javafx.scene.control.ListCell; +import javafx.scene.image.ImageView; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; + +import static de.frosch95.geofrogger.fx.JavaFXUtils.addClasses; +import static de.frosch95.geofrogger.fx.JavaFXUtils.removeClasses; + +/** + * @author Andreas + */ +public class CacheListCell extends ListCell { + private static final String CACHE_LIST_FOUND_CLASS = "cache-list-found"; + private static final String CACHE_LIST_NOT_FOUND_CLASS = "cache-list-not-found"; + private static final String CACHE_LIST_NAME_CLASS = "cache-list-name"; + private static final String CACHE_LIST_DT_CLASS = "cache-list-dt"; + private static final String CACHE_LIST_ICON_CLASS = "cache-list-icon"; + + private final GridPane grid = new GridPane(); + private final ImageView icon = new ImageView(); + private final Label name = new Label(); + private final Label dt = new Label(); + private final ImageView foundIcon = new ImageView(); + private final ImageView favoriteIcon = new ImageView(); + + public CacheListCell() { + configureGrid(); + configureIcon(); + configureName(); + configureDifficultyTerrain(); + addControlsToGrid(); + } + + @Override + public void updateItem(Cache cache, boolean empty) { + super.updateItem(cache, empty); + if (empty) { + clearContent(); + } else { + addContent(cache); + } + } + + private void configureGrid() { + grid.setHgap(10); + grid.setVgap(4); + grid.setPadding(new Insets(0, 10, 0, 10)); + + ColumnConstraints column1 = new ColumnConstraints(32); + ColumnConstraints column2 = new ColumnConstraints(100, 100, Double.MAX_VALUE); + column2.setHgrow(Priority.ALWAYS); + ColumnConstraints column3 = new ColumnConstraints(32); + grid.getColumnConstraints().addAll(column1, column2, column3); + } + + private void configureIcon() { + icon.getStyleClass().add(CACHE_LIST_ICON_CLASS); + } + + private void configureName() { + name.getStyleClass().add(CACHE_LIST_NAME_CLASS); + } + + private void configureDifficultyTerrain() { + dt.getStyleClass().add(CACHE_LIST_DT_CLASS); + } + + private void addControlsToGrid() { + grid.add(icon, 0, 0, 1, 2); + grid.add(name, 1, 0); + grid.add(dt, 1, 1); + grid.add(foundIcon, 2, 0); + grid.add(favoriteIcon, 2, 1); + } + + private void clearContent() { + setText(null); + setGraphic(null); + } + + private void addContent(Cache cache) { + setText(null); + icon.setImage(GeocachingIcons.getIcon(cache)); + name.setText(cache.getName()); + dt.setText("D: " + cache.getDifficulty() + " / T:" + cache.getTerrain()); + + if (CacheUtils.hasUserFoundCache(cache, new Long(3906456))) { + foundIcon.setImage(IconManager.getIcon("/icons/iconmonstr-check-mark-11-icon.png", IconManager.IconSize.SMALL)); + } else { + foundIcon.setImage(null); + } + + setStyleClassDependingOnFoundState(cache); + setGraphic(grid); + } + + private void setStyleClassDependingOnFoundState(Cache cache) { + if (CacheUtils.hasUserFoundCache(cache, new Long(3906456))) { + addClasses(this, CACHE_LIST_FOUND_CLASS); + removeClasses(this, CACHE_LIST_NOT_FOUND_CLASS); + } else { + addClasses(this, CACHE_LIST_NOT_FOUND_CLASS); + removeClasses(this, CACHE_LIST_FOUND_CLASS); + } + } +} diff --git a/src/de/frosch95/geofrogger/fx/components/GeocachingIcons.java b/src/de/frosch95/geofrogger/fx/components/GeocachingIcons.java new file mode 100644 index 0000000..d209263 --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/components/GeocachingIcons.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx.components; + +import de.frosch95.geofrogger.model.Cache; +import javafx.scene.image.Image; + +/** + * @author Andreas + */ +public class GeocachingIcons { + + public static Image getIcon(Cache cache) { + return getIcon(cache, IconManager.IconSize.MIDDLE); + } + + public static Image getIcon(Cache cache, IconManager.IconSize size) { + String iconName = "/icons/iconmonstr-map-5-icon.png"; + + switch (cache.getType()) { + case "Multi-cache": + iconName = "/icons/iconmonstr-map-6-icon.png"; + break; + + case "Traditional Cache": + iconName = "/icons/iconmonstr-map-5-icon.png"; + break; + + case "Unknown Cache": + iconName = "/icons/iconmonstr-help-3-icon.png"; + break; + + case "Earthcache": + iconName = "/icons/iconmonstr-globe-4-icon.png"; + break; + + case "Letterbox Hybrid": + iconName = "/icons/iconmonstr-email-4-icon.png"; + break; + + case "Event Cache": + iconName = "/icons/iconmonstr-calendar-4-icon.png"; + break; + + case "Wherigo Cache": + iconName = "/icons/iconmonstr-navigation-6-icon.png"; + break; + + case "Webcam Cache": + iconName = "/icons/iconmonstr-webcam-3-icon.png"; + break; + + case "Virtual Cache": + iconName = "/icons/iconmonstr-network-2-icon.png"; + break; + + default: + System.out.println(cache.getType()); + } + + + return IconManager.getIcon(iconName, size); + } + + public static Image getMapIcon(Cache cache) { + return getMapIcon(cache, IconManager.IconSize.MIDDLE); + } + + public static Image getMapIcon(Cache cache, IconManager.IconSize size) { + String iconName = "/icons/iconmonstr-location-icon.png"; + return IconManager.getIcon(iconName, size); + } + +} diff --git a/src/de/frosch95/geofrogger/fx/components/GeocachingMapMarker.java b/src/de/frosch95/geofrogger/fx/components/GeocachingMapMarker.java new file mode 100644 index 0000000..61d09aa --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/components/GeocachingMapMarker.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx.components; + +import de.frosch95.geofrogger.model.Cache; +import javafx.collections.ObservableList; +import javafx.scene.Group; +import javafx.scene.Node; +import javafx.scene.control.Label; +import javafx.scene.text.Font; +import javafx.scene.text.FontWeight; +import jfxtras.labs.map.MapControlable; +import jfxtras.labs.map.render.MapMarkable; + +import java.awt.*; +import java.util.Collections; +import java.util.List; + + +/** + * @author Andreas + */ +public class GeocachingMapMarker implements MapMarkable { + + private double lat; + private double lon; + private Label iconLabel; + private Cache cache; + + public GeocachingMapMarker(Cache cache, double lat, double lon) { + this.lat = lat; + this.lon = lon; + this.cache = cache; + + this.iconLabel = new Label(); + iconLabel.setFont(Font.font("FontAwesome", FontWeight.BOLD, 24)); + iconLabel.setText(AwesomeGeocachingIcons.getIcon(cache).toString()); + } + + @Override + public double getLat() { + return lat; + } + + @Override + public double getLon() { + return lon; + } + + @Override + public void render(MapControlable mapController) { + Point postion = mapController.getMapPoint(lat, lon, true); + if (postion != null) { + Group tilesGroup = mapController.getTilesGroup(); + ObservableList children = tilesGroup.getChildren(); + List nodes = createChildren(postion); + for (Node node : nodes) { + if (!children.contains(node)) { + children.add(node); + } + } + } + } + + List createChildren(Point position) { + iconLabel.setTranslateX(position.x); + iconLabel.setTranslateY(position.y); + return Collections.singletonList(iconLabel); + } + + @Override + public Node getNode() { + return iconLabel; + } +} + + + diff --git a/src/de/frosch95/geofrogger/fx/components/IconManager.java b/src/de/frosch95/geofrogger/fx/components/IconManager.java new file mode 100644 index 0000000..b383d34 --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/components/IconManager.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.fx.components; + +import javafx.scene.image.Image; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Andreas + */ +public class IconManager { + + private static final Map container = new HashMap<>(); + + public enum IconSize { + + SMALL(16.0), + MIDDLE(32.0), + BIG(64.0); + + private final double size; + + private IconSize(double size) { + this.size = size; + } + + public double getValue() { + return size; + } + } + + ; + + public static Image getIcon(String iconName, IconSize size) { + final Image image; + String key = iconName + "_" + size; + if (container.containsKey(key)) { + image = container.get(key); + } else { + image = new Image(iconName, size.getValue(), size.getValue(), true, true); + container.put(key, image); + } + return image; + } +} diff --git a/src/de/frosch95/geofrogger/fx/geofrogger.css b/src/de/frosch95/geofrogger/fx/geofrogger.css new file mode 100644 index 0000000..1cdcc89 --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/geofrogger.css @@ -0,0 +1,65 @@ +/* + * Empty Stylesheet file. + */ + +.mainFxmlClass { + +} + +.menu-bar { + -fx-background-color: #aeb5ba, linear-gradient(to bottom, #ecf4fa 0%, #ced4d9 100%); + -fx-background-insets: 0, 0 0 1 0; +} + +.menu-bar .menu .label { + -fx-text-fill: #2d3e4c; +} + +.split-pane > .split-pane-divider { + -fx-background-color: linear-gradient(to right, #ecf4fa 0%, #ced4d9 100%); + -fx-padding: 0 3 0 3; +} + +.scroll-pane { + -fx-background-insets: 0, 0; + -fx-padding: 0; +} + +.form { + -fx-background-color: #aeb5ba, linear-gradient(to bottom, #ecf4fa 0%, #ced4d9 100%); +} + +.details-header, +.cache-header { + -fx-background-color: linear-gradient(to bottom, #aaaaaa 0%, #888888 100%); +} + +.cache-list-name { + -fx-font-size: 1.2em; +} + +.cache-list-icon { + -fx-text-fill: #444444; + -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.4), 3, 0.0, 1, 1); +} + +.cache-list-found .cache-list-icon { + -fx-text-fill: #669900; +} + +.cache-list-action-icons { + -fx-padding: 4; + -fx-margin: 0 8; + -fx-text-fill: #ffffff; +} + +.text-input:readonly, +.combo-box-base:disabled, +.text-input:disabled { + -fx-opacity: 0.9; + -fx-background-color: linear-gradient(to bottom, #eeeeee 0%, #dddddd 100%); +} + +.slider:disabled { + -fx-opacity: 0.8; +} \ No newline at end of file diff --git a/src/de/frosch95/geofrogger/fx/geofrogger.fxml b/src/de/frosch95/geofrogger/fx/geofrogger.fxml new file mode 100644 index 0000000..92d5ebe --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/geofrogger.fxml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/de/frosch95/geofrogger/fx/geofrogger_de.properties b/src/de/frosch95/geofrogger/fx/geofrogger_de.properties new file mode 100644 index 0000000..adcb7ad --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/geofrogger_de.properties @@ -0,0 +1,21 @@ +menu.title.import.gpx = Importiere GPX +menu.title.file = Datei +menu.title.quit = Beenden +menu.title.help = Hilfe +menu.title.about = \u00dcber GeoFroggerFX + +label.text.cache.list=Caches +label.text.name=Name: +label.text.difficulty=Schwierigkeit: +label.text.terrain=Gel\u00E4nde +label.text.placedBy=Platziert von: +label.text.owner=Betreut von: +label.text.date=Datum: +label.text.type=Typ: +label.text.container=Gr\u00F6\u00dfe: +label.text.shortdescription=Kurze Beschreibung: +label.text.htmldescription=HTML Beschreibung +label.text.longdescription=Lange Beschreibung: + +tab.text.descriptions=Beschreibungen +tab.text.general=Allgemein \ No newline at end of file diff --git a/src/de/frosch95/geofrogger/fx/geofrogger_en.properties b/src/de/frosch95/geofrogger/fx/geofrogger_en.properties new file mode 100644 index 0000000..b1b87e0 --- /dev/null +++ b/src/de/frosch95/geofrogger/fx/geofrogger_en.properties @@ -0,0 +1,21 @@ +menu.title.import.gpx = Import GPX +menu.title.file = File +menu.title.quit = Quit +menu.title.help = Help +menu.title.about = About GeoFroggerFX + +label.text.cache.list=Caches +label.text.name=Name: +label.text.difficulty=Difficulty: +label.text.terrain=Terrain: +label.text.placedBy=Placed By: +label.text.owner=Owner: +label.text.date=Date: +label.text.type=Type: +label.text.container=Container: +label.text.shortdescription=Short description: +label.text.htmldescription=HTML Description +label.text.longdescription=Long description: + +tab.text.descriptions=Descriptions +tab.text.general=General \ No newline at end of file diff --git a/src/de/frosch95/geofrogger/gpx/GPXReader.java b/src/de/frosch95/geofrogger/gpx/GPXReader.java new file mode 100644 index 0000000..a979dc7 --- /dev/null +++ b/src/de/frosch95/geofrogger/gpx/GPXReader.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.gpx; + +import de.frosch95.geofrogger.application.ProgressListener; +import de.frosch95.geofrogger.model.Cache; + +import java.io.IOException; +import java.util.List; + +/** + * TODO: describe the class + * + * @author Andreas Billmann + */ +public interface GPXReader { + List load(final String fileName) throws IOException; + + void addListener(ProgressListener listener); +} diff --git a/src/de/frosch95/geofrogger/gpx/GroundspeakGPXReader.java b/src/de/frosch95/geofrogger/gpx/GroundspeakGPXReader.java new file mode 100644 index 0000000..d3613c6 --- /dev/null +++ b/src/de/frosch95/geofrogger/gpx/GroundspeakGPXReader.java @@ -0,0 +1,474 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.gpx; + +import de.frosch95.geofrogger.application.ProgressEvent; +import de.frosch95.geofrogger.application.ProgressListener; +import de.frosch95.geofrogger.model.Attribute; +import de.frosch95.geofrogger.model.*; +import org.jdom2.*; +import org.jdom2.input.SAXBuilder; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * TODO: describe the class + * + * @author Andreas Billmann + */ +public class GroundspeakGPXReader implements GPXReader { + + public static final String LAT = "lat"; + public static final String LON = "lon"; + public static final String TIME = "time"; + public static final String NAME = "name"; + public static final String DESC = "desc"; + public static final String WPT = "wpt"; + public static final String URL = "url"; + public static final String URLNAME = "urlname"; + public static final String SYM = "sym"; + public static final String TYPE = "type"; + public static final String CACHE = "cache"; + public static final String GROUNDSPEAK = "groundspeak"; + public static final String ID = "id"; + public static final String AVAILABLE = "available"; + public static final String ARCHIVED = "archived"; + public static final String PLACED_BY = "placed_by"; + public static final String OWNER = "owner"; + public static final String CONTAINER = "container"; + public static final String ATTRIBUTES = "attributes"; + public static final String ATTRIBUTE = "attribute"; + public static final String INC = "inc"; + public static final String DIFFICULTY = "difficulty"; + public static final String TERRAIN = "terrain"; + public static final String COUNTRY = "country"; + public static final String STATE = "state"; + public static final String SHORT_DESCRIPTION = "short_description"; + public static final String HTML = "html"; + public static final String LONG_DESCRIPTION = "long_description"; + public static final String ENCODED_HINTS = "encoded_hints"; + public static final String LOGS = "logs"; + public static final String LOG = "log"; + public static final String DATE = "date"; + public static final String FINDER = "finder"; + public static final String ENCODED = "encoded"; + public static final String TRAVELBUGS = "travelbugs"; + public static final String TRAVELBUG = "travelbug"; + public static final String TEXT = "text"; + public static final String REF = "ref"; + public static final String DEFAULT_NAMESPACE_URL = "http://www.topografix.com/GPX/1/0"; + public static final String GROUNDSPEAK_NAMESPACE_URL = "http://www.groundspeak.com/cache/1/0/1"; + + private final List listeners = new ArrayList<>(); + + private final Map userCache = new HashMap<>(); + + private File gpxFile; + private Document content; + private List modelList; + private Namespace defaultNamespace; + private Namespace groundspeakNamespace; + + @Override + public void addListener(ProgressListener listener) { + if (!listeners.contains(listener)) { + listeners.add(listener); + } + } + + @Override + public List load(final String filename) throws IOException { + + checkIfParameterIsNull(filename); + instantiateFileAndAssignToMember(filename); + checkIfFileExists(); + readFileContent(); + setNamespaces(); + parseContent(); + + return modelList; + } + + private void setNamespaces() { + defaultNamespace = Namespace.getNamespace(DEFAULT_NAMESPACE_URL); + groundspeakNamespace = Namespace.getNamespace(GROUNDSPEAK, GROUNDSPEAK_NAMESPACE_URL); + } + + private void checkIfParameterIsNull(String filename) { + if (filename == null) { + throw new IllegalArgumentException("filename should not be null"); + } + } + + private void instantiateFileAndAssignToMember(String filename) { + gpxFile = new File(filename); + } + + private void checkIfFileExists() throws FileNotFoundException { + if (!gpxFile.exists()) { + throw new FileNotFoundException("file does not exist"); + } + } + + private void readFileContent() throws IOException { + fireEvent(new ProgressEvent("GPX Reader", + ProgressEvent.State.STARTED, + "Load File " + gpxFile.getName() + " started.")); + countLineNumbers(); + + final SAXBuilder saxBuilder = new SAXBuilder(); + try { + content = saxBuilder.build(gpxFile); + } catch (JDOMException e) { + throw new IOException(e.getMessage(), e); + } + fireEvent(new ProgressEvent("GPX Reader", + ProgressEvent.State.FINISHED, + "Load File " + gpxFile.getName() + " finished.")); + } + + private void parseContent() { + modelList = new ArrayList<>(); + final Element root = content.getRootElement(); + final List waypoints = root.getChildren(WPT, defaultNamespace); + + int totalNumberOfCaches = waypoints.size(); + int currentNumber = 0; + for (final Element waypointElement : waypoints) { + currentNumber++; + fireEvent(new ProgressEvent("GPX Reader", + ProgressEvent.State.RUNNING, + "Parse " + currentNumber + " of " + totalNumberOfCaches + " caches.", + (double) currentNumber / (double) totalNumberOfCaches)); + final Cache cache = parseWaypointElement(waypointElement); + modelList.add(cache); + } + } + + private Cache parseWaypointElement(Element waypointElement) { + final Cache cache = new Cache(); + final Waypoint mainWaypoint = new Waypoint(); + cache.setMainWayPoint(mainWaypoint); + + try { + setLatitudeAndLongitude(waypointElement, mainWaypoint); + setTime(waypointElement, mainWaypoint); + setWaypointName(waypointElement, mainWaypoint); + setDescription(waypointElement, mainWaypoint); + setUrl(waypointElement, mainWaypoint); + setUrlName(waypointElement, mainWaypoint); + setSym(waypointElement, mainWaypoint); + setType(waypointElement, mainWaypoint); + + final Element cacheElement = waypointElement.getChild(CACHE, groundspeakNamespace); + parseCacheElement(cacheElement, cache); + } catch (DataConversionException | MalformedURLException e) { + // TODO: do some batch error handling + e.printStackTrace(); + } + return cache; + } + + private void parseCacheElement(Element cacheElement, Cache cache) throws DataConversionException { + setId(cacheElement, cache); + setAvailable(cacheElement, cache); + setArchived(cacheElement, cache); + setName(cacheElement, cache); + setPlacedBy(cacheElement, cache); + setOwner(cacheElement, cache); + setType(cacheElement, cache); + setContainer(cacheElement, cache); + setAttributes(cacheElement, cache); + setDifficulty(cacheElement, cache); + setTerrain(cacheElement, cache); + setCountry(cacheElement, cache); + setState(cacheElement, cache); + setShortDescription(cacheElement, cache); + setLongDescription(cacheElement, cache); + setEncodedHints(cacheElement, cache); + setLogs(cacheElement, cache); + setTravelBugs(cacheElement, cache); + } + + private void setTravelBugs(Element cacheElement, Cache cache) throws DataConversionException { + final Element travelBugsElement = cacheElement.getChild(TRAVELBUGS, groundspeakNamespace); + if (travelBugsElement != null) { + final List travelBugs = new ArrayList<>(); + cache.setTravelBugs(travelBugs); + for (Element travelBugElement : travelBugsElement.getChildren()) { + final TravelBug travelBug = new TravelBug(); + travelBugs.add(travelBug); + setId(travelBugElement, travelBug); + setRef(travelBugElement, travelBug); + setName(travelBugElement, travelBug); + } + } + } + + private void setName(Element travelBugElement, TravelBug travelBug) { + travelBug.setName(travelBugElement.getChild(NAME, groundspeakNamespace).getTextTrim()); + } + + private void setRef(Element travelBugElement, TravelBug travelBug) { + travelBug.setRef(travelBugElement.getAttribute(REF).getValue()); + } + + private void setId(Element travelBugElement, TravelBug travelBug) throws DataConversionException { + travelBug.setId(travelBugElement.getAttribute(ID).getLongValue()); + } + + private void setLogs(Element cacheElement, Cache cache) throws DataConversionException { + final Element logsElement = cacheElement.getChild(LOGS, groundspeakNamespace); + if (logsElement != null) { + final List logs = new ArrayList<>(); + cache.setLogs(logs); + for (Element logElement : logsElement.getChildren()) { + final Log log = new Log(); + logs.add(log); + setId(logElement, log); + setDate(logElement, log); + setType(logElement, log); + setText(logElement, log); + setFinder(logElement, log); + } + } + } + + private void setFinder(Element logElement, Log log) throws DataConversionException { + final Element finderElement = logElement.getChild(FINDER, groundspeakNamespace); + if (finderElement != null) { + final Long finderId = finderElement.getAttribute(ID).getLongValue(); + + User finder = userCache.get(finderId); + if (finder == null) { + finder = new User(); + setId(finderElement, finder); + setName(finderElement, finder); + } + log.setFinder(finder); + } + } + + private void setText(Element logElement, Log log) throws DataConversionException { + final Element textElement = logElement.getChild(TEXT, groundspeakNamespace); + log.setText(textElement.getTextTrim()); + log.setTextEncoded(textElement.getAttribute(ENCODED).getBooleanValue()); + } + + private void setType(Element logElement, Log log) { + log.setType(logElement.getChild(TYPE, groundspeakNamespace).getTextTrim()); + } + + private void setId(Element logElement, Log log) throws DataConversionException { + log.setId(logElement.getAttribute(ID).getLongValue()); + } + + private void setDate(Element logElement, Log log) { + final String dateText = logElement.getChild(DATE, groundspeakNamespace).getTextTrim(); + final LocalDateTime date = LocalDateTime.parse(dateText, DateTimeFormatter.ISO_DATE_TIME); + log.setDate(date); + } + + private void setEncodedHints(Element cacheElement, Cache cache) { + cache.setEncodedHints(cacheElement.getChild(ENCODED_HINTS, groundspeakNamespace).getTextTrim()); + } + + private void setLongDescription(Element cacheElement, Cache cache) throws DataConversionException { + final Element longDescription = cacheElement.getChild(LONG_DESCRIPTION, groundspeakNamespace); + cache.setLongDescription(longDescription.getTextTrim()); + cache.setLongDescriptionHtml(longDescription.getAttribute(HTML).getBooleanValue()); + } + + private void setShortDescription(Element cacheElement, Cache cache) throws DataConversionException { + final Element shortDescription = cacheElement.getChild(SHORT_DESCRIPTION, groundspeakNamespace); + cache.setShortDescription(shortDescription.getTextTrim()); + cache.setShortDescriptionHtml(shortDescription.getAttribute(HTML).getBooleanValue()); + } + + private void setState(Element cacheElement, Cache cache) { + cache.setState(cacheElement.getChild(STATE, groundspeakNamespace).getTextTrim()); + } + + private void setCountry(Element cacheElement, Cache cache) { + cache.setCountry(cacheElement.getChild(COUNTRY, groundspeakNamespace).getTextTrim()); + } + + private void setTerrain(Element cacheElement, Cache cache) { + cache.setTerrain(cacheElement.getChild(TERRAIN, groundspeakNamespace).getTextTrim()); + } + + private void setDifficulty(Element cacheElement, Cache cache) { + cache.setDifficulty(cacheElement.getChild(DIFFICULTY, groundspeakNamespace).getTextTrim()); + } + + private void setAttributes(Element cacheElement, Cache cache) throws DataConversionException { + final Element attributesElement = cacheElement.getChild(ATTRIBUTES, groundspeakNamespace); + if (attributesElement != null) { + final List attributes = new ArrayList<>(); + cache.setAttributes(attributes); + for (Element attributeElement : attributesElement.getChildren()) { + final Attribute attribute = new Attribute(); + attributes.add(attribute); + setId(attributeElement, attribute); + setInc(attributeElement, attribute); + setText(attributeElement, attribute); + } + } + } + + private void setText(Element attributeElement, Attribute attribute) { + attribute.setText(attributeElement.getTextTrim()); + } + + private void setInc(Element attributeElement, Attribute attribute) throws DataConversionException { + attribute.setInc(attributeElement.getAttribute(INC).getBooleanValue()); + } + + private void setId(Element attributeElement, Attribute attribute) throws DataConversionException { + attribute.setId(attributeElement.getAttribute(ID).getIntValue()); + } + + private void setContainer(Element cacheElement, Cache cache) { + cache.setContainer(cacheElement.getChild(CONTAINER, groundspeakNamespace).getTextTrim()); + } + + private void setType(Element cacheElement, Cache cache) { + cache.setType(cacheElement.getChild(TYPE, groundspeakNamespace).getTextTrim()); + } + + private void setOwner(Element cacheElement, Cache cache) throws DataConversionException { + final Element ownerElement = cacheElement.getChild(OWNER, groundspeakNamespace); + if (ownerElement != null) { + final Long userId = ownerElement.getAttribute(ID).getLongValue(); + User owner = userCache.get(userId); + if (owner == null) { + owner = new User(); + setId(ownerElement, owner); + setName(ownerElement, owner); + } + cache.setOwner(owner); + } + } + + private void setId(Element userElement, User user) throws DataConversionException { + user.setId(userElement.getAttribute(ID).getLongValue()); + } + + private void setName(Element userElement, User user) { + user.setName(userElement.getTextTrim()); + } + + private void setPlacedBy(Element cacheElement, Cache cache) { + cache.setPlacedBy(cacheElement.getChild(PLACED_BY, groundspeakNamespace).getTextTrim()); + } + + private void setArchived(Element cacheElement, Cache cache) throws DataConversionException { + cache.setArchived(cacheElement.getAttribute(ARCHIVED).getBooleanValue()); + } + + private void setAvailable(Element cacheElement, Cache cache) throws DataConversionException { + cache.setAvailable(cacheElement.getAttribute(AVAILABLE).getBooleanValue()); + } + + private void setId(Element cacheElement, Cache cache) throws DataConversionException { + cache.setId(cacheElement.getAttribute(ID).getLongValue()); + } + + private void setType(Element cacheElement, Waypoint waypoint) { + waypoint.setType(cacheElement.getChild(TYPE, defaultNamespace).getTextTrim()); + } + + private void setSym(Element cacheElement, Waypoint waypoint) { + waypoint.setSymbol(cacheElement.getChild(SYM, defaultNamespace).getTextTrim()); + } + + private void setUrlName(Element cacheElement, Waypoint waypoint) throws MalformedURLException { + waypoint.setUrlName(cacheElement.getChild(URLNAME, defaultNamespace).getTextTrim()); + } + + private void setUrl(Element cacheElement, Waypoint waypoint) throws MalformedURLException { + waypoint.setUrl(new URL(cacheElement.getChild(URL, defaultNamespace).getTextTrim())); + } + + private void setDescription(Element cacheElement, Waypoint waypoint) { + waypoint.setDescription(cacheElement.getChild(DESC, defaultNamespace).getTextTrim()); + } + + private void setWaypointName(Element cacheElement, Waypoint waypoint) { + waypoint.setName(cacheElement.getChild(NAME, defaultNamespace).getTextTrim()); + } + + private void setLatitudeAndLongitude(Element cacheElement, Waypoint waypoint) throws DataConversionException { + waypoint.setLatitude(cacheElement.getAttribute(LAT).getDoubleValue()); + waypoint.setLongitude(cacheElement.getAttribute(LON).getDoubleValue()); + } + + private void setTime(Element cacheElement, Waypoint waypoint) { + final String timeText = cacheElement.getChild(TIME, defaultNamespace).getTextTrim(); + final LocalDateTime date = LocalDateTime.parse(timeText, DateTimeFormatter.ISO_DATE_TIME); + waypoint.setTime(date); + } + + private void setName(Element cacheElement, Cache cache) { + cache.setName(cacheElement.getChild(NAME, groundspeakNamespace).getTextTrim()); + } + + private void fireEvent(ProgressEvent event) { + listeners.stream().forEach((l) -> { + l.progress(event); + }); + } + + private void countLineNumbers() { + int totalNumberOfLines = 0; + Charset charset = Charset.forName("UTF-8"); + StringBuilder sb = new StringBuilder(); + try (BufferedReader reader = Files.newBufferedReader(gpxFile.toPath(), charset)) { + String line = null; + while ((line = reader.readLine()) != null) { + totalNumberOfLines++; + } + fireEvent(new ProgressEvent("GPX Reader", + ProgressEvent.State.RUNNING, + totalNumberOfLines + " lines to read!")); + } catch (IOException x) { + x.printStackTrace(); + } + } +} diff --git a/src/de/frosch95/geofrogger/model/Attribute.java b/src/de/frosch95/geofrogger/model/Attribute.java new file mode 100644 index 0000000..f7912c0 --- /dev/null +++ b/src/de/frosch95/geofrogger/model/Attribute.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.model; + +/** + * @author Andreas Billmann + */ +public class Attribute { + + private Integer id; + private boolean inc; + private String text; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public boolean isInc() { + return inc; + } + + public void setInc(boolean inc) { + this.inc = inc; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } +} diff --git a/src/de/frosch95/geofrogger/model/Cache.java b/src/de/frosch95/geofrogger/model/Cache.java new file mode 100644 index 0000000..7b1d0df --- /dev/null +++ b/src/de/frosch95/geofrogger/model/Cache.java @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.model; + +import java.util.List; + +/** + * @author Andreas Billmann + */ +public class Cache { + + private Long id; + private boolean available; + private boolean archived; + private String name; + private String placedBy; + private User owner; + private String type; + private String container; + private List attributes; + private String difficulty; + private String terrain; + private String country; + private String state; + private String shortDescription; + private boolean shortDescriptionHtml; + private String longDescription; + private boolean longDescriptionHtml; + private String encodedHints; + private List logs; + private List travelBugs; + private Waypoint mainWayPoint; + + public Waypoint getMainWayPoint() { + return mainWayPoint; + } + + public void setMainWayPoint(Waypoint mainWayPoint) { + this.mainWayPoint = mainWayPoint; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + public boolean isArchived() { + return archived; + } + + public void setArchived(boolean archived) { + this.archived = archived; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPlacedBy() { + return placedBy; + } + + public void setPlacedBy(String placedBy) { + this.placedBy = placedBy; + } + + public User getOwner() { + return owner; + } + + public void setOwner(User owner) { + this.owner = owner; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getContainer() { + return container; + } + + public void setContainer(String container) { + this.container = container; + } + + public List getAttributes() { + return attributes; + } + + public void setAttributes(List attributes) { + this.attributes = attributes; + } + + public String getDifficulty() { + return difficulty; + } + + public void setDifficulty(String difficulty) { + this.difficulty = difficulty; + } + + public String getTerrain() { + return terrain; + } + + public void setTerrain(String terrain) { + this.terrain = terrain; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getShortDescription() { + return shortDescription; + } + + public void setShortDescription(String shortDescription) { + this.shortDescription = shortDescription; + } + + public boolean isShortDescriptionHtml() { + return shortDescriptionHtml; + } + + public void setShortDescriptionHtml(boolean shortDescriptionHtml) { + this.shortDescriptionHtml = shortDescriptionHtml; + } + + public String getLongDescription() { + return longDescription; + } + + public void setLongDescription(String longDescription) { + this.longDescription = longDescription; + } + + public boolean isLongDescriptionHtml() { + return longDescriptionHtml; + } + + public void setLongDescriptionHtml(boolean longDescriptionHtml) { + this.longDescriptionHtml = longDescriptionHtml; + } + + public String getEncodedHints() { + return encodedHints; + } + + public void setEncodedHints(String encodedHints) { + this.encodedHints = encodedHints; + } + + public List getLogs() { + return logs; + } + + public void setLogs(List logs) { + this.logs = logs; + } + + public List getTravelBugs() { + return travelBugs; + } + + public void setTravelBugs(List travelBugs) { + this.travelBugs = travelBugs; + } + + @Override + public String toString() { + return "Cache{" + + "name='" + name + '\'' + + '}'; + } +} diff --git a/src/de/frosch95/geofrogger/model/CacheUtils.java b/src/de/frosch95/geofrogger/model/CacheUtils.java new file mode 100644 index 0000000..cdc905b --- /dev/null +++ b/src/de/frosch95/geofrogger/model/CacheUtils.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.model; + +import java.util.List; + +/** + * @author Andreas Billmann + */ +public class CacheUtils { + + public static final String FOUND_IT = "Found it"; + + public static boolean hasUserFoundCache(Cache cache, Long currentUser) { + boolean foundIt = false; + if (currentUser != null) { + List logs = cache.getLogs(); + if (logs != null) { + for (Log log : logs) { + if (isCurrentUserLogUser(log, currentUser) && isLogTypeFoundIt(log)) { + foundIt = true; + break; + } + } + } + } + return foundIt; + } + + private static boolean isCurrentUserLogUser(Log log, Long currentUser) { + return log.getFinder().getId().equals(currentUser); + } + + private static boolean isLogTypeFoundIt(Log log) { + return log.getType().equals(FOUND_IT); + } + +} diff --git a/src/de/frosch95/geofrogger/model/Log.java b/src/de/frosch95/geofrogger/model/Log.java new file mode 100644 index 0000000..c726dc0 --- /dev/null +++ b/src/de/frosch95/geofrogger/model/Log.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.model; + +import java.time.LocalDateTime; + +/** + * @author Andreas Billmann + */ +public class Log { + + private Long id; + private LocalDateTime date; + private String type; + private User finder; + private boolean textEncoded; + private String text; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LocalDateTime getDate() { + return date; + } + + public void setDate(LocalDateTime date) { + this.date = date; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public User getFinder() { + return finder; + } + + public void setFinder(User finder) { + this.finder = finder; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public boolean isTextEncoded() { + return textEncoded; + } + + public void setTextEncoded(boolean textEncoded) { + this.textEncoded = textEncoded; + } +} diff --git a/src/de/frosch95/geofrogger/model/TravelBug.java b/src/de/frosch95/geofrogger/model/TravelBug.java new file mode 100644 index 0000000..ece8e21 --- /dev/null +++ b/src/de/frosch95/geofrogger/model/TravelBug.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.model; + +/** + * @author Andreas Billmann + */ +public class TravelBug { + + private Long id; + private String ref; + private String name; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getRef() { + return ref; + } + + public void setRef(String ref) { + this.ref = ref; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/de/frosch95/geofrogger/model/User.java b/src/de/frosch95/geofrogger/model/User.java new file mode 100644 index 0000000..42b9e20 --- /dev/null +++ b/src/de/frosch95/geofrogger/model/User.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.model; + +/** + * @author Andreas Billmann + */ +public class User { + + private Long id; + private String name; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/de/frosch95/geofrogger/model/Waypoint.java b/src/de/frosch95/geofrogger/model/Waypoint.java new file mode 100644 index 0000000..be350f3 --- /dev/null +++ b/src/de/frosch95/geofrogger/model/Waypoint.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.model; + +import java.net.URL; +import java.time.LocalDateTime; + +/** + * @author Andreas Billmann + */ +public class Waypoint { + + private Long id; + private double latitude; + private double longitude; + private String name; + private LocalDateTime time; + private String description; + private URL url; + private String urlName; + private String symbol; + private String type; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public void setTime(LocalDateTime time) { + this.time = time; + } + + public LocalDateTime getTime() { + return time; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public URL getUrl() { + return url; + } + + public void setUrl(URL url) { + this.url = url; + } + + public String getUrlName() { + return urlName; + } + + public void setUrlName(String urlName) { + this.urlName = urlName; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/src/de/frosch95/geofrogger/service/CacheService.java b/src/de/frosch95/geofrogger/service/CacheService.java new file mode 100644 index 0000000..071a4a2 --- /dev/null +++ b/src/de/frosch95/geofrogger/service/CacheService.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.service; + +import de.frosch95.geofrogger.application.ProgressListener; +import de.frosch95.geofrogger.model.Cache; + +import java.util.List; + +/** + * @author Andreas + */ +public interface CacheService { + void storeCaches(List caches); + + List getAllCaches(); + + void addListener(ProgressListener listener); +} diff --git a/src/de/frosch95/geofrogger/service/CacheServiceImpl.java b/src/de/frosch95/geofrogger/service/CacheServiceImpl.java new file mode 100644 index 0000000..e3b33a4 --- /dev/null +++ b/src/de/frosch95/geofrogger/service/CacheServiceImpl.java @@ -0,0 +1,325 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package de.frosch95.geofrogger.service; + +import de.frosch95.geofrogger.application.ProgressEvent; +import de.frosch95.geofrogger.application.ProgressListener; +import de.frosch95.geofrogger.application.ServiceManager; +import de.frosch95.geofrogger.model.Cache; +import de.frosch95.geofrogger.model.User; +import de.frosch95.geofrogger.model.Waypoint; +import de.frosch95.geofrogger.sql.DatabaseService; + +import java.net.MalformedURLException; +import java.net.URL; +import java.sql.*; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * @author Andreas + */ +public class CacheServiceImpl implements CacheService { + + private static final String SAVE_CACHE = "INSERT INTO geocache(" + + "id," + + "available," + + "archived," + + "name," + + "placedBy," + + "ownerId," + + "type," + + "container," + + "difficulty," + + "terrain," + + "country," + + "state," + + "shortDescription," + + "shortDescriptionHtml," + + "longDescription," + + "longDescriptionHtml," + + "encodedHints," + + "mainWaypointId" + + ") values (" + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?" + + ")"; + + private static final String SAVE_WAYPOINT = "INSERT INTO waypoint(" + + "id," + + "latitude," + + "longitude," + + "name," + + "time," + + "description," + + "url," + + "urlName," + + "symbol," + + "type" + + ") values (" + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?," + + "?" + + ")"; + + private static final String COUNT_ALL_CACHES = "SELECT count(*) FROM geocache"; + private static final String LOAD_ALL_CACHES = "SELECT * FROM geocache ORDER BY ID"; + private static final String LOAD_CACHE_BY_ID = "SELECT * FROM geocache WHERE ID = ?"; + private static final String LOAD_ALL_WAYPOINTS = "SELECT * FROM waypoint ORDER BY ID"; + + private final DatabaseService dbService = ServiceManager.getInstance().getDatabaseService(); + + private final List listeners = new ArrayList<>(); + + @Override + public void addListener(ProgressListener listener) { + if (!listeners.contains(listener)) { + listeners.add(listener); + } + } + + @Override + public void storeCaches(List caches) { + Connection connection = null; + try { + connection = dbService.getConnection(); + try (PreparedStatement cacheStatement = connection.prepareStatement(SAVE_CACHE)) { + try (PreparedStatement waypointStatement = connection.prepareStatement(SAVE_WAYPOINT)) { + int currentCacheNumber = 0; + int numberOfCaches = caches.size(); + for (Cache cache : caches) { + currentCacheNumber++; + fireEvent(new ProgressEvent("Database", + ProgressEvent.State.RUNNING, + "Save caches to Database " + currentCacheNumber + " / " + numberOfCaches, + (double) currentCacheNumber / (double) numberOfCaches)); + + if (!doesCacheExist(cache.getId())) { + saveCacheObject(cacheStatement, cache); + saveWaypointObject(waypointStatement, cache); + } + } + } + } + connection.commit(); + } catch (SQLException ex) { + Logger.getLogger(CacheServiceImpl.class.getName()).log(Level.SEVERE, null, ex); + if (connection != null) { + try { + connection.rollback(); + } catch (SQLException ex1) { + Logger.getLogger(CacheServiceImpl.class.getName()).log(Level.SEVERE, null, ex1); + } + } + } + } + + private boolean doesCacheExist(Long id) { + boolean exists = false; + try { + try (PreparedStatement cacheStatement = dbService.getConnection().prepareStatement(LOAD_CACHE_BY_ID)) { + cacheStatement.setLong(1, id); + try (ResultSet cacheResultSet = cacheStatement.executeQuery()) { + exists = cacheResultSet.next(); + } + } + } catch (SQLException ex) { + Logger.getLogger(CacheServiceImpl.class.getName()).log(Level.SEVERE, null, ex); + } + return exists; + } + + @Override + public List getAllCaches() { + List caches = new ArrayList<>(); + Connection connection; + try { + connection = dbService.getConnection(); + try (PreparedStatement cacheStatement = connection.prepareStatement(LOAD_ALL_CACHES)) { + caches = resultSetToCacheList(cacheStatement, connection); + } + connection.commit(); + } catch (SQLException ex) { + Logger.getLogger(CacheServiceImpl.class.getName()).log(Level.SEVERE, null, ex); + } + return caches; + } + + private void saveCacheObject(PreparedStatement cacheStatement, Cache cache) throws SQLException { + cacheStatement.setLong(1, cache.getId()); + cacheStatement.setBoolean(2, cache.isAvailable()); + cacheStatement.setBoolean(3, cache.isArchived()); + cacheStatement.setString(4, cache.getName()); + cacheStatement.setString(5, cache.getPlacedBy()); + cacheStatement.setLong(6, cache.getOwner().getId()); // ownerid + cacheStatement.setString(7, cache.getType()); // type + cacheStatement.setString(8, cache.getContainer()); //container + cacheStatement.setString(9, cache.getDifficulty()); //difficulty + cacheStatement.setString(10, cache.getTerrain()); //terrain + cacheStatement.setString(11, cache.getCountry()); //country + cacheStatement.setString(12, cache.getState()); //state + cacheStatement.setString(13, cache.getShortDescription()); //shortDescription + cacheStatement.setBoolean(14, cache.isShortDescriptionHtml()); //shortDescriptionHtml + cacheStatement.setString(15, cache.getLongDescription()); //longDescription + cacheStatement.setBoolean(16, cache.isLongDescriptionHtml()); //longDescriptionHtml + cacheStatement.setString(17, cache.getEncodedHints()); //encodedHints + cacheStatement.setLong(18, cache.getId()); //mainWaypointId + cacheStatement.execute(); + } + + private void saveWaypointObject(PreparedStatement waypointStatement, Cache cache) throws SQLException { + waypointStatement.setLong(1, cache.getId()); + waypointStatement.setDouble(2, cache.getMainWayPoint().getLatitude()); // latitude + waypointStatement.setDouble(3, cache.getMainWayPoint().getLongitude()); //longitude," + waypointStatement.setString(4, cache.getMainWayPoint().getName()); //name," + waypointStatement.setTimestamp(5, Timestamp.valueOf(cache.getMainWayPoint().getTime())); //time," + waypointStatement.setString(6, cache.getMainWayPoint().getDescription()); //description," + waypointStatement.setString(7, cache.getMainWayPoint().getUrl().toExternalForm()); //url," + waypointStatement.setString(8, cache.getMainWayPoint().getUrlName()); //urlName," + waypointStatement.setString(9, cache.getMainWayPoint().getSymbol()); //symbol," + waypointStatement.setString(10, cache.getMainWayPoint().getType()); //type" + waypointStatement.execute(); + } + + private List resultSetToCacheList(final PreparedStatement cacheStatement, Connection connection) throws SQLException { + + final List caches = new ArrayList<>(); + + int numberOfCaches = 0; + try (PreparedStatement countStatement = connection.prepareStatement(COUNT_ALL_CACHES)) { + try (ResultSet countResultSet = countStatement.executeQuery()) { + if (countResultSet.next()) { + numberOfCaches = countResultSet.getInt(1); + } + } + } + + try (ResultSet cacheResultSet = cacheStatement.executeQuery()) { + int currentCacheNumber = 0; + while (cacheResultSet.next()) { + currentCacheNumber++; + fireEvent(new ProgressEvent("Database", + ProgressEvent.State.RUNNING, + "Load caches from Database " + currentCacheNumber + " / " + numberOfCaches, + (double) currentCacheNumber / (double) numberOfCaches)); + createCacheObject(cacheResultSet, caches); + } + } + + final List waypoints = new ArrayList<>(); + try (PreparedStatement waypointStatement = connection.prepareStatement(LOAD_ALL_WAYPOINTS)) { + try (ResultSet waypointResultSet = waypointStatement.executeQuery()) { + int currentWaypointNumber = 0; + while (waypointResultSet.next()) { + currentWaypointNumber++; + fireEvent(new ProgressEvent("Database", + ProgressEvent.State.RUNNING, + "Load waypoints from Database " + currentWaypointNumber + " / " + numberOfCaches, + (double) currentWaypointNumber / (double) numberOfCaches)); + createWaypointObject(waypointResultSet, waypoints); + } + } + } + + int cacheSize = caches.size(); + int waypointSize = waypoints.size(); + + assert cacheSize == waypointSize : "size of waypoints and size of caches have to be the same!!"; + for (int i = 0; i < cacheSize; i++) { + final Cache cache = caches.get(i); + final Waypoint waypoint = waypoints.get(i); + + assert cache.getId().equals(waypoint.getId()); + + fireEvent(new ProgressEvent("Database", + ProgressEvent.State.RUNNING, + "Add waypoints to caches " + i + " / " + cacheSize, + (double) i / (double) cacheSize)); + + cache.setMainWayPoint(waypoint); + + } + return caches; + } + + private void fireEvent(ProgressEvent event) { + listeners.stream().forEach((l) -> { + l.progress(event); + }); + } + + private void createCacheObject(final ResultSet cacheResultSet, final List caches) throws SQLException { + Cache cache = new Cache(); + cache.setId(cacheResultSet.getLong("id")); + cache.setAvailable(cacheResultSet.getBoolean("available")); + cache.setAvailable(cacheResultSet.getBoolean("archived")); + cache.setName(cacheResultSet.getString("name")); + cache.setPlacedBy(cacheResultSet.getString("placedBy")); + cache.setType(cacheResultSet.getString("type")); + cache.setContainer(cacheResultSet.getString("container")); + cache.setDifficulty(cacheResultSet.getString("difficulty")); + cache.setTerrain(cacheResultSet.getString("terrain")); + cache.setCountry(cacheResultSet.getString("country")); + cache.setState(cacheResultSet.getString("state")); + cache.setShortDescription(cacheResultSet.getString("shortDescription")); + cache.setShortDescriptionHtml(cacheResultSet.getBoolean("shortDescriptionHtml")); + cache.setLongDescription(cacheResultSet.getString("longDescription")); + cache.setLongDescriptionHtml(cacheResultSet.getBoolean("longDescriptionHtml")); + cache.setEncodedHints(cacheResultSet.getString("encodedHints")); + + User user = new User(); + user.setName("aus der DB"); + user.setId(cacheResultSet.getLong("ownerId")); + cache.setOwner(user); + caches.add(cache); + } + + private void createWaypointObject(final ResultSet waypointResultSet, final List waypoints) throws SQLException { + Waypoint waypoint = new Waypoint(); + //cache.setMainWayPoint(waypoint); + waypoint.setId(waypointResultSet.getLong("id")); + waypoint.setLatitude(waypointResultSet.getDouble("latitude")); + waypoint.setLongitude(waypointResultSet.getDouble("longitude")); + waypoint.setName(waypointResultSet.getString("name")); + waypoint.setTime(waypointResultSet.getTimestamp("time").toLocalDateTime()); + waypoint.setDescription(waypointResultSet.getString("description")); + try { + waypoint.setUrl(new URL(waypointResultSet.getString("url"))); + } catch (MalformedURLException ex) { + Logger.getLogger(CacheServiceImpl.class.getName()).log(Level.SEVERE, null, ex); + } + waypoint.setUrlName(waypointResultSet.getString("urlName")); + waypoint.setSymbol(waypointResultSet.getString("symbol")); + waypoint.setType(waypointResultSet.getString("type")); + waypoints.add(waypoint); + } + +} diff --git a/src/de/frosch95/geofrogger/service/UserService.java b/src/de/frosch95/geofrogger/service/UserService.java new file mode 100644 index 0000000..d3310fc --- /dev/null +++ b/src/de/frosch95/geofrogger/service/UserService.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.service; + +/** + * @author Andreas + */ +public interface UserService { + +} diff --git a/src/de/frosch95/geofrogger/sql/DatabaseService.java b/src/de/frosch95/geofrogger/sql/DatabaseService.java new file mode 100644 index 0000000..14b1e69 --- /dev/null +++ b/src/de/frosch95/geofrogger/sql/DatabaseService.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.sql; + +import java.sql.Connection; +import java.sql.SQLException; + +/** + * @author Andreas + */ +public interface DatabaseService { + Connection getConnection() throws SQLException; +} diff --git a/src/de/frosch95/geofrogger/sql/DatabaseServiceImpl.java b/src/de/frosch95/geofrogger/sql/DatabaseServiceImpl.java new file mode 100644 index 0000000..d1e1918 --- /dev/null +++ b/src/de/frosch95/geofrogger/sql/DatabaseServiceImpl.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2013, Andreas Billmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package de.frosch95.geofrogger.sql; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * @author Andreas + */ +public class DatabaseServiceImpl implements DatabaseService { + + private static final String CREATE_GEOCACHE_TABLE = + "CREATE TABLE geocache (" + + "id BIGINT," + + "available BOOLEAN," + + "archived BOOLEAN," + + "name VARCHAR(255)," + + "placedBy VARCHAR(255)," + + "ownerId BIGINT," + + "type VARCHAR(255)," + + "container VARCHAR(255)," + + "difficulty VARCHAR(10)," + + "terrain VARCHAR(10)," + + "country VARCHAR(255)," + + "state VARCHAR(255)," + + "shortDescription CLOB," + + "shortDescriptionHtml BOOLEAN," + + "longDescription CLOB," + + "longDescriptionHtml BOOLEAN," + + "encodedHints CLOB," + + "mainWaypointId BIGINT" + + ");"; + + private static final String WAYPOINT_TABLE = + "CREATE TABLE waypoint (" + + "id BIGINT," + + "latitude DECIMAL(9,6)," + + "longitude DECIMAL(9,6)," + + "name VARCHAR(255)," + + "time TIMESTAMP," + + "description CLOB," + + "url VARCHAR(255)," + + "urlName VARCHAR(255)," + + "symbol VARCHAR(255)," + + "type VARCHAR(255)" + + ");"; + + + private Connection con; + + public DatabaseServiceImpl() { + try { + con = DriverManager.getConnection("jdbc:h2:./geofroggerfxdb;IFEXISTS=TRUE", "sa", "sa"); + con.setAutoCommit(false); + } catch (SQLException ex) { + setupDatabase(); + } + } + + @Override + public Connection getConnection() throws SQLException { + if (con == null) { + throw new SQLException("no connection available"); + } + return con; + } + + private void setupDatabase() { + Statement statement = null; + try { + Class.forName("org.h2.Driver"); + con = DriverManager.getConnection("jdbc:h2:./geofroggerfxdb", "sa", "sa"); + con.setAutoCommit(false); + statement = con.createStatement(); + statement.execute(CREATE_GEOCACHE_TABLE); + statement.execute(WAYPOINT_TABLE); + con.commit(); + } catch (SQLException | ClassNotFoundException ex) { + Logger.getLogger(DatabaseServiceImpl.class.getName()).log(Level.SEVERE, null, ex); + } finally { + if (statement != null) try { + statement.close(); + } catch (SQLException ex) { + Logger.getLogger(DatabaseServiceImpl.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + +} diff --git a/src/fonts/FontAwesome.otf b/src/fonts/FontAwesome.otf new file mode 100644 index 0000000..7012545 Binary files /dev/null and b/src/fonts/FontAwesome.otf differ diff --git a/src/fonts/fontawesome-webfont.eot b/src/fonts/fontawesome-webfont.eot new file mode 100644 index 0000000..0662cb9 Binary files /dev/null and b/src/fonts/fontawesome-webfont.eot differ diff --git a/src/fonts/fontawesome-webfont.svg b/src/fonts/fontawesome-webfont.svg new file mode 100644 index 0000000..2edb4ec --- /dev/null +++ b/src/fonts/fontawesome-webfont.svg @@ -0,0 +1,399 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/fonts/fontawesome-webfont.ttf b/src/fonts/fontawesome-webfont.ttf new file mode 100644 index 0000000..d365924 Binary files /dev/null and b/src/fonts/fontawesome-webfont.ttf differ diff --git a/src/fonts/fontawesome-webfont.woff b/src/fonts/fontawesome-webfont.woff new file mode 100644 index 0000000..b9bd17e Binary files /dev/null and b/src/fonts/fontawesome-webfont.woff differ diff --git a/src/fonts/license.txt b/src/fonts/license.txt new file mode 100644 index 0000000..f0e41c0 --- /dev/null +++ b/src/fonts/license.txt @@ -0,0 +1,23 @@ +Font Awesome is fully open source and is GPL compatible. You can use it for commercial projects, open source projects, or really just about whatever you want. + +Booking.comTime for a change? We are hiring great developers to work with us in awesome Amsterdam.ads via Carbon +Attribution is no longer required as of Font Awesome 3.0 but is much appreciated: "Font Awesome by Dave Gandy - http://fontawesome.io". +Font License + +Applies to all desktop and webfont files in the following directory: font-awesome/font/. +License: SIL OFL 1.1 +URL: http://scripts.sil.org/OFL +Code License + +Applies to all CSS and LESS files in the following directories: font-awesome/css/ and font-awesome/less/. +License: MIT License +URL: http://opensource.org/licenses/mit-license.html +Documentation License + +Applies to all Font Awesome project files that are not a part of the Font or Code licenses. +License: CC BY 3.0 +URL: http://creativecommons.org/licenses/by/3.0/ +Brand Icons + +All brand icons are trademarks of their respective owners. +The use of these trademarks does not indicate endorsement of the trademark holder by Font Awesome, nor vice versa. \ No newline at end of file diff --git a/src/icons/iconmonstr-bookmark-21-icon.png b/src/icons/iconmonstr-bookmark-21-icon.png new file mode 100644 index 0000000..2fc8e7e Binary files /dev/null and b/src/icons/iconmonstr-bookmark-21-icon.png differ diff --git a/src/icons/iconmonstr-bookmark-22-icon.png b/src/icons/iconmonstr-bookmark-22-icon.png new file mode 100644 index 0000000..99d61ce Binary files /dev/null and b/src/icons/iconmonstr-bookmark-22-icon.png differ diff --git a/src/icons/iconmonstr-bookmark-23-icon.png b/src/icons/iconmonstr-bookmark-23-icon.png new file mode 100644 index 0000000..90c76c9 Binary files /dev/null and b/src/icons/iconmonstr-bookmark-23-icon.png differ diff --git a/src/icons/iconmonstr-bookmark-24-icon.png b/src/icons/iconmonstr-bookmark-24-icon.png new file mode 100644 index 0000000..ed8a4c4 Binary files /dev/null and b/src/icons/iconmonstr-bookmark-24-icon.png differ diff --git a/src/icons/iconmonstr-bookmark-25-icon.png b/src/icons/iconmonstr-bookmark-25-icon.png new file mode 100644 index 0000000..361512b Binary files /dev/null and b/src/icons/iconmonstr-bookmark-25-icon.png differ diff --git a/src/icons/iconmonstr-bookmark-26-icon.png b/src/icons/iconmonstr-bookmark-26-icon.png new file mode 100644 index 0000000..6f2f685 Binary files /dev/null and b/src/icons/iconmonstr-bookmark-26-icon.png differ diff --git a/src/icons/iconmonstr-bookmark-27-icon.png b/src/icons/iconmonstr-bookmark-27-icon.png new file mode 100644 index 0000000..4e28779 Binary files /dev/null and b/src/icons/iconmonstr-bookmark-27-icon.png differ diff --git a/src/icons/iconmonstr-calendar-4-icon.png b/src/icons/iconmonstr-calendar-4-icon.png new file mode 100644 index 0000000..c4fea8a Binary files /dev/null and b/src/icons/iconmonstr-calendar-4-icon.png differ diff --git a/src/icons/iconmonstr-check-mark-10-icon.png b/src/icons/iconmonstr-check-mark-10-icon.png new file mode 100644 index 0000000..96a0d86 Binary files /dev/null and b/src/icons/iconmonstr-check-mark-10-icon.png differ diff --git a/src/icons/iconmonstr-check-mark-11-icon.png b/src/icons/iconmonstr-check-mark-11-icon.png new file mode 100644 index 0000000..d2885a9 Binary files /dev/null and b/src/icons/iconmonstr-check-mark-11-icon.png differ diff --git a/src/icons/iconmonstr-check-mark-2-icon.png b/src/icons/iconmonstr-check-mark-2-icon.png new file mode 100644 index 0000000..eab825d Binary files /dev/null and b/src/icons/iconmonstr-check-mark-2-icon.png differ diff --git a/src/icons/iconmonstr-check-mark-3-icon.png b/src/icons/iconmonstr-check-mark-3-icon.png new file mode 100644 index 0000000..0591649 Binary files /dev/null and b/src/icons/iconmonstr-check-mark-3-icon.png differ diff --git a/src/icons/iconmonstr-check-mark-4-icon.png b/src/icons/iconmonstr-check-mark-4-icon.png new file mode 100644 index 0000000..3f57384 Binary files /dev/null and b/src/icons/iconmonstr-check-mark-4-icon.png differ diff --git a/src/icons/iconmonstr-check-mark-5-icon.png b/src/icons/iconmonstr-check-mark-5-icon.png new file mode 100644 index 0000000..de2c885 Binary files /dev/null and b/src/icons/iconmonstr-check-mark-5-icon.png differ diff --git a/src/icons/iconmonstr-check-mark-8-icon.png b/src/icons/iconmonstr-check-mark-8-icon.png new file mode 100644 index 0000000..6d82de6 Binary files /dev/null and b/src/icons/iconmonstr-check-mark-8-icon.png differ diff --git a/src/icons/iconmonstr-check-mark-9-icon.png b/src/icons/iconmonstr-check-mark-9-icon.png new file mode 100644 index 0000000..6c57bfd Binary files /dev/null and b/src/icons/iconmonstr-check-mark-9-icon.png differ diff --git a/src/icons/iconmonstr-check-mark-icon.png b/src/icons/iconmonstr-check-mark-icon.png new file mode 100644 index 0000000..64a0091 Binary files /dev/null and b/src/icons/iconmonstr-check-mark-icon.png differ diff --git a/src/icons/iconmonstr-email-4-icon.png b/src/icons/iconmonstr-email-4-icon.png new file mode 100644 index 0000000..195e59a Binary files /dev/null and b/src/icons/iconmonstr-email-4-icon.png differ diff --git a/src/icons/iconmonstr-filter-2-icon.png b/src/icons/iconmonstr-filter-2-icon.png new file mode 100644 index 0000000..a60dc5c Binary files /dev/null and b/src/icons/iconmonstr-filter-2-icon.png differ diff --git a/src/icons/iconmonstr-filter-3-icon.png b/src/icons/iconmonstr-filter-3-icon.png new file mode 100644 index 0000000..e1ff21c Binary files /dev/null and b/src/icons/iconmonstr-filter-3-icon.png differ diff --git a/src/icons/iconmonstr-filter-4-icon.png b/src/icons/iconmonstr-filter-4-icon.png new file mode 100644 index 0000000..907d057 Binary files /dev/null and b/src/icons/iconmonstr-filter-4-icon.png differ diff --git a/src/icons/iconmonstr-filter-5-icon.png b/src/icons/iconmonstr-filter-5-icon.png new file mode 100644 index 0000000..a0dd066 Binary files /dev/null and b/src/icons/iconmonstr-filter-5-icon.png differ diff --git a/src/icons/iconmonstr-filter-icon.png b/src/icons/iconmonstr-filter-icon.png new file mode 100644 index 0000000..9fb5f07 Binary files /dev/null and b/src/icons/iconmonstr-filter-icon.png differ diff --git a/src/icons/iconmonstr-gear-10-icon.png b/src/icons/iconmonstr-gear-10-icon.png new file mode 100644 index 0000000..3b81030 Binary files /dev/null and b/src/icons/iconmonstr-gear-10-icon.png differ diff --git a/src/icons/iconmonstr-gear-9-icon.png b/src/icons/iconmonstr-gear-9-icon.png new file mode 100644 index 0000000..9d85ebc Binary files /dev/null and b/src/icons/iconmonstr-gear-9-icon.png differ diff --git a/src/icons/iconmonstr-gear-icon.png b/src/icons/iconmonstr-gear-icon.png new file mode 100644 index 0000000..3bd8e52 Binary files /dev/null and b/src/icons/iconmonstr-gear-icon.png differ diff --git a/src/icons/iconmonstr-globe-4-icon.png b/src/icons/iconmonstr-globe-4-icon.png new file mode 100644 index 0000000..7d1bedd Binary files /dev/null and b/src/icons/iconmonstr-globe-4-icon.png differ diff --git a/src/icons/iconmonstr-help-3-icon.png b/src/icons/iconmonstr-help-3-icon.png new file mode 100644 index 0000000..be7311d Binary files /dev/null and b/src/icons/iconmonstr-help-3-icon.png differ diff --git a/src/icons/iconmonstr-inbox-5-icon.png b/src/icons/iconmonstr-inbox-5-icon.png new file mode 100644 index 0000000..0020d63 Binary files /dev/null and b/src/icons/iconmonstr-inbox-5-icon.png differ diff --git a/src/icons/iconmonstr-laptop-3-icon.png b/src/icons/iconmonstr-laptop-3-icon.png new file mode 100644 index 0000000..c3d5e45 Binary files /dev/null and b/src/icons/iconmonstr-laptop-3-icon.png differ diff --git a/src/icons/iconmonstr-license-agreement.pdf b/src/icons/iconmonstr-license-agreement.pdf new file mode 100644 index 0000000..2684aea Binary files /dev/null and b/src/icons/iconmonstr-license-agreement.pdf differ diff --git a/src/icons/iconmonstr-location-10-icon.png b/src/icons/iconmonstr-location-10-icon.png new file mode 100644 index 0000000..0a46044 Binary files /dev/null and b/src/icons/iconmonstr-location-10-icon.png differ diff --git a/src/icons/iconmonstr-location-11-icon.png b/src/icons/iconmonstr-location-11-icon.png new file mode 100644 index 0000000..3360f32 Binary files /dev/null and b/src/icons/iconmonstr-location-11-icon.png differ diff --git a/src/icons/iconmonstr-location-12-icon.png b/src/icons/iconmonstr-location-12-icon.png new file mode 100644 index 0000000..f29a149 Binary files /dev/null and b/src/icons/iconmonstr-location-12-icon.png differ diff --git a/src/icons/iconmonstr-location-13-icon.png b/src/icons/iconmonstr-location-13-icon.png new file mode 100644 index 0000000..c9e93bd Binary files /dev/null and b/src/icons/iconmonstr-location-13-icon.png differ diff --git a/src/icons/iconmonstr-location-14-icon.png b/src/icons/iconmonstr-location-14-icon.png new file mode 100644 index 0000000..4ef861d Binary files /dev/null and b/src/icons/iconmonstr-location-14-icon.png differ diff --git a/src/icons/iconmonstr-location-15-icon.png b/src/icons/iconmonstr-location-15-icon.png new file mode 100644 index 0000000..6bfc9ad Binary files /dev/null and b/src/icons/iconmonstr-location-15-icon.png differ diff --git a/src/icons/iconmonstr-location-16-icon.png b/src/icons/iconmonstr-location-16-icon.png new file mode 100644 index 0000000..002f60c Binary files /dev/null and b/src/icons/iconmonstr-location-16-icon.png differ diff --git a/src/icons/iconmonstr-location-17-icon.png b/src/icons/iconmonstr-location-17-icon.png new file mode 100644 index 0000000..d26c909 Binary files /dev/null and b/src/icons/iconmonstr-location-17-icon.png differ diff --git a/src/icons/iconmonstr-location-18-icon.png b/src/icons/iconmonstr-location-18-icon.png new file mode 100644 index 0000000..4189eba Binary files /dev/null and b/src/icons/iconmonstr-location-18-icon.png differ diff --git a/src/icons/iconmonstr-location-2-icon.svg b/src/icons/iconmonstr-location-2-icon.svg new file mode 100644 index 0000000..6d59a22 --- /dev/null +++ b/src/icons/iconmonstr-location-2-icon.svg @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/src/icons/iconmonstr-location-5-icon.png b/src/icons/iconmonstr-location-5-icon.png new file mode 100644 index 0000000..291ea1c Binary files /dev/null and b/src/icons/iconmonstr-location-5-icon.png differ diff --git a/src/icons/iconmonstr-location-6-icon.png b/src/icons/iconmonstr-location-6-icon.png new file mode 100644 index 0000000..13f4d0e Binary files /dev/null and b/src/icons/iconmonstr-location-6-icon.png differ diff --git a/src/icons/iconmonstr-location-6-icon.svg b/src/icons/iconmonstr-location-6-icon.svg new file mode 100644 index 0000000..a3ce43c --- /dev/null +++ b/src/icons/iconmonstr-location-6-icon.svg @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/src/icons/iconmonstr-location-7-icon.png b/src/icons/iconmonstr-location-7-icon.png new file mode 100644 index 0000000..5e4d69c Binary files /dev/null and b/src/icons/iconmonstr-location-7-icon.png differ diff --git a/src/icons/iconmonstr-location-8-icon.png b/src/icons/iconmonstr-location-8-icon.png new file mode 100644 index 0000000..6a529d7 Binary files /dev/null and b/src/icons/iconmonstr-location-8-icon.png differ diff --git a/src/icons/iconmonstr-location-9-icon.png b/src/icons/iconmonstr-location-9-icon.png new file mode 100644 index 0000000..5307a53 Binary files /dev/null and b/src/icons/iconmonstr-location-9-icon.png differ diff --git a/src/icons/iconmonstr-location-icon.png b/src/icons/iconmonstr-location-icon.png new file mode 100644 index 0000000..1dd8ee4 Binary files /dev/null and b/src/icons/iconmonstr-location-icon.png differ diff --git a/src/icons/iconmonstr-location-icon.svg b/src/icons/iconmonstr-location-icon.svg new file mode 100644 index 0000000..da55e7e --- /dev/null +++ b/src/icons/iconmonstr-location-icon.svg @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/src/icons/iconmonstr-map-2-icon.png b/src/icons/iconmonstr-map-2-icon.png new file mode 100644 index 0000000..05d0657 Binary files /dev/null and b/src/icons/iconmonstr-map-2-icon.png differ diff --git a/src/icons/iconmonstr-map-2-icon.svg b/src/icons/iconmonstr-map-2-icon.svg new file mode 100644 index 0000000..bf02fd6 --- /dev/null +++ b/src/icons/iconmonstr-map-2-icon.svg @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/src/icons/iconmonstr-map-3-icon.png b/src/icons/iconmonstr-map-3-icon.png new file mode 100644 index 0000000..a732fe5 Binary files /dev/null and b/src/icons/iconmonstr-map-3-icon.png differ diff --git a/src/icons/iconmonstr-map-4-icon.png b/src/icons/iconmonstr-map-4-icon.png new file mode 100644 index 0000000..70d43dc Binary files /dev/null and b/src/icons/iconmonstr-map-4-icon.png differ diff --git a/src/icons/iconmonstr-map-5-icon.png b/src/icons/iconmonstr-map-5-icon.png new file mode 100644 index 0000000..2f3e3e6 Binary files /dev/null and b/src/icons/iconmonstr-map-5-icon.png differ diff --git a/src/icons/iconmonstr-map-6-icon.png b/src/icons/iconmonstr-map-6-icon.png new file mode 100644 index 0000000..416a14f Binary files /dev/null and b/src/icons/iconmonstr-map-6-icon.png differ diff --git a/src/icons/iconmonstr-map-icon.png b/src/icons/iconmonstr-map-icon.png new file mode 100644 index 0000000..29ab2ed Binary files /dev/null and b/src/icons/iconmonstr-map-icon.png differ diff --git a/src/icons/iconmonstr-menu-10-icon.png b/src/icons/iconmonstr-menu-10-icon.png new file mode 100644 index 0000000..30a6024 Binary files /dev/null and b/src/icons/iconmonstr-menu-10-icon.png differ diff --git a/src/icons/iconmonstr-menu-2-icon.png b/src/icons/iconmonstr-menu-2-icon.png new file mode 100644 index 0000000..6fdc297 Binary files /dev/null and b/src/icons/iconmonstr-menu-2-icon.png differ diff --git a/src/icons/iconmonstr-menu-3-icon.png b/src/icons/iconmonstr-menu-3-icon.png new file mode 100644 index 0000000..e93856b Binary files /dev/null and b/src/icons/iconmonstr-menu-3-icon.png differ diff --git a/src/icons/iconmonstr-menu-4-icon.png b/src/icons/iconmonstr-menu-4-icon.png new file mode 100644 index 0000000..5419228 Binary files /dev/null and b/src/icons/iconmonstr-menu-4-icon.png differ diff --git a/src/icons/iconmonstr-menu-5-icon.png b/src/icons/iconmonstr-menu-5-icon.png new file mode 100644 index 0000000..902b880 Binary files /dev/null and b/src/icons/iconmonstr-menu-5-icon.png differ diff --git a/src/icons/iconmonstr-menu-6-icon.png b/src/icons/iconmonstr-menu-6-icon.png new file mode 100644 index 0000000..3dc3fe9 Binary files /dev/null and b/src/icons/iconmonstr-menu-6-icon.png differ diff --git a/src/icons/iconmonstr-menu-7-icon.png b/src/icons/iconmonstr-menu-7-icon.png new file mode 100644 index 0000000..c5a1125 Binary files /dev/null and b/src/icons/iconmonstr-menu-7-icon.png differ diff --git a/src/icons/iconmonstr-menu-8-icon.png b/src/icons/iconmonstr-menu-8-icon.png new file mode 100644 index 0000000..8a821e8 Binary files /dev/null and b/src/icons/iconmonstr-menu-8-icon.png differ diff --git a/src/icons/iconmonstr-menu-9-icon.png b/src/icons/iconmonstr-menu-9-icon.png new file mode 100644 index 0000000..1776656 Binary files /dev/null and b/src/icons/iconmonstr-menu-9-icon.png differ diff --git a/src/icons/iconmonstr-menu-icon.png b/src/icons/iconmonstr-menu-icon.png new file mode 100644 index 0000000..87e1bf9 Binary files /dev/null and b/src/icons/iconmonstr-menu-icon.png differ diff --git a/src/icons/iconmonstr-navigation-10-icon.png b/src/icons/iconmonstr-navigation-10-icon.png new file mode 100644 index 0000000..3e96524 Binary files /dev/null and b/src/icons/iconmonstr-navigation-10-icon.png differ diff --git a/src/icons/iconmonstr-navigation-11-icon.png b/src/icons/iconmonstr-navigation-11-icon.png new file mode 100644 index 0000000..7f53647 Binary files /dev/null and b/src/icons/iconmonstr-navigation-11-icon.png differ diff --git a/src/icons/iconmonstr-navigation-12-icon.png b/src/icons/iconmonstr-navigation-12-icon.png new file mode 100644 index 0000000..808926e Binary files /dev/null and b/src/icons/iconmonstr-navigation-12-icon.png differ diff --git a/src/icons/iconmonstr-navigation-13-icon.png b/src/icons/iconmonstr-navigation-13-icon.png new file mode 100644 index 0000000..1c5aa54 Binary files /dev/null and b/src/icons/iconmonstr-navigation-13-icon.png differ diff --git a/src/icons/iconmonstr-navigation-14-icon.png b/src/icons/iconmonstr-navigation-14-icon.png new file mode 100644 index 0000000..227a64d Binary files /dev/null and b/src/icons/iconmonstr-navigation-14-icon.png differ diff --git a/src/icons/iconmonstr-navigation-15-icon.png b/src/icons/iconmonstr-navigation-15-icon.png new file mode 100644 index 0000000..585f74e Binary files /dev/null and b/src/icons/iconmonstr-navigation-15-icon.png differ diff --git a/src/icons/iconmonstr-navigation-2-icon.png b/src/icons/iconmonstr-navigation-2-icon.png new file mode 100644 index 0000000..386ac8d Binary files /dev/null and b/src/icons/iconmonstr-navigation-2-icon.png differ diff --git a/src/icons/iconmonstr-navigation-3-icon.png b/src/icons/iconmonstr-navigation-3-icon.png new file mode 100644 index 0000000..154aecd Binary files /dev/null and b/src/icons/iconmonstr-navigation-3-icon.png differ diff --git a/src/icons/iconmonstr-navigation-4-icon.png b/src/icons/iconmonstr-navigation-4-icon.png new file mode 100644 index 0000000..bb2e13b Binary files /dev/null and b/src/icons/iconmonstr-navigation-4-icon.png differ diff --git a/src/icons/iconmonstr-navigation-5-icon.png b/src/icons/iconmonstr-navigation-5-icon.png new file mode 100644 index 0000000..4c0a13e Binary files /dev/null and b/src/icons/iconmonstr-navigation-5-icon.png differ diff --git a/src/icons/iconmonstr-navigation-6-icon.png b/src/icons/iconmonstr-navigation-6-icon.png new file mode 100644 index 0000000..76eb27d Binary files /dev/null and b/src/icons/iconmonstr-navigation-6-icon.png differ diff --git a/src/icons/iconmonstr-navigation-7-icon.png b/src/icons/iconmonstr-navigation-7-icon.png new file mode 100644 index 0000000..567a7c4 Binary files /dev/null and b/src/icons/iconmonstr-navigation-7-icon.png differ diff --git a/src/icons/iconmonstr-navigation-8-icon.png b/src/icons/iconmonstr-navigation-8-icon.png new file mode 100644 index 0000000..c3ee44e Binary files /dev/null and b/src/icons/iconmonstr-navigation-8-icon.png differ diff --git a/src/icons/iconmonstr-navigation-9-icon.png b/src/icons/iconmonstr-navigation-9-icon.png new file mode 100644 index 0000000..5c59eab Binary files /dev/null and b/src/icons/iconmonstr-navigation-9-icon.png differ diff --git a/src/icons/iconmonstr-navigation-icon.png b/src/icons/iconmonstr-navigation-icon.png new file mode 100644 index 0000000..eb41d82 Binary files /dev/null and b/src/icons/iconmonstr-navigation-icon.png differ diff --git a/src/icons/iconmonstr-network-2-icon.png b/src/icons/iconmonstr-network-2-icon.png new file mode 100644 index 0000000..b407a16 Binary files /dev/null and b/src/icons/iconmonstr-network-2-icon.png differ diff --git a/src/icons/iconmonstr-note-19-icon.png b/src/icons/iconmonstr-note-19-icon.png new file mode 100644 index 0000000..99a56c6 Binary files /dev/null and b/src/icons/iconmonstr-note-19-icon.png differ diff --git a/src/icons/iconmonstr-note-25-icon.png b/src/icons/iconmonstr-note-25-icon.png new file mode 100644 index 0000000..6d1d7b6 Binary files /dev/null and b/src/icons/iconmonstr-note-25-icon.png differ diff --git a/src/icons/iconmonstr-note-26-icon.png b/src/icons/iconmonstr-note-26-icon.png new file mode 100644 index 0000000..151fdb3 Binary files /dev/null and b/src/icons/iconmonstr-note-26-icon.png differ diff --git a/src/icons/iconmonstr-note-27-icon.png b/src/icons/iconmonstr-note-27-icon.png new file mode 100644 index 0000000..525becb Binary files /dev/null and b/src/icons/iconmonstr-note-27-icon.png differ diff --git a/src/icons/iconmonstr-note-29-icon.png b/src/icons/iconmonstr-note-29-icon.png new file mode 100644 index 0000000..509b311 Binary files /dev/null and b/src/icons/iconmonstr-note-29-icon.png differ diff --git a/src/icons/iconmonstr-thumb-10-icon.png b/src/icons/iconmonstr-thumb-10-icon.png new file mode 100644 index 0000000..28b8461 Binary files /dev/null and b/src/icons/iconmonstr-thumb-10-icon.png differ diff --git a/src/icons/iconmonstr-thumb-11-icon.png b/src/icons/iconmonstr-thumb-11-icon.png new file mode 100644 index 0000000..9e5d29d Binary files /dev/null and b/src/icons/iconmonstr-thumb-11-icon.png differ diff --git a/src/icons/iconmonstr-thumb-12-icon.png b/src/icons/iconmonstr-thumb-12-icon.png new file mode 100644 index 0000000..4087396 Binary files /dev/null and b/src/icons/iconmonstr-thumb-12-icon.png differ diff --git a/src/icons/iconmonstr-thumb-13-icon.png b/src/icons/iconmonstr-thumb-13-icon.png new file mode 100644 index 0000000..68dbe20 Binary files /dev/null and b/src/icons/iconmonstr-thumb-13-icon.png differ diff --git a/src/icons/iconmonstr-thumb-14-icon.png b/src/icons/iconmonstr-thumb-14-icon.png new file mode 100644 index 0000000..5889d00 Binary files /dev/null and b/src/icons/iconmonstr-thumb-14-icon.png differ diff --git a/src/icons/iconmonstr-thumb-16-icon.png b/src/icons/iconmonstr-thumb-16-icon.png new file mode 100644 index 0000000..11b8106 Binary files /dev/null and b/src/icons/iconmonstr-thumb-16-icon.png differ diff --git a/src/icons/iconmonstr-thumb-17-icon.png b/src/icons/iconmonstr-thumb-17-icon.png new file mode 100644 index 0000000..710537b Binary files /dev/null and b/src/icons/iconmonstr-thumb-17-icon.png differ diff --git a/src/icons/iconmonstr-thumb-9-icon.png b/src/icons/iconmonstr-thumb-9-icon.png new file mode 100644 index 0000000..a9132f0 Binary files /dev/null and b/src/icons/iconmonstr-thumb-9-icon.png differ diff --git a/src/icons/iconmonstr-webcam-3-icon.png b/src/icons/iconmonstr-webcam-3-icon.png new file mode 100644 index 0000000..17af879 Binary files /dev/null and b/src/icons/iconmonstr-webcam-3-icon.png differ