Marker interface making marker handling more flexible

This commit is contained in:
Erik Duisters
2016-09-16 20:43:06 +02:00
committed by Emux
parent 3703cf7e00
commit 7cdeacd1c2
11 changed files with 55 additions and 53 deletions

View File

@@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item>
public class ItemizedLayer<Item extends MarkerInterface> extends MarkerLayer<Item>
implements GestureListener {
static final Logger log = LoggerFactory.getLogger(ItemizedLayer.class);
@@ -267,12 +267,4 @@ public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item>
return false;
}
public Item getByUid(Object uid) {
for (Item it : mItemList)
if (it.getUid() == uid)
return it;
return null;
}
}

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2016 Erik Duisters
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.layers.marker;
import org.oscim.core.GeoPoint;
public interface MarkerInterface {
MarkerSymbol getMarker();
GeoPoint getPoint();
}

View File

@@ -6,6 +6,7 @@
*
* Copyright 2014 Hannes Janetzek
* Copyright 2016 devemux86
* Copyright 2016 Erik Duisters
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -27,24 +28,7 @@ import org.oscim.core.GeoPoint;
/**
* Immutable class describing a GeoPoint with a Title and a Description.
*/
public class MarkerItem {
public static final int ITEM_STATE_FOCUSED_MASK = 4;
public static final int ITEM_STATE_PRESSED_MASK = 1;
public static final int ITEM_STATE_SELECTED_MASK = 2;
/**
* Indicates a hotspot for an area. This is where the origin (0,0) of a
* point will be located relative to the area. In otherwords this acts as an
* offset. NONE indicates that no adjustment should be made.
*/
public enum HotspotPlace {
NONE, CENTER, BOTTOM_CENTER,
TOP_CENTER, RIGHT_CENTER, LEFT_CENTER,
UPPER_RIGHT_CORNER, LOWER_RIGHT_CORNER,
UPPER_LEFT_CORNER, LOWER_LEFT_CORNER
}
public class MarkerItem implements MarkerInterface {
public final Object uid;
public String title;
public String description;
@@ -78,10 +62,12 @@ public class MarkerItem {
return description;
}
@Override
public GeoPoint getPoint() {
return geoPoint;
}
@Override
public MarkerSymbol getMarker() {
return mMarker;
}

View File

@@ -33,7 +33,7 @@ import org.oscim.map.Map;
* gets checked for onTap first. This class is generic, because you then you get
* your custom item-class passed back in onTap(). << TODO
*/
public abstract class MarkerLayer<Item extends MarkerItem> extends Layer {
public abstract class MarkerLayer<Item extends MarkerInterface> extends Layer {
protected final MarkerRenderer mMarkerRenderer;
protected Item mFocusedItem;

View File

@@ -19,9 +19,20 @@ package org.oscim.layers.marker;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.core.PointF;
import org.oscim.layers.marker.MarkerItem.HotspotPlace;
public class MarkerSymbol {
/**
* Indicates a hotspot for an area. This is where the origin (0,0) of a
* point will be located relative to the area. In otherwords this acts as an
* offset. NONE indicates that no adjustment should be made.
*/
public enum HotspotPlace {
NONE, CENTER, BOTTOM_CENTER,
TOP_CENTER, RIGHT_CENTER, LEFT_CENTER,
UPPER_RIGHT_CORNER, LOWER_RIGHT_CORNER,
UPPER_LEFT_CORNER, LOWER_LEFT_CORNER
}
final Bitmap mBitmap;
/**
* Hotspot offset