changed the package name to the domain name

This commit is contained in:
2014-05-17 07:18:37 +02:00
parent 471b532290
commit 2af2f56ade
48 changed files with 116 additions and 127 deletions

View File

@@ -0,0 +1,144 @@
/*
* Copyright (c) 2013, 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.fx.components;
import de.geofroggerfx.model.Cache;
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.geofroggerfx.fx.utils.JavaFXUtils.addClasses;
import static de.geofroggerfx.fx.utils.JavaFXUtils.removeClasses;
/**
* Multi-Column-Row list cell to shows the most important data in a list.
*
* @author Andreas
*/
public class CacheListCell extends ListCell<Cache> {
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 Label owner = new Label();
private final ImageView foundIcon = 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(100, 100, 200);
column3.setHgrow(Priority.SOMETIMES);
ColumnConstraints column4 = new ColumnConstraints(32);
grid.getColumnConstraints().addAll(column1, column2, column3, column4);
}
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, 2, 1);
grid.add(dt, 2, 1);
grid.add(owner, 1, 1);
grid.add(foundIcon, 3, 0);
}
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());
String ownerText = cache.getPlacedBy().equals(cache.getOwner().getName()) ? cache.getPlacedBy() : cache.getPlacedBy() + " (" + cache.getOwner().getName() + ")";
owner.setText(ownerText);
if (cache.isFound()) {
foundIcon.setImage(IconManager.getIcon("iconmonstr-check-mark-11-icon.png", IconManager.IconSize.SMALL));
} else {
foundIcon.setImage(null);
}
setStyleClassDependingOnFoundState(cache);
setGraphic(grid);
}
private void setStyleClassDependingOnFoundState(Cache cache) {
if (cache.isFound()) {
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);
}
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 2013, 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.fx.components;
import de.geofroggerfx.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 = "iconmonstr-map-5-icon.png";
switch (cache.getType()) {
case MULTI_CACHE:
iconName = "iconmonstr-map-6-icon.png";
break;
case TRADITIONAL_CACHE:
iconName = "iconmonstr-map-5-icon.png";
break;
case UNKNOWN_CACHE:
iconName = "iconmonstr-help-3-icon.png";
break;
case EARTH_CACHE:
iconName = "iconmonstr-globe-4-icon.png";
break;
case LETTERBOX:
iconName = "iconmonstr-email-4-icon.png";
break;
case EVENT:
case CITO_EVENT:
case MEGA_EVENT:
iconName = "iconmonstr-calendar-4-icon.png";
break;
case WHERIGO:
iconName = "iconmonstr-navigation-6-icon.png";
break;
case WEBCAM_CACHE:
iconName = "iconmonstr-webcam-3-icon.png";
break;
case VIRTUAL_CACHE:
iconName = "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 = "iconmonstr-location-icon.png";
return IconManager.getIcon(iconName, size);
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 2013, 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.fx.components;
import javafx.scene.image.Image;
import java.util.HashMap;
import java.util.Map;
/**
* @author Andreas
*/
public class IconManager {
private static final Map<String, Image> 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("/icons/"+(int)size.getValue()+"/"+iconName, size.getValue(), size.getValue(), true, true);
container.put(key, image);
}
return image;
}
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 2013, 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.fx.components;
import de.geofroggerfx.fx.utils.JavaFXUtils;
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 <abi@geofroggerfx.de>
*/
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<MapMarkable> 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);
}
});
}
}

View File

@@ -0,0 +1,55 @@
package de.geofroggerfx.fx.components;
import de.geofroggerfx.service.CacheSortField;
import de.geofroggerfx.service.SortDirection;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.MenuItem;
import static de.geofroggerfx.service.SortDirection.ASC;
import static de.geofroggerfx.service.SortDirection.DESC;
/**
* MenuItem with a ASC and DESC arrow when selected
*/
public class SortingMenuItem extends MenuItem {
private static final String BLACK_UP_POINTING_TRIANGLE = " \u25B2";
private static final String BLACK_DOWN_POINTING_TRIANGLE = " \u25BC";
private boolean oldValue = false;
private ObjectProperty<CacheSortField> field = new SimpleObjectProperty<>();
private ObjectProperty<SortDirection> sortDirection = new SimpleObjectProperty<>(ASC);
public SortingMenuItem(final String text, final CacheSortField field) {
super(text);
this.field.setValue(field);
}
public void setSelected(boolean newValue) {
final StringBuilder text = new StringBuilder(getText());
String triangle = BLACK_UP_POINTING_TRIANGLE;
if (newValue && oldValue) {
sortDirection.set(sortDirection.get().equals(ASC) ? DESC : ASC);
triangle = sortDirection.get().equals(ASC) ? BLACK_UP_POINTING_TRIANGLE : BLACK_DOWN_POINTING_TRIANGLE;
text.delete(text.length() - 2, text.length());
text.append(triangle);
} else if (newValue) {
text.append(triangle);
} else {
text.delete(text.length() - 2, text.length());
}
setText(text.toString());
oldValue = newValue;
}
public CacheSortField getField() {
return field.get();
}
public SortDirection getSortDirection() {
return sortDirection.get();
}
}