de.fhpotsdam.unfolding.marker
Class MultiMarker

java.lang.Object
  extended by de.fhpotsdam.unfolding.marker.MultiMarker
All Implemented Interfaces:
Marker

public class MultiMarker
extends java.lang.Object
implements Marker

A MultiMarker enables handling of multiple, logically grouped markers. Properties and display states are the same for all its markers. A MultiMarker can consist of various sub-markers, even of different types. For instance, a MultiMarker could have three polygon marker and one point marker.


Field Summary
protected  boolean hidden
           
protected  java.lang.String id
           
protected  java.util.List<Marker> markers
           
 java.util.HashMap<java.lang.String,java.lang.Object> properties
           
protected  boolean selected
           
 
Constructor Summary
MultiMarker()
           
 
Method Summary
 void addMarkers(Marker... markers)
           
 void draw(UnfoldingMap map)
          Draws this marker.
 double getDistanceTo(Location location)
          return distance between location and the (to the location) closest marker
 java.lang.String getId()
          Gets the marker ID.
 Location getLocation()
          Return center of all markers.
 java.util.List<Marker> getMarkers()
           
 java.util.HashMap<java.lang.String,java.lang.Object> getProperties()
          Gets the optional properties of this marker.
 java.lang.Object getProperty(java.lang.String key)
          Gets the property for given key.
 java.lang.String getStringProperty(java.lang.String key)
          Gets the property as String for given key.
 boolean isHidden()
          Indicates whether this marker is hidden.
 boolean isInside(UnfoldingMap map, float checkX, float checkY)
          Returns true if at least one marker is hit.
 boolean isSelected()
          Indicates whether this multi marker is selected.
 void setColor(int color)
          Sets the main color of this marker.
 void setHidden(boolean hidden)
          Sets the visibility status of this marker.
 void setId(java.lang.String id)
          Sets the marker ID.
 void setLocation(float lat, float lng)
          Set the location for this marker.
 void setLocation(Location location)
          Set the location for this marker.
 void setMarkers(java.util.List<Marker> markers)
           
 void setProperties(java.util.HashMap<java.lang.String,java.lang.Object> properties)
          Sets the optional properties of this marker.
 void setSelected(boolean selected)
          Sets the selected status of all its markers.
 void setStrokeColor(int color)
          Sets the color of the border.
 void setStrokeWeight(int weight)
          Sets the thickness of the border of this marker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

markers

protected java.util.List<Marker> markers

properties

public java.util.HashMap<java.lang.String,java.lang.Object> properties

selected

protected boolean selected

hidden

protected boolean hidden

id

protected java.lang.String id
Constructor Detail

MultiMarker

public MultiMarker()
Method Detail

getId

public java.lang.String getId()
Description copied from interface: Marker
Gets the marker ID.

Specified by:
getId in interface Marker
Returns:
An ID.

setId

public void setId(java.lang.String id)
Description copied from interface: Marker
Sets the marker ID.

Specified by:
setId in interface Marker
Parameters:
id - The ID.

setMarkers

public void setMarkers(java.util.List<Marker> markers)

getMarkers

public java.util.List<Marker> getMarkers()

addMarkers

public void addMarkers(Marker... markers)

getLocation

public Location getLocation()
Return center of all markers. This uses marker.getLocation() which either returns single location, or centroid location (of shape marker), and then combines it. TODO Check whether to use GeoUtils.getCentroid(List) instead.

Specified by:
getLocation in interface Marker
Returns:
The location with lat, lng.

setLocation

public void setLocation(float lat,
                        float lng)
Description copied from interface: Marker
Set the location for this marker.

Specified by:
setLocation in interface Marker
Parameters:
lat - latitude
lng - longitude

setLocation

public void setLocation(Location location)
Description copied from interface: Marker
Set the location for this marker.

Specified by:
setLocation in interface Marker
Parameters:
location - Location with lat, lng

getDistanceTo

public double getDistanceTo(Location location)
return distance between location and the (to the location) closest marker

Specified by:
getDistanceTo in interface Marker
Parameters:
location - The location to calculate the distance to.
Returns:
Distance to location in kilometers (km).

setProperties

public void setProperties(java.util.HashMap<java.lang.String,java.lang.Object> properties)
Description copied from interface: Marker
Sets the optional properties of this marker.

Specified by:
setProperties in interface Marker
Parameters:
properties - The properties to set. The map consist of key,value pairs for each property.

getProperties

public java.util.HashMap<java.lang.String,java.lang.Object> getProperties()
Description copied from interface: Marker
Gets the optional properties of this marker. The map consist of key,value pairs for each property.

Specified by:
getProperties in interface Marker
Returns:
A map of properties.

getProperty

public java.lang.Object getProperty(java.lang.String key)
Description copied from interface: Marker
Gets the property for given key.

Specified by:
getProperty in interface Marker
Parameters:
key - The key of the property.
Returns:
The property, if found.

getStringProperty

public java.lang.String getStringProperty(java.lang.String key)
Description copied from interface: Marker
Gets the property as String for given key.

Specified by:
getStringProperty in interface Marker
Parameters:
key - The key of the property.
Returns:
The property, if found.

isInside

public boolean isInside(UnfoldingMap map,
                        float checkX,
                        float checkY)
Returns true if at least one marker is hit.

Specified by:
isInside in interface Marker
Parameters:
map - The map to draw on.
checkX - The x position to check in screen coordinates.
checkY - The y position to check in screen coordinates.
Returns:
true if inside, false otherwise.

draw

public void draw(UnfoldingMap map)
Description copied from interface: Marker
Draws this marker.

Specified by:
draw in interface Marker
Parameters:
map - The map to draw on.

setSelected

public void setSelected(boolean selected)
Sets the selected status of all its markers.

Specified by:
setSelected in interface Marker
Parameters:
selected - Whether this marker is selected or not.

isSelected

public boolean isSelected()
Indicates whether this multi marker is selected. This does not necessarily reflect the selected states of all its markers (i.e. a marker of a MultiMarker can have a different selection status):

Specified by:
isSelected in interface Marker
Returns:
true if it is selected, false otherwise.

setHidden

public void setHidden(boolean hidden)
Description copied from interface: Marker
Sets the visibility status of this marker.

Specified by:
setHidden in interface Marker
Parameters:
hidden - The new status

isHidden

public boolean isHidden()
Description copied from interface: Marker
Indicates whether this marker is hidden. Can be used for drawing the marker differently.

Specified by:
isHidden in interface Marker
Returns:
true if it is hidden, false otherwise.

setColor

public void setColor(int color)
Description copied from interface: Marker
Sets the main color of this marker.

Specified by:
setColor in interface Marker
Parameters:
color - The color (in Processing's color type)

setStrokeColor

public void setStrokeColor(int color)
Description copied from interface: Marker
Sets the color of the border.

Specified by:
setStrokeColor in interface Marker
Parameters:
color - The color (in Processing's color type)

setStrokeWeight

public void setStrokeWeight(int weight)
Description copied from interface: Marker
Sets the thickness of the border of this marker.

Specified by:
setStrokeWeight in interface Marker
Parameters:
weight - Thickness in pixel.