- 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 class
MapElement.VisualizationType
Describes how the map element was displayed.
-
Field Summary
Fields Modifier and Type Field Description static String
ATTR_COLOR
Attribute: color of the element.static String
ATTR_USE_CONTAINER_COLOR
Name of the attribute that indicates if the element must use its container's color.static String
ATTR_VISUALIZATION_TYPE
Name 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 void
addGISEditableChangeListener(GISEditableChangeListener listener)
Add listener.protected boolean
boundsContains(double x, double y, double delta)
Replies if the specified point (x,y) was inside the bounds of this MapElement.protected boolean
boundsIntersects(Shape2D<?,?,?,?,?,? extends Rectangle2afp<?,?,?,?,?,?>> rectangle)
Replies if the bounds of this element has an intersection with the specified rectangle.MapElement
clone()
Clone this object to obtain a valid copy.boolean
contains(Point2D<?,?> point)
Replies if the specified point (x,y) was inside the figure of this MapElement.abstract boolean
contains(Point2D<?,?> point, double delta)
Replies if the specified point (x,y) was inside the figure of this MapElement.boolean
equals(Object obj)
Replies if the specified objects is the same as this one.abstract boolean
equals(MapElement element)
Replies if the specified objects is the same as this one.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.protected void
fireElementChanged()
Fire the event that indicates this object has changed.protected void
fireGraphicalAttributeChanged()
Invoked when one of the graphical attributes of this element has changed, except those that change the bounding boxes.protected void
fireShapeChanged()
Invoked when the shape of this element changed.int
getColor()
Replies the color of this element or the color of the container.abstract double
getDistance(Point2D<?,?> point)
Replies the distance between this MapElement and point.int
getFlags()
Replies the flags associated to this element.Integer
getRawColor()
Replies the color stored inside this element.MapElement.VisualizationType
getVisualizationType()
Replies the type of visualization that must be used by this element.boolean
hasFlag(int flagIndex)
Replies if the specified flag is set for this element.abstract int
hashCode()
abstract boolean
intersects(Shape2D<?,?,?,?,?,? extends Rectangle2afp<?,?,?,?,?,?>> rectangle)
Replies if this element has an intersection with the specified rectangle.boolean
isContainerColorUsed()
Replies the flag that indicates if this element use its color or the container's color.boolean
isReadOnlyObject()
Replies if this editable object want to be seen as a reed-only object.protected void
onAttributeChanged(String name)
This function is invoked by the attribute provider each time an attribute has changed.void
removeGISEditableChangeListener(GISEditableChangeListener listener)
Remove listener.void
resetBoundingBox()
Clear the current bounding box to force the computation of it at the next call toBoundedElement2afp.getBoundingBox()
.void
setColor(int color)
Set the color of this element.void
setContainerColorUse(boolean useContainerColor)
Set the flag that indicates if this element use its color or the container's color.void
setFlag(int flag)
Set the flag.void
setReadOnlyObject(boolean readOnly)
Set if this editable object want to be seen as a reed-only object.void
setUUID(UUID id)
Set the unique identifier for element.void
setVisualizationType(MapElement.VisualizationType type)
Set the type of visualization that must be used by this element.void
switchFlag(int flagIndex)
Switch the value of the specified flag on this element.void
toJson(JsonBuffer buffer)
Replies the Json representation of this node.void
unsetFlag(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, ornull
if 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:JsonableObject
Replies the Json representation of this node.- Specified by:
toJson
in interfaceJsonableObject
- Overrides:
toJson
in 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:
clone
in interfaceAttributeCollection
- Specified by:
clone
in interfaceAttributeProvider
- Specified by:
clone
in interfaceGISCloneable<MapElement>
- Specified by:
clone
in interfaceGISElement
- Overrides:
clone
in 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:
setUUID
in classAbstractGISElement<GISElementContainer<?>,MapElement>
- Parameters:
id
- is the new identifier- Since:
- 4.0
-
addGISEditableChangeListener
public void addGISEditableChangeListener(GISEditableChangeListener listener)
Description copied from interface:GISEditable
Add listener.- Specified by:
addGISEditableChangeListener
in interfaceGISEditable
- Parameters:
listener
- the listener.
-
removeGISEditableChangeListener
public void removeGISEditableChangeListener(GISEditableChangeListener listener)
Description copied from interface:GISEditable
Remove listener.- Specified by:
removeGISEditableChangeListener
in 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:FlagContainer
Replies the flags associated to this element.The flag could be predefined (eg.
FlagContainer.FLAG_SELECTED
, or user defined.- Specified by:
getFlags
in 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:FlagContainer
Replies if the specified flag is set for this element.The flag could be predefined (eg.
FlagContainer.FLAG_SELECTED
, or user defined.- Specified by:
hasFlag
in interfaceFlagContainer
- Parameters:
flagIndex
- is the index of the flag- Returns:
true
if 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:FlagContainer
Switch the value of the specified flag on this element.The flag could be predefined (eg.
FlagContainer.FLAG_SELECTED
, or user defined.- Specified by:
switchFlag
in 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:FlagContainer
Set the flag.The flag could be predefined (eg.
FlagContainer.FLAG_SELECTED
, or user defined.- Specified by:
setFlag
in 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:FlagContainer
Unset the flag.The flag could be predefined (eg.
FlagContainer.FLAG_SELECTED
, or user defined.- Specified by:
unsetFlag
in 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:GISEditable
Replies 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:
isReadOnlyObject
in interfaceGISEditable
- Returns:
true
if 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:BoundedGISElement
Clear the current bounding box to force the computation of it at the next call toBoundedElement2afp.getBoundingBox()
.- Specified by:
resetBoundingBox
in interfaceBoundedGISElement
- Overrides:
resetBoundingBox
in 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:
true
if 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:
true
if 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:
true
if 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:
true
if 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:
true
if 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:
true
if 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 betrue
if this element must use the container's color, and must befalse
to 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:
true
if this element must use the container's color, andfalse
to use the element's color.
-
getColor
@Pure public int getColor()
Description copied from interface:GISEditable
Replies the color of this element or the color of the container.- Specified by:
getColor
in interfaceGISEditable
- Returns:
- the color.
- See Also:
GISEditable.getRawColor()
-
getRawColor
@Pure public Integer getRawColor()
Description copied from interface:GISEditable
Replies the color stored inside this element.- Specified by:
getRawColor
in interfaceGISEditable
- Returns:
- the color of this element, or
null
.
-
setColor
public void setColor(int color)
Description copied from interface:GISEditable
Set the color of this element.- Specified by:
setColor
in 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.
-
-