com.micello.mapapi.data
Class MapData

java.lang.Object
  extended by com.micello.mapapi.data.MapData
All Implemented Interfaces:
CommunityDataListener, DrawingEntitiesDataListener, LevelGeometryDataListener

public class MapData
extends java.lang.Object
implements CommunityDataListener, DrawingEntitiesDataListener, LevelGeometryDataListener

This class manages the map data including the base map and map annotations. The map data is managed with this class and the viewport to the map is managed with the class MapViewRegion. The class MicelloMapView renders the data given by MapData with a viewport given by MapViewRegion. The active MapData object as well as the MapViewRegion object can be accessed from the static class MicelloManager.

This class is used to open a community as well as to change the active map and level. This class is also used to hold the annotations for the map. The annotations should be added using an annotation layer, which manages the groups of annotations.


Constructor Summary
MapData(MicelloManager micelloManager)
          Constructor
 
Method Summary
 void addCommunityChangedListener(CommunityChangedListener communityChangedListener)
          This method adds a community data listener.
 void addLayer(AnnotationLayer layer)
          This method adds a new annotation layer to the map data.
 void clearCommunity()
          This method clears the community from the MapData and map rendering objects.
 void communityLoaded(Community community)
          This is an implementation of the CommunityDataListener interface
 void drawingEntitiesLoaded(int did, java.lang.String lang, int version, java.util.List<Entity> entityList)
          This is an implementation of the DrawingEnityDataListener interface
 Community getCommunity()
          Thie method gets the current community.
 Drawing getCurrentDrawing()
          This method gets the current drawing.
 DrawingLevel getCurrentLevel()
          This method gets the currently rendered level.
 Drawing getDrawing(int drawingId)
          This method returns the drawing given by the passed drawing id.
 int getEntityVersion()
          This method returns the entity version of the currently loaded community.
 java.util.List<AnnotationLayer> getLayerList()
          This method returns a list of annotation layers currently registered.
 DrawingLevel getLevel(int levelId)
          This method returns the level given by the passed level id.
 void getMapObjectInfo(GeomReference geomRef, int levelId, int entityId, MapObjectInfoListener listener)
          This method will load the MapObjectInfo for the given geometry reference with the entityId paremeter set.
 void getMapObjectInfo(GeomReference geomRef, int levelId, MapObjectInfoListener listener)
          This method will load the MapObjectInfo for the given geometry reference.
 MapObjectInfo getMapObjectInfo(int markerOverlayId, int levelId)
          This method retrieves a MapObjectInfo for the specified marker overlay.
 MapObjectInfo getMapObjectInfo(int markerOverlayId, int levelId, boolean isoLevel)
          This method retrieves a MapObjectInfo for the specified marker overlay and for a specific level.
 int getMapVersion()
          This method returns the map version of the currently loaded community.
 MarkerOverlay getMarker(int markerId)
          This method returns a marker from the given level id and marker id.
 Drawing getPendingDrawing()
          This method gets the most recently set drawing.
 DrawingLevel getPendingLevel()
          This method gets the most recently set drawing level.
 void levelGeometryLoaded(LevelGeometry levelGeom)
          This is an implementation of the LevelGeometryDataListener interface
 void onCommunityError(int cid, int error)
          This is an implementation of the CommunityDataListener interface
 void onDrawingEntitiesError(int did, int error)
          This is an implementation of the DrawingEnityDataListener interface
 void onLevelGeometryError(int lid, int error)
          This is an implementation of the LevelGeometryDataListener interface
 void openCommunity(int communityId)
          This method loads a community.
 void openCommunityAndDrawing(int communityId, int drawingId)
          This method loads a community as with the single argument, opening it to the specified drawing.
 void openCommunityAndLevel(int communityId, int levelId)
          This method loads a community as with the single argument, opening it to the specified level.
 void openLink(MapLink link)
          This method opens the map to the given community, drawing and level.
 void removeCommunityChangedListener(CommunityChangedListener communityChangedListener)
          This method removes a community data listener.
 void removeLayer(AnnotationLayer layer)
          This method removes an annotation layer from the map data.
 void resetCommunity()
          This method resets a community to the just opened state.
 void setDrawing(int drawingId)
          This method sets the current drawing, which opens to the default level.
 void setLevel(int levelId)
          This method sets the level to the level with the given level ID.
 void setTileManager(TileManager tileManager)
          This method is for internal use only.
 void synchGeomData()
          This method should only be called by the tile renderer to synchronize the geometry annotation data with the tile render thread.
 void synchLevelData()
          This method should only be called by the map renderer to synchronize the requested level with the rendered level.
 void synchMarkerData()
          This method should only be called by the map renderer to synchronize the marker annotation data with the map render thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapData

public MapData(MicelloManager micelloManager)
Constructor

Method Detail

addCommunityChangedListener

public void addCommunityChangedListener(CommunityChangedListener communityChangedListener)
This method adds a community data listener.


removeCommunityChangedListener

public void removeCommunityChangedListener(CommunityChangedListener communityChangedListener)
This method removes a community data listener.


getMapVersion

public int getMapVersion()
This method returns the map version of the currently loaded community. Data requested for this community should use this map version, where necessary. As an alternative, the version value (@link DataStore.UNKOWN_VERSION} can be used to request the latest data.

Returns:
The map vesion for the data

getEntityVersion

public int getEntityVersion()
This method returns the entity version of the currently loaded community. Data requested for this community should use this entity version, where necessary. As an alternative, the version value (@link DataStore.UNKOWN_VERSION} can be used to request the latest data.

Returns:
The map vesion for the data

getCommunity

public Community getCommunity()
Thie method gets the current community.


getPendingDrawing

public Drawing getPendingDrawing()
This method gets the most recently set drawing. It should match the current drawing except for the window of time before the render thread starts.


getCurrentDrawing

public Drawing getCurrentDrawing()
This method gets the current drawing.


getPendingLevel

public DrawingLevel getPendingLevel()
This method gets the most recently set drawing level. It should match the current drawing level except for the window of time before the render thread starts.


getCurrentLevel

public DrawingLevel getCurrentLevel()
This method gets the currently rendered level.


getDrawing

public Drawing getDrawing(int drawingId)
This method returns the drawing given by the passed drawing id. If the object is not found null is returned. The object will not be found if it is in the community but not yet loaded.

Parameters:
drawingId - The drawing id for the requested drawing
Returns:
The requested drawing. If the drawing is not found null is returned.

getLevel

public DrawingLevel getLevel(int levelId)
This method returns the level given by the passed level id. If the object is not found null is returned. The object will not be found if it is in the community but not yet loaded.

Parameters:
levelId - The level id for the requested level
Returns:
The requested level. If the level is not found null is returned.

getMapObjectInfo

public void getMapObjectInfo(GeomReference geomRef,
                             int levelId,
                             MapObjectInfoListener listener)
This method will load the MapObjectInfo for the given geometry reference. The geometry is returned to the listener object. If the geometry is not currently loaded, the given level will be made the active level and then the geometry returned.

Parameters:
geomRef - The geometry to load
levelId - The level on which the geometry resides
listener - The listener to receive the object

getMapObjectInfo

public void getMapObjectInfo(GeomReference geomRef,
                             int levelId,
                             int entityId,
                             MapObjectInfoListener listener)
This method will load the MapObjectInfo for the given geometry reference with the entityId paremeter set. This is used when a reference to a specific entity for a geometry is desired. The geometry is returned to the listener object. If the geometry is not currently loaded, the given level will be made the active level and then the geometry returned.

Parameters:
geomRef - The geometry to load
levelId - The main level on which the geometry resides
entityId - The entity active for this map object info reference
listener - The listener to receive the object

getMapObjectInfo

public MapObjectInfo getMapObjectInfo(int markerOverlayId,
                                      int levelId)
This method retrieves a MapObjectInfo for the specified marker overlay. The level value should be the desired level to be loaded by default for this marker. THe marker itself may appear on multiple levels howeever. If will return null if the level is not a valid level.

Parameters:
markerOverlayId - The annotation id for the MarkerOverlay
levelId - The level to be used in the MapObjectInfo,
Returns:
The MapObjectInfo

getMapObjectInfo

public MapObjectInfo getMapObjectInfo(int markerOverlayId,
                                      int levelId,
                                      boolean isoLevel)
This method retrieves a MapObjectInfo for the specified marker overlay and for a specific level. This is can be used to reference a single level of a marker that appears on mulitple levels. If will return null if the level is not a valid level.

Parameters:
markerOverlayId - The annotation id for the MarkerOverlay
levelId - The level to be used in the MapObjectInfo
Returns:
The MapObjectInfo

getMarker

public MarkerOverlay getMarker(int markerId)
This method returns a marker from the given level id and marker id.

Parameters:
markerId - The marker id
Returns:
The marker overlay object

clearCommunity

public void clearCommunity()
This method clears the community from the MapData and map rendering objects.


resetCommunity

public void resetCommunity()
This method resets a community to the just opened state.


openCommunity

public void openCommunity(int communityId)
This method loads a community. If the community ID passed is already the current community, the community is reset to the new state. Otherwise a new community is loaded. The CommunityChangedListener is the callback that indicates changes in the community.


openCommunityAndDrawing

public void openCommunityAndDrawing(int communityId,
                                    int drawingId)
This method loads a community as with the single argument, opening it to the specified drawing. The default level for the drawing is shown.


openCommunityAndLevel

public void openCommunityAndLevel(int communityId,
                                  int levelId)
This method loads a community as with the single argument, opening it to the specified level.


setDrawing

public void setDrawing(int drawingId)
This method sets the current drawing, which opens to the default level. The drawing should be in the current community.


setLevel

public void setLevel(int levelId)
This method sets the level to the level with the given level ID.


openLink

public void openLink(MapLink link)
This method opens the map to the given community, drawing and level. It does not center the act on the value for the geometry.


getLayerList

public java.util.List<AnnotationLayer> getLayerList()
This method returns a list of annotation layers currently registered. The layers may be showing or hidden.


addLayer

public void addLayer(AnnotationLayer layer)
This method adds a new annotation layer to the map data.


removeLayer

public void removeLayer(AnnotationLayer layer)
This method removes an annotation layer from the map data.


synchLevelData

public void synchLevelData()
This method should only be called by the map renderer to synchronize the requested level with the rendered level. This is done to prevent the level from changing whle the map is being renderered.


synchMarkerData

public void synchMarkerData()
This method should only be called by the map renderer to synchronize the marker annotation data with the map render thread. This is to prevent the markers from being changed while the level is bveing rendered.


synchGeomData

public void synchGeomData()
This method should only be called by the tile renderer to synchronize the geometry annotation data with the tile render thread. This is to prevent the geometry from being changed while the tiles are being rendered.


setTileManager

public void setTileManager(TileManager tileManager)
This method is for internal use only. It sets the tile manager.


communityLoaded

public void communityLoaded(Community community)
This is an implementation of the CommunityDataListener interface

Specified by:
communityLoaded in interface CommunityDataListener

onCommunityError

public void onCommunityError(int cid,
                             int error)
This is an implementation of the CommunityDataListener interface

Specified by:
onCommunityError in interface CommunityDataListener

levelGeometryLoaded

public void levelGeometryLoaded(LevelGeometry levelGeom)
This is an implementation of the LevelGeometryDataListener interface

Specified by:
levelGeometryLoaded in interface LevelGeometryDataListener

onLevelGeometryError

public void onLevelGeometryError(int lid,
                                 int error)
This is an implementation of the LevelGeometryDataListener interface

Specified by:
onLevelGeometryError in interface LevelGeometryDataListener

drawingEntitiesLoaded

public void drawingEntitiesLoaded(int did,
                                  java.lang.String lang,
                                  int version,
                                  java.util.List<Entity> entityList)
This is an implementation of the DrawingEnityDataListener interface

Specified by:
drawingEntitiesLoaded in interface DrawingEntitiesDataListener

onDrawingEntitiesError

public void onDrawingEntitiesError(int did,
                                   int error)
This is an implementation of the DrawingEnityDataListener interface

Specified by:
onDrawingEntitiesError in interface DrawingEntitiesDataListener