- java.lang.Object
-
- org.arakhne.afc.gis.primitive.AbstractGISElement<C,T>
-
- org.arakhne.afc.gis.primitive.AbstractBoundedGISElement<GISElementContainer<?>,MapElement>
-
- org.arakhne.afc.gis.mapelement.MapElement
-
- All Implemented Interfaces:
Serializable,Cloneable,EventListener,AttributeChangeListener,AttributeCollection,AttributeProvider,BoundedGISElement,FlagContainer,GISCloneable<MapElement>,GISContentElement<GISElementContainer<?>>,GISEditable,GISElement,GISFlagContainer,GISPrimitive,BoundedElement2afp<Rectangle2d>,JsonableObject
- Direct Known Subclasses:
MapComposedElement,MapPonctualElement
public abstract class MapElement extends AbstractBoundedGISElement<GISElementContainer<?>,MapElement> implements GISContentElement<GISElementContainer<?>>, GISEditable, GISFlagContainer
Abstract class for all the elements of a map inside a layer.Since release 1.3, this object allow to store attributes inside a database system.
An attribute is a pair name-value which must respect some constraints:
- its name must be unique;
- its value type must be the same as the defined type inside the attribute definition manager.
- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:53
- Author:
- Stéphane GALLAND
- See Also:
- Serialized Form
- Maven Group Id:
- org.arakhne.afc.gis
- Maven Artifact Id:
- giscore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMapElement.VisualizationTypeDescribes how the map element was displayed.
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_COLORAttribute: color of the element.static StringATTR_USE_CONTAINER_COLORName of the attribute that indicates if the element must use its container's color.static StringATTR_VISUALIZATION_TYPEName of the attribute that indicates if the element must use its container's color.-
Fields inherited from interface org.arakhne.afc.gis.primitive.FlagContainer
FLAG_READONLY, FLAG_SELECTED
-
Fields inherited from interface org.arakhne.afc.gis.primitive.GISElement
ATTR_NAME, NAME_COMPARATOR
-
Fields inherited from interface org.arakhne.afc.gis.primitive.GISPrimitive
COMPARATOR
-
-
Constructor Summary
Constructors Constructor Description MapElement(UUID id, AttributeCollection attributeSource)Create a new map element.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddGISEditableChangeListener(GISEditableChangeListener listener)Add listener.protected booleanboundsContains(double x, double y, double delta)Replies if the specified point (x,y) was inside the bounds of this MapElement.protected booleanboundsIntersects(Shape2D<?,?,?,?,?,? extends Rectangle2afp<?,?,?,?,?,?>> rectangle)Replies if the bounds of this element has an intersection with the specified rectangle.MapElementclone()Clone this object to obtain a valid copy.booleancontains(Point2D<?,?> point)Replies if the specified point (x,y) was inside the figure of this MapElement.abstract booleancontains(Point2D<?,?> point, double delta)Replies if the specified point (x,y) was inside the figure of this MapElement.booleanequals(Object obj)Replies if the specified objects is the same as this one.abstract booleanequals(MapElement element)Replies if the specified objects is the same as this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.protected voidfireElementChanged()Fire the event that indicates this object has changed.protected voidfireGraphicalAttributeChanged()Invoked when one of the graphical attributes of this element has changed, except those that change the bounding boxes.protected voidfireShapeChanged()Invoked when the shape of this element changed.intgetColor()Replies the color of this element or the color of the container.abstract doublegetDistance(Point2D<?,?> point)Replies the distance between this MapElement and point.intgetFlags()Replies the flags associated to this element.IntegergetRawColor()Replies the color stored inside this element.MapElement.VisualizationTypegetVisualizationType()Replies the type of visualization that must be used by this element.booleanhasFlag(int flagIndex)Replies if the specified flag is set for this element.abstract inthashCode()abstract booleanintersects(Shape2D<?,?,?,?,?,? extends Rectangle2afp<?,?,?,?,?,?>> rectangle)Replies if this element has an intersection with the specified rectangle.booleanisContainerColorUsed()Replies the flag that indicates if this element use its color or the container's color.booleanisReadOnlyObject()Replies if this editable object want to be seen as a reed-only object.protected voidonAttributeChanged(String name)This function is invoked by the attribute provider each time an attribute has changed.voidremoveGISEditableChangeListener(GISEditableChangeListener listener)Remove listener.voidresetBoundingBox()Clear the current bounding box to force the computation of it at the next call toBoundedElement2afp.getBoundingBox().voidsetColor(int color)Set the color of this element.voidsetContainerColorUse(boolean useContainerColor)Set the flag that indicates if this element use its color or the container's color.voidsetFlag(int flag)Set the flag.voidsetReadOnlyObject(boolean readOnly)Set if this editable object want to be seen as a reed-only object.voidsetUUID(UUID id)Set the unique identifier for element.voidsetVisualizationType(MapElement.VisualizationType type)Set the type of visualization that must be used by this element.voidswitchFlag(int flagIndex)Switch the value of the specified flag on this element.voidtoJson(JsonBuffer buffer)Replies the Json representation of this node.voidunsetFlag(int flagIndex)Unset the flag.-
Methods inherited from class org.arakhne.afc.gis.primitive.AbstractBoundedGISElement
calcBounds, getBoundingBox, setBoundingBox
-
Methods inherited from class org.arakhne.afc.gis.primitive.AbstractGISElement
addAttributeChangeListener, addAttributes, addAttributes, attributes, copyAttributes, flush, freeMemory, getAllAttributeNames, getAllAttributes, getAllAttributesByType, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeAsBool, getAttributeAsDate, getAttributeAsDouble, getAttributeAsEnumeration, getAttributeAsEnumeration, getAttributeAsFloat, getAttributeAsInetAddress, getAttributeAsInt, getAttributeAsJavaClass, getAttributeAsLong, getAttributeAsString, getAttributeAsURI, getAttributeAsURL, getAttributeAsUUID, getAttributeCollection, getAttributeCount, getAttributeObject, getAttributeProvider, getContainer, getGeoId, getName, getTopContainer, getUUID, hasAttribute, hashKey, isEventFirable, onAttributeChangeEvent, removeAllAttributes, removeAttribute, removeAttributeChangeListener, renameAttribute, renameAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setAttributeType, setContainer, setEventFirable, setName, toMap, toMap, toString
-
Methods inherited from interface org.arakhne.afc.attrs.collection.AttributeCollection
addAttributeChangeListener, addAttributes, addAttributes, flush, isEventFirable, removeAllAttributes, removeAttribute, removeAttributeChangeListener, renameAttribute, renameAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setAttributeType, setEventFirable
-
Methods inherited from interface org.arakhne.afc.attrs.collection.AttributeProvider
attributes, freeMemory, getAllAttributeNames, getAllAttributes, getAllAttributesByType, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeAsBool, getAttributeAsDate, getAttributeAsDouble, getAttributeAsEnumeration, getAttributeAsEnumeration, getAttributeAsFloat, getAttributeAsInetAddress, getAttributeAsInt, getAttributeAsJavaClass, getAttributeAsLong, getAttributeAsString, getAttributeAsURI, getAttributeAsURL, getAttributeAsUUID, getAttributeCount, getAttributeObject, hasAttribute, toMap, toMap
-
Methods inherited from interface org.arakhne.afc.gis.primitive.BoundedGISElement
getShape
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISContentElement
getContainer, getTopContainer, setContainer
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISEditable
getName, setName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISElement
copyAttributes, getName, hashKey, setName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISPrimitive
getGeoId, getGeoLocation, getUUID
-
-
-
-
Field Detail
-
ATTR_COLOR
public static final String ATTR_COLOR
Attribute: color of the element.- See Also:
- Constant Field Values
-
ATTR_USE_CONTAINER_COLOR
public static final String ATTR_USE_CONTAINER_COLOR
Name of the attribute that indicates if the element must use its container's color.- See Also:
- Constant Field Values
-
ATTR_VISUALIZATION_TYPE
public static final String ATTR_VISUALIZATION_TYPE
Name of the attribute that indicates if the element must use its container's color.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MapElement
public MapElement(UUID id, AttributeCollection attributeSource)
Create a new map element.- Parameters:
id- is the unique identifier of this element, ornullif unknown.attributeSource- is the source of the attributes for this map element.- Since:
- 4.0
-
-
Method Detail
-
toJson
@Pure public void toJson(JsonBuffer buffer)
Description copied from interface:JsonableObjectReplies the Json representation of this node.- Specified by:
toJsonin interfaceJsonableObject- Overrides:
toJsonin classAbstractBoundedGISElement<GISElementContainer<?>,MapElement>- Parameters:
buffer- the Json buffer.
-
finalize
@Deprecated(since="17.0", forRemoval=true) protected void finalize() throws Throwable
Deprecated, for removal: This API element is subject to removal in a future version.
-
clone
@Pure public MapElement clone()
Clone this object to obtain a valid copy.- Specified by:
clonein interfaceAttributeCollection- Specified by:
clonein interfaceAttributeProvider- Specified by:
clonein interfaceGISCloneable<MapElement>- Specified by:
clonein interfaceGISElement- Overrides:
clonein classAbstractBoundedGISElement<GISElementContainer<?>,MapElement>- Returns:
- a copy
-
setUUID
public final void setUUID(UUID id)
Set the unique identifier for element.A Unique IDentifier (UID) must be unique for all the object instances.
- Overrides:
setUUIDin classAbstractGISElement<GISElementContainer<?>,MapElement>- Parameters:
id- is the new identifier- Since:
- 4.0
-
addGISEditableChangeListener
public void addGISEditableChangeListener(GISEditableChangeListener listener)
Description copied from interface:GISEditableAdd listener.- Specified by:
addGISEditableChangeListenerin interfaceGISEditable- Parameters:
listener- the listener.
-
removeGISEditableChangeListener
public void removeGISEditableChangeListener(GISEditableChangeListener listener)
Description copied from interface:GISEditableRemove listener.- Specified by:
removeGISEditableChangeListenerin interfaceGISEditable- Parameters:
listener- the listener.
-
fireElementChanged
protected final void fireElementChanged()
Fire the event that indicates this object has changed.
-
getFlags
@Pure public int getFlags()
Description copied from interface:FlagContainerReplies the flags associated to this element.The flag could be predefined (eg.
FlagContainer.FLAG_SELECTED, or user defined.- Specified by:
getFlagsin interfaceFlagContainer- Returns:
- the flags
- See Also:
FlagContainer.FLAG_SELECTED,FlagContainer.hasFlag(int),FlagContainer.setFlag(int),FlagContainer.unsetFlag(int)
-
hasFlag
@Pure public boolean hasFlag(int flagIndex)
Description copied from interface:FlagContainerReplies if the specified flag is set for this element.The flag could be predefined (eg.
FlagContainer.FLAG_SELECTED, or user defined.- Specified by:
hasFlagin interfaceFlagContainer- Parameters:
flagIndex- is the index of the flag- Returns:
trueif the flag was set, otherwisefalse- See Also:
FlagContainer.FLAG_SELECTED,FlagContainer.getFlags(),FlagContainer.setFlag(int),FlagContainer.unsetFlag(int)
-
switchFlag
public void switchFlag(int flagIndex)
Description copied from interface:FlagContainerSwitch the value of the specified flag on this element.The flag could be predefined (eg.
FlagContainer.FLAG_SELECTED, or user defined.- Specified by:
switchFlagin interfaceFlagContainer- Parameters:
flagIndex- is the index of the flag- See Also:
FlagContainer.FLAG_SELECTED,FlagContainer.getFlags(),FlagContainer.setFlag(int),FlagContainer.unsetFlag(int)
-
setFlag
public void setFlag(int flag)
Description copied from interface:FlagContainerSet the flag.The flag could be predefined (eg.
FlagContainer.FLAG_SELECTED, or user defined.- Specified by:
setFlagin interfaceFlagContainer- Parameters:
flag- is the index of the flag- See Also:
FlagContainer.FLAG_SELECTED,FlagContainer.getFlags(),FlagContainer.hasFlag(int),FlagContainer.unsetFlag(int)
-
unsetFlag
public void unsetFlag(int flagIndex)
Description copied from interface:FlagContainerUnset the flag.The flag could be predefined (eg.
FlagContainer.FLAG_SELECTED, or user defined.- Specified by:
unsetFlagin interfaceFlagContainer- Parameters:
flagIndex- is the index of the flag- See Also:
FlagContainer.FLAG_SELECTED,FlagContainer.getFlags(),FlagContainer.hasFlag(int),FlagContainer.setFlag(int)
-
isReadOnlyObject
@Pure public final boolean isReadOnlyObject()
Description copied from interface:GISEditableReplies if this editable object want to be seen as a reed-only object.Even if this object replies
true, it is possible to change its attributes. The value replied by this function is just a desire from this object. It could be used by the GUI to allow edition or not from a graphical component.- Specified by:
isReadOnlyObjectin interfaceGISEditable- Returns:
trueif this object ant to be assumed as read-only, otherwisefalse
-
setReadOnlyObject
public final void setReadOnlyObject(boolean readOnly)
Set if this editable object want to be seen as a reed-only object.Even if this object replies
true, it is possible to change its attributes. The value replied by this function is just a desire from this object. It could be used by the GUI to allow edition or not from a graphical component.- Parameters:
readOnly- the read-only flag value.
-
onAttributeChanged
protected void onAttributeChanged(String name)
This function is invoked by the attribute provider each time an attribute has changed.You should override this method to provide several feedback to the GISLayerContainer for instance.
- Parameters:
name- is the name of the attribute that changed
-
fireGraphicalAttributeChanged
protected final void fireGraphicalAttributeChanged()
Invoked when one of the graphical attributes of this element has changed, except those that change the bounding boxes.This function does not call
resetBoundingBox().In the implementation of a MapElement, prefers to call
fireGraphicalAttributeChanged()orfireShapeChanged()instead ofresetBoundingBox().If the attributes that change concern the shape (bounding box) of the element, prefers an invocation of
fireShapeChanged()instead offireGraphicalAttributeChanged()
-
fireShapeChanged
protected final void fireShapeChanged()
Invoked when the shape of this element changed.This method also reset the bounding box to allow its re-computation (with a call to
resetBoundingBox().In the implementation of a MapElement, prefers to call
fireGraphicalAttributeChanged()orfireShapeChanged()instead ofresetBoundingBox().If the attributes that change does not concern the shape (bounding box) of the element, prefers an invocation of
fireGraphicalAttributeChanged()instead offireShapeChanged()
-
resetBoundingBox
public void resetBoundingBox()
Description copied from interface:BoundedGISElementClear the current bounding box to force the computation of it at the next call toBoundedElement2afp.getBoundingBox().- Specified by:
resetBoundingBoxin interfaceBoundedGISElement- Overrides:
resetBoundingBoxin classAbstractBoundedGISElement<GISElementContainer<?>,MapElement>
-
equals
@Pure public boolean equals(Object obj)
Replies if the specified objects is the same as this one.
-
equals
@Pure public abstract boolean equals(MapElement element)
Replies if the specified objects is the same as this one.- Parameters:
element- the element to compare to.- Returns:
trueif the given element is equal to this object, otherwisefalse
-
getDistance
@Pure public abstract double getDistance(Point2D<?,?> point)
Replies the distance between this MapElement and point.- Parameters:
point- the point to compute the distance to.- Returns:
- the distance. Should be negative depending of the MapElement type.
-
contains
@Pure public abstract boolean contains(Point2D<?,?> point, double delta)
Replies if the specified point (x,y) was inside the figure of this MapElement.- Parameters:
point- is a geo-referenced coordinatedelta- is the geo-referenced distance that corresponds to a approximation distance in the screen coordinate system- Returns:
trueif the specified point has a distance nearest than delta to this element, otherwisefalse
-
contains
@Pure public final boolean contains(Point2D<?,?> point)
Replies if the specified point (x,y) was inside the figure of this MapElement.If this MapElement has no associated figure, this method always returns
false.- Parameters:
point- is a geo-referenced coordinate- Returns:
trueif this MapElement had an associated figure and the specified point was inside this bounds of this figure, otherwhisefalse
-
boundsContains
@Pure protected final boolean boundsContains(double x, double y, double delta)Replies if the specified point (x,y) was inside the bounds of this MapElement.- Parameters:
x- is a geo-referenced coordinatey- is a geo-referenced coordinatedelta- is the geo-referenced distance that corresponds to a approximation distance in the screen coordinate system- Returns:
trueif the point is inside the bounds of this object, otherwisefalse
-
intersects
@Pure public abstract boolean intersects(Shape2D<?,?,?,?,?,? extends Rectangle2afp<?,?,?,?,?,?>> rectangle)
Replies if this element has an intersection with the specified rectangle.- Parameters:
rectangle- the rectangle- Returns:
trueif this MapElement is intersecting the specified area, otherwisefalse
-
boundsIntersects
@Pure protected final boolean boundsIntersects(Shape2D<?,?,?,?,?,? extends Rectangle2afp<?,?,?,?,?,?>> rectangle)
Replies if the bounds of this element has an intersection with the specified rectangle.- Parameters:
rectangle- the rectangle.- Returns:
trueif this bounds is intersecting the specified area, otherwisefalse
-
setContainerColorUse
public void setContainerColorUse(boolean useContainerColor)
Set the flag that indicates if this element use its color or the container's color.- Parameters:
useContainerColor- must betrueif this element must use the container's color, and must befalseto use the element's color.
-
isContainerColorUsed
@Pure public boolean isContainerColorUsed()
Replies the flag that indicates if this element use its color or the container's color.- Returns:
trueif this element must use the container's color, andfalseto use the element's color.
-
getColor
@Pure public int getColor()
Description copied from interface:GISEditableReplies the color of this element or the color of the container.- Specified by:
getColorin interfaceGISEditable- Returns:
- the color.
- See Also:
GISEditable.getRawColor()
-
getRawColor
@Pure public Integer getRawColor()
Description copied from interface:GISEditableReplies the color stored inside this element.- Specified by:
getRawColorin interfaceGISEditable- Returns:
- the color of this element, or
null.
-
setColor
public void setColor(int color)
Description copied from interface:GISEditableSet the color of this element.- Specified by:
setColorin interfaceGISEditable- Parameters:
color- the new color
-
getVisualizationType
@Pure public MapElement.VisualizationType getVisualizationType()
Replies the type of visualization that must be used by this element.- Returns:
- the type of visualization
-
setVisualizationType
public void setVisualizationType(MapElement.VisualizationType type)
Set the type of visualization that must be used by this element.- Parameters:
type- the visualization type.
-
-