initial commit of version 2

This commit is contained in:
Andreas Billmann
2015-03-23 21:50:58 +01:00
commit 6a4c1ace4f
58 changed files with 5327 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) Andreas Billmann <abi@geofroggerfx.de>
* 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.geofroggerfx.ui;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import java.io.IOException;
import java.io.InputStream;
import java.util.ResourceBundle;
public abstract class FXMLController implements InitializingBean, Initializable {
protected Node view;
protected String fxmlFilePath;
protected String resourcePath;
public abstract void setFxmlFilePath(String filePath);
@Value("${resource.main}")
public void setResourceBundle(String resourcePath) {
this.resourcePath = resourcePath;
}
@Override
public void afterPropertiesSet() throws Exception {
loadFXML();
}
protected final void loadFXML() throws IOException {
try (InputStream fxmlStream = getClass().getResourceAsStream(fxmlFilePath)) {
FXMLLoader loader = new FXMLLoader();
loader.setResources(ResourceBundle.getBundle(this.resourcePath));
loader.setController(this);
this.view = (loader.load(fxmlStream));
} catch (Throwable t) {
t.printStackTrace();
}
}
public Node getView() {
return view;
}
}

View File

@@ -0,0 +1,98 @@
/*
* Copyright (c) Andreas Billmann <abi@geofroggerfx.de>
* 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.geofroggerfx.ui;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.text.Font;
import javafx.stage.Stage;
//import org.scenicview.ScenicView;
import org.springframework.context.annotation.*;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Configuration
@ComponentScan("de.geofroggerfx")
@PropertySource(value = "classpath:/de/geofroggerfx/ui/application.properties")
public class GeoFroggerFX extends Application {
private AnnotationConfigApplicationContext appContext;
@Override
public void start(Stage primaryStage) throws Exception {
loadCustomFonts();
appContext = new AnnotationConfigApplicationContext(GeoFroggerFX.class);
String name = appContext.getEnvironment().getProperty("application.name");
String version = appContext.getEnvironment().getProperty("application.version");
GeoFroggerFXController geoFroggerFXController = appContext.getBean(GeoFroggerFXController.class);
Scene scene = new Scene((Parent) geoFroggerFXController.getView());
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if (isScenicViewShortcutPressed(event)) {
// ScenicView.show(scene);
}
}
});
primaryStage.setScene(scene);
primaryStage.setTitle(String.format("%s %s", name, version));
primaryStage.show();
}
@Bean
public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
@Override
public void stop() throws Exception {
if (appContext != null) {
appContext.close();
}
super.stop();
}
public static void main(String[] args) {
launch(args);
}
private static boolean isScenicViewShortcutPressed(final KeyEvent keyEvent) {
return keyEvent.isAltDown() && keyEvent.isControlDown() && keyEvent.getCode().equals(KeyCode.V);
}
private void loadCustomFonts() {
Font.loadFont(GeoFroggerFX.class.getResource("/fonts/sofia/Sofia-Regular.otf").toExternalForm(), 24);
}
}

View File

@@ -0,0 +1,283 @@
/*
* Copyright (c) Andreas Billmann <abi@geofroggerfx.de>
* 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.geofroggerfx.ui;
import de.geofroggerfx.application.ProgressEvent;
import de.geofroggerfx.application.SessionContext;
import de.geofroggerfx.gpx.GPXReader;
import de.geofroggerfx.model.Cache;
import de.geofroggerfx.model.CacheListEntry;
import de.geofroggerfx.plugins.Plugin;
import de.geofroggerfx.service.CacheService;
import de.geofroggerfx.service.PluginService;
import de.geofroggerfx.ui.details.DetailsController;
import de.geofroggerfx.ui.list.ListController;
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.scene.control.*;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.stage.FileChooser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import static de.geofroggerfx.application.SessionContext.*;
/**
* Created by Andreas on 09.03.2015.
*/
@Component
public class GeoFroggerFXController extends FXMLController {
private static final Logger LOGGER = Logger.getLogger(GeoFroggerFXController.class.getName());
@Autowired
private CacheService cacheService;
@Autowired
private SessionContext sessionContext;
@Autowired
private ListController listController;
@Autowired
private DetailsController detailsController;
@Autowired
private PluginService pluginService;
@Autowired
private GPXReader reader;
@FXML
private HBox cacheListContent;
@FXML
private AnchorPane cacheDetailsContent;
@FXML
private Label leftStatus;
@FXML
private ProgressBar progress;
@FXML
private Menu pluginsMenu;
private ResourceBundle resourceBundle;
private final LoadCachesFromFileService loadService = new LoadCachesFromFileService();
private final LoadCacheListsFromDatabaseService loadListsFromDBService = new LoadCacheListsFromDatabaseService();
@Value("${fxml.geofrogger.view}")
@Override
public void setFxmlFilePath(String filePath) {
this.fxmlFilePath = filePath;
}
@Override
public void initialize(URL location, ResourceBundle resources) {
this.resourceBundle = resources;
LOGGER.info("load all sub controller");
cacheListContent.getChildren().add(listController.getView());
cacheDetailsContent.getChildren().add(detailsController.getView());
LOGGER.info("add listeners");
reader.addListener((ProgressEvent event) -> updateStatus(event.getMessage(), event.getProgress()));
loadListsFromDBService.start();
List<Plugin> plugins = pluginService.getAllPlugins();
for (Plugin plugin: plugins) {
MenuItem menuItem = new MenuItem(plugin.getName()+" ("+plugin.getVersion()+")");
menuItem.setOnAction(actionEvent -> pluginService.executePlugin(plugin));
pluginsMenu.getItems().add(menuItem);
}
}
@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, resourceBundle.getString("dialog.title.about"));
// dialog.setMasthead(MASTHEAD_TEXT);
// dialog.setContent(ABOUT_TEXT);
// dialog.setExpandableContent(new TextArea(LICENSE));
// dialog.show();
}
@FXML
public void showSettings(ActionEvent actionEvent) {
// mainPane.setCenter();
// FXMLLoader.load()
}
@FXML
public void newList(ActionEvent actionEvent) {
// final Optional<String> listNameOption = Dialogs.
// create().
// title(resourceBundle.getString("dialog.title.new_list")).
// message(resourceBundle.getString("dialog.label.listname")).
// showTextInput();
// if (hasValue(listNameOption)) {
// final String listName = listNameOption.get().trim();
// if (cacheService.doesCacheListNameExist(listName)) {
// Dialogs.
// create().
// message(resourceBundle.getString("dialog.msg.list.does.exist")).
// showError();
// } else {
// CacheList list = new CacheList();
// list.setName(listName);
// cacheService.storeCacheList(list);
// setCacheListInContext();
// }
// }
}
@FXML
public void deleteList(ActionEvent actionEvent) {
// final Optional<CacheList> listOption = Dialogs.
// create().
// title("dialog.title.delete_list").
// message("dialog.label.listname").
// showChoices(cacheService.getAllCacheLists());
//
// if (listOption.isPresent()) {
// cacheService.deleteCacheList(listOption.get());
// setCacheListInContext();
// }
}
@FXML
public void exit(ActionEvent actionEvent) {
Platform.exit();
}
private void updateStatus(String text, double progressValue) {
Platform.runLater(() -> {
leftStatus.setText(text);
progress.setProgress(progressValue);
});
}
private class LoadCachesFromFileService extends Service {
private final ObjectProperty<File> file = new SimpleObjectProperty();
public final void setFile(File value) {
file.set(value);
}
public final File getFile() {
return file.get();
}
public final ObjectProperty<File> fileProperty() {
return file;
}
@Override
protected Task createTask() {
return new Task() {
@Override
protected Void call() throws Exception {
try {
LOGGER.info("load from file "+file.get().getAbsolutePath());
final List<Cache> cacheList = reader.load(file.get());
LOGGER.info(cacheList.size()+" caches loaded");
if (!cacheList.isEmpty()) {
updateStatus(resourceBundle.getString("status.store.all.caches"), ProgressIndicator.INDETERMINATE_PROGRESS);
cacheService.storeCaches(cacheList);
updateStatus(resourceBundle.getString("status.all.caches.stored"), 0);
LOGGER.info("caches stored in database");
loadAllCacheEntries();
}
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, ex.getMessage() ,ex);
}
return null;
}
};
}
}
private class LoadCacheListsFromDatabaseService extends Service {
@Override
protected Task createTask() {
return new Task() {
@Override
protected Void call() throws Exception {
loadAllCacheEntries();
return null;
}
};
}
}
private void loadAllCacheEntries() {
updateStatus(resourceBundle.getString("status.load.caches.from.db"), ProgressIndicator.INDETERMINATE_PROGRESS);
sessionContext.setData(CACHE_ENTRY_LIST, cacheService.getAllCacheEntriesSortBy("name", "asc"));
updateStatus(resourceBundle.getString("status.all.caches.loaded"), 0);
}
}

View File

@@ -0,0 +1,334 @@
/*
* Copyright (c) Andreas Billmann <abi@geofroggerfx.de>
* 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.geofroggerfx.ui;
import de.geofroggerfx.model.Attribute;
import de.geofroggerfx.model.Type;
import de.jensd.fx.glyphs.GlyphIcon;
import de.jensd.fx.glyphs.GlyphIcons;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcons;
import javafx.scene.text.Text;
import java.util.HashMap;
import java.util.Map;
import static de.geofroggerfx.model.Attribute.*;
import static de.geofroggerfx.model.Type.*;
import static de.geofroggerfx.ui.glyphs.GeofroggerGlyphsDude.createIcon;
import static de.jensd.fx.glyphs.fontawesome.FontAwesomeIcons.*;
import static de.jensd.fx.glyphs.weathericons.WeatherIcons.*;
/**
* @author Andreas
*/
public class GeocachingIcons {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cache attribute
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private static final Map<Attribute, GlyphIcons> attributeMap;
static {
attributeMap = new HashMap<>();
attributeMap.put(DOGS_TRUE, PAW);
attributeMap.put(DOGS_FALSE, PAW);
// attributeMap.put(ACCESS_OR_PARKING_FEE_TRUE,);
// attributeMap.put(ACCESS_OR_PARKING_FEE_FALSE, );
// attributeMap.put(CLIMBING_GEAR_TRUE,);
// attributeMap.put(CLIMBING_GEAR_FALSE,);
attributeMap.put(BOAT_TRUE, SHIP);
attributeMap.put(BOAT_FALSE, SHIP);
// attributeMap.put(SCUBA_GEAR_TRUE(5);
// attributeMap.put(SCUBA_GEAR_FALSE(-5);
attributeMap.put(RECOMMENDED_FOR_KIDS_TRUE, CHILD);
attributeMap.put(RECOMMENDED_FOR_KIDS_FALSE, CHILD);
attributeMap.put(TAKES_LESS_THAN_AN_HOUR_TRUE, TIME_1);
attributeMap.put(TAKES_LESS_THAN_AN_HOUR_FALSE, TIME_1);
attributeMap.put(SCENIC_VIEW_TRUE, EYE);
attributeMap.put(SCENIC_VIEW_FALSE, EYE);
// attributeMap.put(SIGNIFICANT_HIKE_TRUE(9);
// attributeMap.put(SIGNIFICANT_HIKE_FALSE(-9);
// attributeMap.put(DIFFICULT_CLIMBING_TRUE(10);
// attributeMap.put(DIFFICULT_CLIMBING_FALSE(-10);
// attributeMap.put(MAY_REQUIRE_WADING_TRUE(11);
// attributeMap.put(MAY_REQUIRE_WADING_FALSE(-11);
// attributeMap.put(MAY_REQUIRE_SWIMMING_TRUE(12);
// attributeMap.put(MAY_REQUIRE_SWIMMING_FALSE(-12);
attributeMap.put(AVAILABLE_AT_ALL_TIMES_TRUE, TIME_12);
attributeMap.put(AVAILABLE_AT_ALL_TIMES_FALSE, TIME_12);
attributeMap.put(RECOMMENDED_AT_NIGHT_TRUE, MOON_ALT);
attributeMap.put(RECOMMENDED_AT_NIGHT_FALSE, MOON_ALT);
attributeMap.put(AVAILABLE_DURING_WINTER_TRUE, SNOW);
attributeMap.put(AVAILABLE_DURING_WINTER_FALSE, SNOW);
// attributeMap.put(POISON_PLANTS_TRUE(17);
// attributeMap.put(POISON_PLANTS_FALSE(-17);
// attributeMap.put(DANGEROUS_ANIMALS_TRUE(18);
// attributeMap.put(DANGEROUS_ANIMALS_FALSE(-18);
// attributeMap.put(TICKS_TRUE(19);
// attributeMap.put(TICKS_FALSE(-19);
// attributeMap.put(ABANDONED_MINES_TRUE(20);
// attributeMap.put(ABANDONED_MINES_FALSE(-20);
attributeMap.put(CLIFF_FALLING_ROCKS_TRUE, METEOR);
attributeMap.put(CLIFF_FALLING_ROCKS_FALSE, METEOR);
// attributeMap.put(HUNTING_TRUE(22);
// attributeMap.put(HUNTING_FALSE(-22);
// attributeMap.put(DANGEROUS_AREA_TRUE(23);
// attributeMap.put(DANGEROUS_AREA_FALSE(-23);
attributeMap.put(WHEELCHAIR_ACCESSIBLE_TRUE, WHEELCHAIR);
attributeMap.put(WHEELCHAIR_ACCESSIBLE_FALSE, WHEELCHAIR);
// attributeMap.put(PARKING_AVAILABLE_TRUE(25);
// attributeMap.put(PARKING_AVAILABLE_FALSE(-25);
attributeMap.put(PUBLIC_TRANSPORTATION_TRUE, BUS);
attributeMap.put(PUBLIC_TRANSPORTATION_FALSE, BUS);
// attributeMap.put(DRINKING_WATER_NEARBY_TRUE(27);
// attributeMap.put(DRINKING_WATER_NEARBY_FALSE(-27);
// attributeMap.put(PUBLIC_RESTROOMS_NEARBY_TRUE(28);
// attributeMap.put(PUBLIC_RESTROOMS_NEARBY_FALSE(-28);
attributeMap.put(TELEPHONE_NEARBY_TRUE, PHONE);
attributeMap.put(TELEPHONE_NEARBY_FALSE, PHONE);
// attributeMap.put(PICNIC_TABLES_NEARBY_TRUE(30);
// attributeMap.put(PICNIC_TABLES_NEARBY_FALSE(-30);
// attributeMap.put(CAMPING_AVAILABLE_TRUE(31);
// attributeMap.put(CAMPING_AVAILABLE_FALSE(-31);
attributeMap.put(BICYCLES_TRUE, BICYCLE);
attributeMap.put(BICYCLES_FALSE, BICYCLE);
attributeMap.put(MOTORCYCLES_TRUE, MOTORCYCLE);
attributeMap.put(MOTORCYCLES_FALSE, MOTORCYCLE);
// attributeMap.put(QUADS_TRUE(34);
// attributeMap.put(QUADS_FALSE(-34);
// attributeMap.put(OFF_ROAD_VEHICLES_TRUE(35);
// attributeMap.put(OFF_ROAD_VEHICLES_FALSE(-35);
// attributeMap.put(SNOWMOBILES_TRUE(36);
// attributeMap.put(SNOWMOBILES_FALSE(-36);
// attributeMap.put(HORSES_TRUE(37);
// attributeMap.put(HORSES_FALSE(-37);
// attributeMap.put(CAMPFIRES_TRUE(38);
// attributeMap.put(CAMPFIRES_FALSE(-38);
// attributeMap.put(THORNS_TRUE(39);
// attributeMap.put(THORNS_FALSE(-39);
// attributeMap.put(STEALTH_REQUIRED_TRUE(40);
// attributeMap.put(STEALTH_REQUIRED_FALSE(-40);
// attributeMap.put(STROLLER_ACCESSIBLE_TRUE(41);
// attributeMap.put(STROLLER_ACCESSIBLE_FALSE(-41);
// attributeMap.put(WATCH_FOR_LIVESTOCK_TRUE(43);
// attributeMap.put(WATCH_FOR_LIVESTOCK_FALSE(-43);
// attributeMap.put(NEEDS_MAINTENANCE_TRUE(42);
// attributeMap.put(NEEDS_MAINTENANCE_FALSE(-42);
// attributeMap.put(FLASHLIGHT_REQUIRED_TRUE(44);
// attributeMap.put(FLASHLIGHT_REQUIRED_FALSE(-44);
// attributeMap.put(LOST_AND_FOUND_TOUR_TRUE(45);
// attributeMap.put(LOST_AND_FOUND_TOUR_FALSE(-45);
// attributeMap.put(TRUCK_DRIVER_RV_TRUE(46);
// attributeMap.put(TRUCK_DRIVER_RV_FALSE(-46);
// attributeMap.put(FIELD_PUZZLE_TRUE(47);
// attributeMap.put(FIELD_PUZZLE_FALSE(-47);
// attributeMap.put(UV_LIGHT_REQUIRED_TRUE(48);
// attributeMap.put(UV_LIGHT_REQUIRED_FALSE(-48);
// attributeMap.put(SNOWSHOES_TRUE(49);
// attributeMap.put(SNOWSHOES_FALSE(-49);
// attributeMap.put(CROSS_COUNTRY_SKIS_TRUE(50);
// attributeMap.put(CROSS_COUNTRY_SKIS_FALSE(-50);
// attributeMap.put(SPECIAL_TOOL_REQUIRED_TRUE(51);
// attributeMap.put(SPECIAL_TOOL_REQUIRED_FALSE(-51);
attributeMap.put(NIGHT_CACHE_TRUE, MOON_WANING_CRESCENT_2);
attributeMap.put(NIGHT_CACHE_FALSE, MOON_WANING_CRESCENT_2);
// attributeMap.put(PARK_AND_GRAB_TRUE(53);
// attributeMap.put(PARK_AND_GRAB_FALSE(-53);
// attributeMap.put(ABANDONED_STRUCTURE_TRUE(54);
// attributeMap.put(ABANDONED_STRUCTURE_FALSE(-54);
// attributeMap.put(SHORT_HIKE_LESS_THAN_1KM_TRUE(55);
// attributeMap.put(SHORT_HIKE_LESS_THAN_1KM_FALSE(-55);
// attributeMap.put(MEDIUM_HIKE_1KM_10KM_TRUE(56);
// attributeMap.put(MEDIUM_HIKE_1KM_10KM_FALSE(-56);
// attributeMap.put(LONG_HIKE_10KM_TRUE(57);
// attributeMap.put(LONG_HIKE_10KM_FALSE(-57);
// attributeMap.put(FUEL_NEARBY_TRUE(58);
// attributeMap.put(FUEL_NEARBY_FALSE(-58);
// attributeMap.put(FOOD_NEARBY_TRUE(59);
// attributeMap.put(FOOD_NEARBY_FALSE(-59);
// attributeMap.put(WIRELESS_BEACON_TRUE(60);
// attributeMap.put(WIRELESS_BEACON_FALSE(-60);
// attributeMap.put(PARTNERSHIP_CACHE_TRUE(61);
// attributeMap.put(PARTNERSHIP_CACHE_FALSE(-61);
attributeMap.put(SEASONAL_ACCESS_TRUE, THERMOMETER);
attributeMap.put(SEASONAL_ACCESS_FALSE, THERMOMETER);
// attributeMap.put(TOURIST_FRIENDLY_TRUE(63);
// attributeMap.put(TOURIST_FRIENDLY_FALSE(-63);
// attributeMap.put(TREE_CLIMBING_TRUE(64);
// attributeMap.put(TREE_CLIMBING_FALSE(-64);
// attributeMap.put(FRONT_YARD_PRIVATE_RESIDENCE_TRUE(65);
// attributeMap.put(FRONT_YARD_PRIVATE_RESIDENCE_FALSE(-65);
// attributeMap.put(TEAMWORK_REQUIRED_TRUE(66);
// attributeMap.put(TEAMWORK_REQUIRED_FALSE(-66);
// attributeMap.put(GEOTOUR_TRUE(67);
// attributeMap.put(GEOTOUR_FALSE(-67);
}
public static Text getIconAsText(Attribute attribute, String iconSize) {
return createIcon(getIcon(attribute), iconSize);
}
public static Text getIconAsText(Attribute attribute) {
return getIconAsText(attribute, GlyphIcon.DEFAULT_ICON_SIZE);
}
public static String getIconAsString(Attribute attribute) {
return getIcon(attribute).characterToString();
}
public static GlyphIcons getIcon(Attribute attribute) {
GlyphIcons iconName = attributeMap.get(attribute);
if (iconName == null) {
iconName = FontAwesomeIcons.BLANK;
}
return iconName;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cache type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private static final Map<Type, GlyphIcons> typeMap;
static {
typeMap = new HashMap<>();
typeMap.put(MULTI_CACHE, TAGS);
typeMap.put(TRADITIONAL_CACHE, TAG);
typeMap.put(UNKNOWN_CACHE, QUESTION);
typeMap.put(EARTH_CACHE, GLOBE);
typeMap.put(LETTERBOX, ENVELOPE);
typeMap.put(EVENT, CALENDAR);
typeMap.put(CITO_EVENT, CALENDAR);
typeMap.put(MEGA_EVENT, CALENDAR);
typeMap.put(WHERIGO, COMPASS);
typeMap.put(WEBCAM_CACHE, CAMERA);
typeMap.put(VIRTUAL_CACHE, LAPTOP);
}
public static Text getIconAsText(Type type, String iconSize) {
return createIcon(getIcon(type), iconSize);
}
public static Text getIconAsText(Type type) {
return getIconAsText(type, GlyphIcon.DEFAULT_ICON_SIZE);
}
public static String getIconAsString(Type type) {
return getIcon(type).characterToString();
}
public static GlyphIcons getIcon(Type type) {
GlyphIcons iconName = typeMap.get(type);
if (iconName == null) {
iconName = FontAwesomeIcons.BLANK;
}
return iconName;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// star icon
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static Text getStars(String value) {
return getStarsAsText(value, GlyphIcon.DEFAULT_ICON_SIZE);
}
public static String getStarsAsString(String value) {
StringBuffer stringBuffer = new StringBuffer();
switch (value) {
case "1":
stringBuffer.append(STAR.characterToString());
break;
case "1.5":
stringBuffer.append(STAR.characterToString())
.append(STAR_HALF.characterToString());
break;
case "2":
stringBuffer.append(STAR.characterToString())
.append(STAR.characterToString());
break;
case "2.5":
stringBuffer.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR_HALF.characterToString());
break;
case "3":
stringBuffer.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR.characterToString());
break;
case "3.5":
stringBuffer.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR_HALF.characterToString());
break;
case "4":
stringBuffer.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR.characterToString());
break;
case "4.5":
stringBuffer.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR_HALF.characterToString());
break;
case "5":
stringBuffer.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR.characterToString())
.append(STAR.characterToString());
break;
default:
stringBuffer.append(FontAwesomeIcons.BLANK.characterToString());
System.out.println(value);
}
return stringBuffer.toString();
}
public static Text getStarsAsText(String value, String iconSize) {
Text text = createIcon(FontAwesomeIcons.BLANK, iconSize);
text.setText(value);
return text;
}
}

View File

@@ -0,0 +1,158 @@
/*
* Copyright (c) Andreas Billmann <abi@geofroggerfx.de>
* 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.geofroggerfx.ui.details;
import com.lynden.gmapsfx.GoogleMapView;
import com.lynden.gmapsfx.MapComponentInitializedListener;
import com.lynden.gmapsfx.javascript.object.*;
import de.geofroggerfx.application.SessionContext;
import de.geofroggerfx.application.SessionContextListener;
import de.geofroggerfx.model.Cache;
import de.geofroggerfx.ui.FXMLController;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.net.URL;
import java.util.ResourceBundle;
import static de.geofroggerfx.application.SessionContext.CURRENT_CACHE;
import static de.geofroggerfx.ui.GeocachingIcons.getStarsAsString;
/**
* Created by Andreas on 09.03.2015.
*/
@Component
public class DetailsController extends FXMLController {
@Autowired
private SessionContext sessionContext;
@FXML
private Label cacheName;
@FXML
private Text cacheDifficulty;
@FXML
private Text cacheTerrain;
@FXML
private VBox mainContent;
@FXML
private WebView description;
@FXML
private GoogleMapView mapView;
private GoogleMap map;
private Marker marker;
@Value("${fxml.geofrogger.details.view}")
@Override
public void setFxmlFilePath(String filePath) {
this.fxmlFilePath = filePath;
}
@Override
public void initialize(URL location, ResourceBundle resources) {
sessionContext.addListener(CURRENT_CACHE, new SessionContextListener() {
@Override
public void sessionContextChanged() {
fillContent();
}
});
mapView.addMapInializedListener(new MapComponentInitializedListener() {
@Override
public void mapInitialized() {
//Set the initial properties of the map.
MapOptions mapOptions = new MapOptions();
mapOptions.center(new LatLong(47.6097, -122.3331))
.mapType(MapTypeIdEnum.ROADMAP)
.overviewMapControl(false)
.panControl(false)
.rotateControl(false)
.scaleControl(false)
.streetViewControl(false)
.zoomControl(false)
.zoom(12);
map = mapView.createMap(mapOptions);
LatLong latLong = new LatLong(49.045458, 9.189835);
MarkerOptions options = new MarkerOptions();
options.position(latLong);
marker = new Marker(options);
map.addMarker(marker);
map.setCenter(latLong);
}
});
}
private void fillContent() {
Cache cache = (Cache) sessionContext.getData(CURRENT_CACHE);
cacheName.setText(cache.getName());
cacheDifficulty.setText(getStarsAsString(cache.getDifficulty()));
cacheTerrain.setText(getStarsAsString(cache.getTerrain()));
String shortDescription = cache.getShortDescription();
if (!cache.getLongDescriptionHtml()) {
shortDescription = shortDescription.replaceAll("\n","</br>");
}
String longDescription = cache.getLongDescription();
if (!cache.getLongDescriptionHtml()) {
longDescription = longDescription.replaceAll("\n","</br>");
}
String description = "<html><body><p>"+shortDescription+"</p><p>"+longDescription+"</p></body></html>";
final WebEngine webEngine = this.description.getEngine();
webEngine.loadContent(description);
LatLong latLong = new LatLong(cache.getMainWayPoint().getLatitude(), cache.getMainWayPoint().getLongitude());
MarkerOptions options = new MarkerOptions();
options.position(latLong);
options.title(cache.getMainWayPoint().getName());
map.removeMarker(marker);
marker.setTitle(cache.getMainWayPoint().getName());
marker = new Marker(options);
map.addMarker(marker);
map.setCenter(latLong);
mapView.requestLayout();
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) Andreas Billmann <abi@geofroggerfx.de>
* 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.geofroggerfx.ui.glyphs;
import de.jensd.fx.glyphs.GlyphIcon;
import javafx.scene.text.Font;
public class ElusiveIcon extends GlyphIcon<ElusiveIcons> {
public final static String TTF_PATH = "/fonts/elusive/Elusive-Icons.ttf";
public final static String FONT_FAMILY = "\'Elusive-Icons\'";
static {
Font.loadFont(ElusiveIcon.class.getResource(TTF_PATH).toExternalForm(), 10.0);
}
@Override
public ElusiveIcons getDefaultGlyph() {
return ElusiveIcons.USER;
}
}

View File

@@ -0,0 +1,359 @@
/*
* Copyright (c) Andreas Billmann <abi@geofroggerfx.de>
* 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.geofroggerfx.ui.glyphs;
import de.jensd.fx.glyphs.GlyphIcons;
public enum ElusiveIcons implements GlyphIcons {
ZOOM_OUT('\uE600'),
ZOOM_IN('\uE601'),
YOUTUBE('\uE602'),
WRENCH_ALT('\uE603'),
WRENCH('\uE604'),
WORDPRESS('\uE605'),
WHEELCHAIR('\uE606'),
WEBSITE_ALT('\uE607'),
WEBSITE('\uE608'),
WARNING_SIGN('\uE609'),
W3C('\uE60A'),
VOLUME_UP('\uE60B'),
VOLUME_OFF('\uE60C'),
VOLUME_DOWN('\uE60D'),
VKONTAKTE('\uE60E'),
VIMEO('\uE60F'),
VIEW_MODE('\uE610'),
VIDEO_CHAT('\uE611'),
VIDEO_ALT('\uE612'),
VIDEO('\uE613'),
VIADEO('\uE614'),
USER('\uE615'),
USD('\uE616'),
UPLOAD('\uE617'),
UNLOCK_ALT('\uE618'),
UNLOCK('\uE619'),
UNIVERSAL_ACCESS('\uE61A'),
TWITTER('\uE61B'),
TUMBLR('\uE61C'),
TRASH_ALT('\uE61D'),
TRASH('\uE61E'),
TORSO('\uE61F'),
TINT('\uE620'),
TIME_ALT('\uE621'),
TIME('\uE622'),
THUMBS_UP('\uE623'),
THUMBS_DOWN('\uE624'),
TH_LIST('\uE625'),
TH_LARGE('\uE626'),
TH('\uE627'),
TEXT_WIDTH('\uE628'),
TEXT_HEIGHT('\uE629'),
TASKS('\uE62A'),
TAGS('\uE62B'),
TAG('\uE62C'),
STUMBLEUPON('\uE62D'),
STOP_ALT('\uE62E'),
STOP('\uE62F'),
STEP_FORWARD('\uE630'),
STEP_BACKWARD('\uE631'),
STAR_EMPTY('\uE632'),
STAR_ALT('\uE633'),
STAR('\uE634'),
STACKOVERFLOW('\uE635'),
SPOTIFY('\uE636'),
SPEAKER('\uE637'),
SOUNDCLOUD('\uE638'),
SMILEY_ALT('\uE639'),
SMILEY('\uE63A'),
SLIDESHARE('\uE63B'),
SKYPE('\uE63C'),
SIGNAL('\uE63D'),
SHOPPING_CART_SIGN('\uE63E'),
SHOPPING_CART('\uE63F'),
SHARE_ALT('\uE640'),
SHARE('\uE641'),
SEARCH_ALT('\uE642'),
SEARCH('\uE643'),
SCREENSHOT('\uE644'),
SCREEN_ALT('\uE645'),
SCREEN('\uE646'),
SCISSORS('\uE647'),
RSS('\uE648'),
ROAD('\uE649'),
REVERSE_ALT('\uE64A'),
RETWEET('\uE64B'),
RETURN_KEY('\uE64C'),
RESIZE_VERTICAL('\uE64D'),
RESIZE_SMALL('\uE64E'),
RESIZE_HORIZONTAL('\uE64F'),
RESIZE_FULL('\uE650'),
REPEAT_ALT('\uE651'),
REPEAT('\uE652'),
REMOVE_SIGN('\uE653'),
REMOVE_CIRCLE('\uE654'),
REMOVE('\uE655'),
REFRESH('\uE656'),
REDDIT('\uE657'),
RECORD('\uE658'),
RANDOM('\uE659'),
QUOTES_ALT('\uE65A'),
QUOTES('\uE65B'),
QUESTION_SIGN('\uE65C'),
QUESTION('\uE65D'),
QRCODE('\uE65E'),
PUZZLE('\uE65F'),
PRINT('\uE660'),
PODCAST('\uE661'),
PLUS_SIGN('\uE662'),
PLUS('\uE663'),
PLAY_CIRCLE('\uE664'),
PLAY_ALT('\uE665'),
PLAY('\uE666'),
PLANE('\uE667'),
PINTEREST('\uE668'),
PICTURE('\uE669'),
PICASA('\uE66A'),
PHOTO_ALT('\uE66B'),
PHOTO('\uE66C'),
PHONE_ALT('\uE66D'),
PHONE('\uE66E'),
PERSON('\uE66F'),
PENCIL_ALT('\uE670'),
PENCIL('\uE671'),
PAUSE_ALT('\uE672'),
PAUSE('\uE673'),
PATH('\uE674'),
PAPER_CLIP_ALT('\uE675'),
PAPER_CLIP('\uE676'),
OPENSOURCE('\uE677'),
OK_SIGN('\uE678'),
OK_CIRCLE('\uE679'),
OK('\uE67A'),
OFF('\uE67B'),
NETWORK('\uE67C'),
MYSPACE('\uE67D'),
MUSIC('\uE67E'),
MOVE('\uE67F'),
MINUS_SIGN('\uE680'),
MINUS('\uE681'),
MIC_ALT('\uE682'),
MIC('\uE683'),
MAP_MARKER_ALT('\uE684'),
MAP_MARKER('\uE685'),
MALE('\uE686'),
MAGNET('\uE687'),
MAGIC('\uE688'),
LOCK_ALT('\uE689'),
LOCK('\uE68A'),
LIVEJOURNAL('\uE68B'),
LIST_ALT('\uE68C'),
LIST('\uE68D'),
LINKEDIN('\uE68E'),
LINK('\uE68F'),
LINES('\uE690'),
LEAF('\uE691'),
LASTFM('\uE692'),
LAPTOP_ALT('\uE693'),
LAPTOP('\uE694'),
KEY('\uE695'),
ITALIC('\uE696'),
IPHONE_HOME('\uE697'),
INSTAGRAM('\uE698'),
INFO_SIGN('\uE699'),
INDENT_RIGHT('\uE69A'),
INDENT_LEFT('\uE69B'),
INBOX_BOX('\uE69C'),
INBOX_ALT('\uE69D'),
INBOX('\uE69E'),
IDEA_ALT('\uE69F'),
IDEA('\uE6A0'),
HOURGLASS('\uE6A1'),
HOME_ALT('\uE6A2'),
HOME('\uE6A3'),
HEART_EMPTY('\uE6A4'),
HEART_ALT('\uE6A5'),
HEART('\uE6A6'),
HEARING_IMPAIRED('\uE6A7'),
HEADPHONES('\uE6A8'),
HDD('\uE6A9'),
HAND_UP('\uE6AA'),
HAND_RIGHT('\uE6AB'),
HAND_LEFT('\uE6AC'),
HAND_DOWN('\uE6AD'),
GUIDEDOG('\uE6AE'),
GROUP_ALT('\uE6AF'),
GROUP('\uE6B0'),
GRAPH_ALT('\uE6B1'),
GRAPH('\uE6B2'),
GOOGLEPLUS('\uE6B3'),
GLOBE_ALT('\uE6B4'),
GLOBE('\uE6B5'),
GLASSES('\uE6B6'),
GLASS('\uE6B7'),
GITHUB_TEXT('\uE6B8'),
GITHUB('\uE6B9'),
GIFT('\uE6BA'),
GBP('\uE6BB'),
FULLSCREEN('\uE6BC'),
FRIENDFEED_RECT('\uE6BD'),
FRIENDFEED('\uE6BE'),
FOURSQUARE('\uE6BF'),
FORWARD_ALT('\uE6C0'),
FORWARD('\uE6C1'),
FORK('\uE6C2'),
FONTSIZE('\uE6C3'),
FONT('\uE6C4'),
FOLDER_SIGN('\uE6C5'),
FOLDER_OPEN('\uE6C6'),
FOLDER_CLOSE('\uE6C7'),
FOLDER('\uE6C8'),
FLICKR('\uE6C9'),
FLAG_ALT('\uE6CA'),
FLAG('\uE6CB'),
FIRE('\uE6CC'),
FILTER('\uE6CD'),
FILM('\uE6CE'),
FILE_NEW_ALT('\uE6CF'),
FILE_NEW('\uE6D0'),
FILE_EDIT_ALT('\uE6D1'),
FILE_EDIT('\uE6D2'),
FILE_ALT('\uE6D3'),
FILE('\uE6D4'),
FEMALE('\uE6D5'),
FAST_FORWARD('\uE6D6'),
FAST_BACKWARD('\uE6D7'),
FACETIME_VIDEO('\uE6D8'),
FACEBOOK('\uE6D9'),
EYE_OPEN('\uE6DA'),
EYE_CLOSE('\uE6DB'),
EXCLAMATION_SIGN('\uE6DC'),
EUR('\uE6DD'),
ERROR_ALT('\uE6DE'),
ERROR('\uE6DF'),
ENVELOPE_ALT('\uE6E0'),
ENVELOPE('\uE6E1'),
EJECT('\uE6E2'),
EDIT('\uE6E3'),
DRIBBBLE('\uE6E4'),
DOWNLOAD_ALT('\uE6E5'),
DOWNLOAD('\uE6E6'),
DIGG('\uE6E7'),
DEVIANTART('\uE6E8'),
DELICIOUS('\uE6E9'),
DASHBOARD('\uE6EA'),
CSS('\uE6EB'),
CREDIT_CARD('\uE6EC'),
COMPASS_ALT('\uE6ED'),
COMPASS('\uE6EE'),
COMMENT_ALT('\uE6EF'),
COMMENT('\uE6F0'),
COGS('\uE6F1'),
COG_ALT('\uE6F2'),
COG('\uE6F3'),
CLOUD_ALT('\uE6F4'),
CLOUD('\uE6F5'),
CIRCLE_ARROW_UP('\uE6F6'),
CIRCLE_ARROW_RIGHT('\uE6F7'),
CIRCLE_ARROW_LEFT('\uE6F8'),
CIRCLE_ARROW_DOWN('\uE6F9'),
CHILD('\uE6FA'),
CHEVRON_UP('\uE6FB'),
CHEVRON_RIGHT('\uE6FC'),
CHEVRON_LEFT('\uE6FD'),
CHEVRON_DOWN('\uE6FE'),
CHECK_EMPTY('\uE6FF'),
CHECK('\uE700'),
CERTIFICATE('\uE701'),
CC('\uE702'),
CARET_UP('\uE703'),
CARET_RIGHT('\uE704'),
CARET_LEFT('\uE705'),
CARET_DOWN('\uE706'),
CAR('\uE707'),
CAMERA('\uE708'),
CALENDAR_SIGN('\uE709'),
CALENDAR('\uE70A'),
BULLHORN('\uE70B'),
BULB('\uE70C'),
BRUSH('\uE70D'),
BROOM('\uE70E'),
BRIEFCASE('\uE70F'),
BRAILLE('\uE710'),
BOOKMARK_EMPTY('\uE711'),
BOOKMARK('\uE712'),
BOOK('\uE713'),
BOLD('\uE714'),
BLOGGER('\uE715'),
BLIND('\uE716'),
BELL('\uE717'),
BEHANCE('\uE718'),
BARCODE('\uE719'),
BAN_CIRCLE('\uE71A'),
BACKWARD('\uE71B'),
ASL('\uE71C'),
ARROW_UP('\uE71D'),
ARROW_RIGHT('\uE71E'),
ARROW_LEFT('\uE71F'),
ARROW_DOWN('\uE720'),
ALIGN_RIGHT('\uE721'),
ALIGN_LEFT('\uE722'),
ALIGN_JUSTIFY('\uE723'),
ALIGN_CENTER('\uE724'),
ADULT('\uE725'),
ADJUST_ALT('\uE726'),
ADJUST('\uE727'),
ADDRESS_BOOK_ALT('\uE728'),
ADDRESS_BOOK('\uE729'),
ASTERISK('\uE72A');
private final char character;
private ElusiveIcons(char character) {
this.character = character;
}
@Override
public char getChar() {
return character;
}
@Override
public String unicodeToString() {
return String.format("\\u%04x", (int) character);
}
@Override
public String characterToString() {
return Character.toString(character);
}
@Override
public String getFontFamily() {
return ElusiveIcon.FONT_FAMILY;
}
}

View File

@@ -0,0 +1,14 @@
package de.geofroggerfx.ui.glyphs;
import de.jensd.fx.glyphs.GlyphsDude;
import javafx.scene.text.Font;
/**
* Created by Andreas on 23.03.2015.
*/
public class GeofroggerGlyphsDude extends GlyphsDude {
static {
Font.loadFont(GeofroggerGlyphsDude.class.getResource(ElusiveIcon.TTF_PATH).toExternalForm(), 10.0);
}
}

View File

@@ -0,0 +1,148 @@
/*
* Copyright (c) Andreas Billmann <abi@geofroggerfx.de>
* 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.geofroggerfx.ui.list;
import de.geofroggerfx.model.CacheListEntry;
import de.geofroggerfx.ui.GeocachingIcons;
import de.jensd.fx.glyphs.GlyphsDude;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcons;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.text.Text;
/**
* Multi-Column-Row list cell to shows the most important data in a list.
*
* @author Andreas
*/
public class CacheListCell extends ListCell<CacheListEntry> {
private static final String YELLOW = ";-fx-fill: linear-gradient(#e8e474 0%, #edcf59 70%, #bfba26 85%);";
private static final String GRAY = ";-fx-fill: linear-gradient(#cccccc 0%, #999999 70%, #888888 85%);";
private final GridPane grid = new GridPane();
private final Text icon = GlyphsDude.createIcon(FontAwesomeIcons.BLANK, "20.0");
private final Label name = new Label();
private final Text difficultyStars = GlyphsDude.createIcon(FontAwesomeIcons.BLANK, "8.0");
private final Text terrainStars = GlyphsDude.createIcon(FontAwesomeIcons.BLANK, "8.0");
public CacheListCell() {
configureGrid();
configureIcon();
configureName();
configureDifficulty();
configureTerrain();
addControlsToGrid();
}
@Override
public void updateItem(CacheListEntry 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(USE_COMPUTED_SIZE , USE_COMPUTED_SIZE, Double.MAX_VALUE);
column2.setHgrow(Priority.NEVER);
ColumnConstraints column3 = new ColumnConstraints(30 , 50 , Double.MAX_VALUE);
column3.setHgrow(Priority.ALWAYS);
column3.setFillWidth(true);
ColumnConstraints column4 = new ColumnConstraints(USE_COMPUTED_SIZE , USE_COMPUTED_SIZE , Double.MAX_VALUE);
column4.setHgrow(Priority.NEVER);
ColumnConstraints column5 = new ColumnConstraints(30 , 50 , Double.MAX_VALUE);
column5.setHgrow(Priority.ALWAYS);
column5.setFillWidth(true);
grid.getColumnConstraints().addAll(column1, column2, column3, column4, column5);
}
private void configureIcon() {
icon.setStyle(icon.getStyle()+ GRAY);
}
private void configureName() {
name.setStyle("-fx-font-weight: bold;");
}
private void configureDifficulty() {
difficultyStars.setStyle(difficultyStars.getStyle() + YELLOW);
}
private void configureTerrain() {
terrainStars.setStyle(difficultyStars.getStyle() + YELLOW);
}
private void addControlsToGrid() {
grid.add(icon, 0, 0, 1, 2);
grid.add(name, 1, 0, 4, 1);
grid.add(new Label("Difficulty:"), 1, 1);
grid.add(difficultyStars, 2, 1);
grid.add(new Label("Terrain:"), 3, 1);
grid.add(terrainStars, 4, 1);
}
private void clearContent() {
setText(null);
setGraphic(null);
}
private void addContent(CacheListEntry cache) {
setIcon(cache);
setCacheName(cache);
setDifficulty(cache);
setTerrain(cache);
setGraphic(grid);
}
private void setCacheName(CacheListEntry cache) {
name.setText(cache.getName());
}
private void setIcon(CacheListEntry cache) {
icon.setText(GeocachingIcons.getIconAsString(cache.getType()));
}
private void setDifficulty(CacheListEntry cache) {
difficultyStars.setText(GeocachingIcons.getStarsAsString(cache.getDifficulty()));
}
private void setTerrain(CacheListEntry cache) {
terrainStars.setText(GeocachingIcons.getStarsAsString(cache.getTerrain()));
}
}

View File

@@ -0,0 +1,96 @@
/*
* Copyright (c) Andreas Billmann <abi@geofroggerfx.de>
* 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.geofroggerfx.ui.list;
import de.geofroggerfx.application.SessionContext;
import de.geofroggerfx.model.Cache;
import de.geofroggerfx.model.CacheListEntry;
import de.geofroggerfx.service.CacheService;
import de.geofroggerfx.ui.FXMLController;
import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import static de.geofroggerfx.application.SessionContext.CACHE_ENTRY_LIST;
import static de.geofroggerfx.application.SessionContext.CURRENT_CACHE;
/**
* Created by Andreas on 09.03.2015.
*/
@Component
public class ListController extends FXMLController {
@Autowired
private SessionContext sessionContext;
@Autowired
private CacheService cacheService;
@FXML
ListView cacheListView;
@Value("${fxml.geofrogger.list.view}")
@Override
public void setFxmlFilePath(String filePath) {
this.fxmlFilePath = filePath;
}
@Override
public void initialize(URL location, ResourceBundle resources) {
setCellFactory();
sessionContext.addListener(CACHE_ENTRY_LIST, () -> Platform.runLater(this::resetCacheList));
cacheListView.getSelectionModel().selectedItemProperty().addListener(
(InvalidationListener) observable -> setSelectedCacheIntoSession()
);
}
private void resetCacheList() {
List<Cache> caches = (List<Cache>) sessionContext.getData(CACHE_ENTRY_LIST);
cacheListView.getItems().setAll(caches);
}
@SuppressWarnings("unchecked")
private void setCellFactory() {
cacheListView.setCellFactory(param -> new CacheListCell());
}
private void setSelectedCacheIntoSession() {
CacheListEntry entry = (CacheListEntry) cacheListView.getSelectionModel().getSelectedItem();
Cache cache = null;
if (entry != null) {
cache = cacheService.getCacheForId(entry.getId());
}
sessionContext.setData(CURRENT_CACHE, cache);
}
}