|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.lbs.maps.model.MapDataModel
public class MapDataModel
Represents a container of information for a MapField
.
The MapDataModel
contains items that can be
displayed on the field, including whether the mappable item is
visible or not, and what tags apply to the mappable item.
Instances of Mappable
that are added to this container
must correctly implement hashCode()
and
equals(Object)
because the container uses these methods for
storage, retrieval and duplication checking.
RichMapField map = MapFactory.getInstance().generateRichMapField();
MapDataModel data = map.getModel();
// create Bob's work location and add it with appropriate tags
MapLocation bobWork = new MapLocation( 45.34296, -75.91606, "Bob - Work", null );
int bobWorkId = data.add( bobWork, "bob" );
data.tag( bobWorkId, "work" ); //locations can have more than one tag
// set items tagged "work" as visible
data.setVisibleNone();
data.setVisible( "work" );
Constructor Summary | ||
---|---|---|
MapDataModel()
Constructs a new MapDataModel instance. |
Method Summary | ||
---|---|---|
int |
add(Mappable data)
Adds the mappable item to the model. |
|
int |
add(Mappable data,
String tag)
Adds the mappable item to the model with a specified tag. |
|
int |
add(Mappable data,
String tag,
boolean visible)
Adds the mappable item to the model with a tag and the specified visibility. |
|
void |
addAll(MapDataModel data)
Adds all the items in the given parameter to this storage container. |
|
void |
addAll(Mappable[] data)
Adds all the mappable entities in the given array to this storage container. |
|
void |
addAll(MappableVector data)
Adds all the mappable entities in the given vector to this storage container. |
|
boolean |
contains(Mappable data)
Determines if this store already contains the specified mappable data. |
|
Mappable |
get(int id)
Retrieves the mappable item based on the item's ID. |
|
Mappable |
get(Integer id)
Retrieves the mappable item based on the item's ID. |
|
MappableVector |
get(String tag)
Retrieves all the mappable elements that are tagged with the specified tag. |
|
Object |
getAt(int index)
Retrieves element by index. |
|
int |
getAt(int index,
int count,
Object[] elements,
int destIndex)
Retrieves range of elements starting at provided index. |
|
int |
getId(Mappable data)
Retrieves the ID for the specified data. |
|
IntVector |
getIds(String tag)
Retrieves a list of all the IDs that are tagged with the specified tag. |
|
int |
getIndex(Object element)
Retrieves index by element. |
|
Vector |
getTags(int id)
Retrieves a vector containing all the tags for a given mappable element. |
|
MappableVector |
getVisible()
Retrieves all mappable items that are flagged as visible, regardless of the visible area. |
|
LatLonRectangle |
getVisibleBoundingBox()
Calculates a bounding box of all visible data. |
|
MappableVector |
getVisibleData(LatLonRectangle visBoundingBox)
Retrieves all the mappable elements in this store that are visible in the specified rectangle. |
|
MappableVector |
getVisibleData(MapDimensions visibleArea)
Retrieves all the mappable elements in this store that are visible in the specified dimensions. |
|
IntVector |
getVisibleIds()
Returns the IDs for all visible mappable items. |
|
boolean |
isVisible(int id)
Determines if the mappable item with the specified ID is visible. |
|
void |
remove(int id)
Removes the item with the specified ID from the store. |
|
void |
remove(String tag)
Removes all elements tagged with the specified tag. |
|
void |
remove(IntVector ids)
Removes all items with the specified IDs. |
|
void |
removeAll()
Removes all mappable elements from storage. |
|
void |
setVisible(int id)
Sets the mappable item with the specified ID to visible. |
|
void |
setVisible(int id,
boolean visible)
Sets the visible state of the mappable item that has the specified ID. |
|
void |
setVisible(String tag)
Sets all mappables items with the specified tag to visible. |
|
void |
setVisible(String tag,
boolean visible)
Sets the visible state for all mappable items with the specified tag. |
|
void |
setVisible(Mappable[] visibles)
Sets all mappable items in this collection to visible. |
|
void |
setVisibleNone()
Sets all visible elements to not visible. |
|
int |
size()
Retrieves the number of elements in this collection. |
|
void |
tag(int id,
String tag)
Tags a single mappable element with the specified tag. |
|
void |
tag(Mappable data,
String tag)
Tags a single element with the specified tag. |
|
Mappable[] |
toArray()
Retrieves all mappable items in this storage container. |
|
void |
untag(int id)
Removes all tags from the specified element. |
|
void |
untag(int id,
String tag)
Removes the specified tag from the element with the specified ID. |
|
void |
untag(Mappable data,
String tag)
Removes a tag from a single element. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.rim.device.api.collection.CollectionEventSource |
---|
addCollectionListener, removeCollectionListener |
Constructor Detail |
---|
public MapDataModel()
Method Detail |
---|
public int add(Mappable data)
add( data, null, true )
.
data
- The new value to be added.
MapDataModel.add(Mappable, String, boolean)
public int add(Mappable data, String tag)
add( data, tag, true )
.
data
- The new value to add.tag
- The tag to apply to the new data.
MapDataModel.add(Mappable, String, boolean)
public int add(Mappable data, String tag, boolean visible)
data
- The new value to data.tag
- The tag to apply to the new data.visible
- If true
the mappable item is visible,
if false
, the mappable item is not visible.
public void addAll(Mappable[] data)
data
- the mappable entities to add.public void addAll(MappableVector data)
data
- The mappables entities to add.public void addAll(MapDataModel data)
data
- The entities to add.public Mappable get(int id)
id
- ID of the mappable item.
NullMappable
if the
item is not found, never returns null
.public Mappable get(Integer id)
id
- ID of the mappable item.
NullMappable
if the
item is not found, never returns null
.public MappableVector get(String tag)
tag
- The tag of the elements to retrieve.
null
.public IntVector getIds(String tag)
tag
- The tag of the IDs to retrieve.
null
.public int getId(Mappable data)
data
- The mappable item of the ID to retrieve.
public boolean contains(Mappable data)
data
- The mappable data to verify.
true
if the data is already stored,
false
otherwise.public void tag(int id, String tag)
id
- The unique ID of the element to be tagged.tag
- The tag to apply.public void tag(Mappable data, String tag)
tag( getId( data ), tag )
.
data
- The element (that is already in the store) to be tagged.tag
- The tag to apply.public void untag(int id, String tag)
id
- The unique ID of the element.tag
- The tag to remove.public void untag(Mappable data, String tag)
untag( getId( data ), tag )
.
data
- The mappable element that is already in the store.tag
- The tag to remove.public void untag(int id)
id
- The unique ID of the element to remove all tags from.public void remove(String tag)
tag
- The tag for the elements that are to be removed.public void remove(IntVector ids)
ids
- The collection of IDs to remove.public void remove(int id)
id
- The ID of the item to remove.public void removeAll()
public void setVisible(int id)
id
- The ID of the item that is to be made visible.public void setVisible(int id, boolean visible)
id
- The ID of the mappable item.visible
- true
to make this item visible,
false
to make this item not visible.public void setVisible(String tag)
setVisible( tag, true )
.
tag
- The tag of the mappable item.public void setVisible(String tag, boolean visible)
tag
- The tag of the mappable item.visible
- true
to make this item visible,
false
to make it not visible.public void setVisible(Mappable[] visibles)
Note: The object must correctly implement equals(Object)
.
visibles
- The collection of mappable items to be visible.public void setVisibleNone()
public boolean isVisible(int id)
id
- The ID of the mappable item.
true
if the item is visible, false
otherwise.public IntVector getVisibleIds()
public MappableVector getVisible()
MapDataModel.getVisibleData(MapDimensions)
public MappableVector getVisibleData(MapDimensions visibleArea)
Note: Only those elements that are in the specified area and that are flagged as visible are returned.
visibleArea
- The area to search for visible elements.
null
.public MappableVector getVisibleData(LatLonRectangle visBoundingBox)
Note: Only those elements that are in the specified rectangle and that are flagged as visible are returned.
visBoundingBox
- The rectangular area to search for visible elements.
null
.public LatLonRectangle getVisibleBoundingBox()
null
if there is no visible data.public Mappable[] toArray()
public Vector getTags(int id)
id
- The unique ID of the element.
null
.public Object getAt(int index)
ReadableList
getAt
in interface ReadableList
index
- Index of the element to retrieve.
ReadableList.getAt(int)
public int getAt(int index, int count, Object[] elements, int destIndex)
ReadableList
getAt
in interface ReadableList
index
- Index of first element to retrieve.count
- Number of elements to retrieve.elements
- Object array to contain returned elements; this array must
have enough space to hold the number of elements you expect to receive.destIndex
- Index within destination array to contain the first
element retrieved (the destination array must therefore be at least
destIndex + count
elements long).
ReadableList.getAt(int, int, Object[], int)
public int getIndex(Object element)
ReadableList
Note: this operation may be linear with respect to the number of elements in the list.
getIndex
in interface ReadableList
element
- Element to locate.
ReadableList.getIndex(Object)
public int size()
ReadableList
size
in interface ReadableList
ReadableList.size()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.