de.fhpotsdam.unfolding.marker
Class MarkerManager<E extends Marker>

java.lang.Object
  extended by de.fhpotsdam.unfolding.marker.MarkerManager<E>

public class MarkerManager<E extends Marker>
extends java.lang.Object

Manages markers of different types. Is always connected to one map (for location to screen coordinate conversion).


Field Summary
protected  boolean bEnableDrawing
           
protected  UnfoldingMap map
           
protected  java.util.List<E> markers
           
 
Constructor Summary
MarkerManager()
          Creates a MarkerManager with an empty markers list.
MarkerManager(java.util.List<E> markers)
          Creates a MarkerManager with given markers.
 
Method Summary
 boolean addMarker(E marker)
          Adds a marker to the manager marker list.
 void addMarkers(java.util.List<E> markers)
          Adds a list of markers to the managed markers.
 void clearMarkers()
          Removes all markers.
 void disableDrawing()
           
 void draw()
          Internal method to draw all managed markers.
 void enableDrawing()
           
 E getFirstHitMarker(float checkX, float checkY)
          Returns the first marker which the given screen coordinates hit.
 java.util.List<E> getHitMarkers(float checkX, float checkY)
          Returns all hit markers.
 java.util.List<E> getMarkers()
          Returns all markers managed by this MarkerManager.
 E getNearestMarker(float checkX, float checkY)
          Returns the nearest marker to the given screen coordinates.
 boolean isDrawingEnabled()
           
 Marker isInside(float checkX, float checkY)
          Deprecated. Replaced by getFirstHitMarker(float, float)
 boolean removeMarker(E marker)
          Removes a marker from the managed markers.
 void setMap(UnfoldingMap map)
          Set the map to use for conversion of geo-locations to screen positions for the markers.
 void setMarkers(java.util.List<E> markers)
          Sets the markers to manage.
 void toggleDrawing()
          Toggles whether this marker manager draws all markers or none.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected UnfoldingMap map

markers

protected java.util.List<E extends Marker> markers

bEnableDrawing

protected boolean bEnableDrawing
Constructor Detail

MarkerManager

public MarkerManager()
Creates a MarkerManager with an empty markers list.


MarkerManager

public MarkerManager(java.util.List<E> markers)
Creates a MarkerManager with given markers.

Parameters:
markers - The markers to add.
Method Detail

setMap

public void setMap(UnfoldingMap map)
Set the map to use for conversion of geo-locations to screen positions for the markers.

Parameters:
map - The map.

setMarkers

public void setMarkers(java.util.List<E> markers)
Sets the markers to manage.

Parameters:
markers - A list of markers. If null all existing markers will be removed.

removeMarker

public boolean removeMarker(E marker)
Removes a marker from the managed markers.

Parameters:
marker - The marker to remove.
Returns:
Whether the list contained the given marker.

clearMarkers

public void clearMarkers()
Removes all markers.


isDrawingEnabled

public boolean isDrawingEnabled()

enableDrawing

public void enableDrawing()

disableDrawing

public void disableDrawing()

toggleDrawing

public void toggleDrawing()
Toggles whether this marker manager draws all markers or none.


addMarker

public boolean addMarker(E marker)
Adds a marker to the manager marker list.

Parameters:
marker - The marker to add.
Returns:
Whether the marker was added or not.

addMarkers

public void addMarkers(java.util.List<E> markers)
Adds a list of markers to the managed markers.

Parameters:
markers - A list of markers.

getMarkers

public java.util.List<E> getMarkers()
Returns all markers managed by this MarkerManager.

Returns:
A list of markers.

isInside

@Deprecated
public Marker isInside(float checkX,
                                  float checkY)
Deprecated. Replaced by getFirstHitMarker(float, float)


getNearestMarker

public E getNearestMarker(float checkX,
                          float checkY)
Returns the nearest marker to the given screen coordinates.

Parameters:
checkX - The x position to check.
checkY - The y position to check.
Returns:
The nearest marker, or null if no marker was hit.

getFirstHitMarker

public E getFirstHitMarker(float checkX,
                           float checkY)
Returns the first marker which the given screen coordinates hit.

Parameters:
checkX - The x position to check.
checkY - The y position to check.
Returns:
The hit marker, or null if no marker was hit.

getHitMarkers

public java.util.List<E> getHitMarkers(float checkX,
                                       float checkY)
Returns all hit markers.

Parameters:
checkX - The x position to check.
checkY - The y position to check.
Returns:
All hit markers, or an empty list if no marker was hit.

draw

public void draw()
Internal method to draw all managed markers.