- java.lang.Object
-
- org.arakhne.afc.gis.primitive.AbstractGISElement<C,T>
-
- org.arakhne.afc.gis.primitive.AbstractBoundedGISElement<GISLayerContainer<?>,MapLayer>
-
- org.arakhne.afc.gis.maplayer.MapLayer
-
- All Implemented Interfaces:
Serializable
,Cloneable
,EventListener
,AttributeChangeListener
,AttributeCollection
,AttributeProvider
,BoundedGISElement
,GISBrowsable
,GISCloneable<MapLayer>
,GISContentElement<GISLayerContainer<?>>
,GISEditable
,GISElement
,GISPrimitive
,BoundedElement2afp<Rectangle2d>
,JsonableObject
- Direct Known Subclasses:
BusItineraryLayer
,MapElementLayer
,MultiMapLayer
public abstract class MapLayer extends AbstractBoundedGISElement<GISLayerContainer<?>,MapLayer> implements GISBrowsable, GISEditable, GISContentElement<GISLayerContainer<?>>
This class represents a layer. A Layer is a container of map elements or other layers.A layer could have several states:
- temporary: the layer and its content (including sublayers) are marked has temporary variables ie, the layer is assumed to not be saved when it will be closed. The events on this layers will be also marked has temporary;
- visible: the layer and its content (including sublayers) are visible or not in a displaying component;
- clickable: the layer and its content (including sublayers) are accepting mouse events;
- removable: the layer is removable from its parent. If the layer is marked has removable, it could be removed from its. This state was only useful for GUI purpose.
- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:53
- Author:
- Stéphane GALLAND
- See Also:
for a container of layer
,for a container of map elements
,for a container of map elements
,for a container of map elements
, Serialized Form- Maven Group Id:
- org.arakhne.afc.gis
- Maven Artifact Id:
- giscore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
MapLayer.SpecialAttributeValue
Attribute value with a special meaning in MapLayer.
-
Field Summary
Fields Modifier and Type Field Description static String
ATTR_CLICKABLE
Name of the attribute that indicates if the element could be clicked.static String
ATTR_COLOR
Attribute: color of the element.static String
ATTR_REMOVABLE
Name of the attribute that indicates if the element is removabled from its parent.static String
ATTR_USE_CONTAINER_COLOR
Name of the attribute that indicates if the element must use its container's color.static String
ATTR_VISIBLE
Name of the attribute that indicates if the element is visible.protected ListenerCollection<?>
listeners
List of listeners on the events.-
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 MapLayer(UUID id, AttributeCollection attributeSource)
Create a new layer with the specified attribute source.MapLayer(UUID id, AttributeCollection attributeSource, boolean isTemp)
Create a new layer with the specified attribute source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGISEditableChangeListener(GISEditableChangeListener listener)
Add listener.void
addLayerListener(MapLayerListener listener)
Add a listener on the layer's events.MapLayer
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.boolean
contains(Point2D<?,?> point, double delta)
Replies if the specified point (x,y) was inside the figure of this MapElement.void
fireElementChanged()
Fire the event that indicates this object has changed.void
fireLayerAttributeChangedEvent(String attributeName, Object oldValue, Object newValue)
Forward to the parent layer the event that indicates the content of a child layer was changed.void
fireLayerAttributeChangedEvent(MapLayerAttributeChangeEvent event)
Forward to the parent layer the event that indicates the content of a child layer was changed.void
fireLayerContentChangedEvent(MapLayerContentEvent event)
Forward to the parent layer the event that indicates the content of a child layer was changed.void
fireLayerHierarchyChangedEvent(MapLayerHierarchyEvent event)
Fire the event that indicates the hierarchy of layers has changed.int
getColor()
Replies the color of this element or the color of the container.GeoLocation
getGeoLocation()
Replies the geo-location.protected MapLayerListener[]
getListeners()
Replies the list of listeners on this object.String
getParentName()
Replies the name of the parent.Integer
getRawColor()
Replies the color stored inside this element.int
indexInParent()
Replies the index of this layer in its parent.boolean
intersects(Shape2d<?> rectangle)
Replies if this element has an intersection with the specified rectangle.boolean
isClickable()
Replies if this layer accepts the user clicks.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.boolean
isRemovable()
Replies if this layer is removable from this container.boolean
isTemporaryLayer()
Replies if this layer was mark as temporary lyer.boolean
isVisible()
Replies if this element is assumed to be visible inside a displayer.void
onAttributeChangeEvent(AttributeChangeEvent event)
Invoked when the attribute's value changed.void
removeGISEditableChangeListener(GISEditableChangeListener listener)
Remove listener.void
removeLayerListener(MapLayerListener listener)
Remove a listener on the layer's events.void
repaint()
Send a repainting query.void
resetBoundingBox()
Clear the current bounding box to force the computation of it at the next call toAbstractBoundedGISElement.getBoundingBox()
.void
setClickable(boolean clickable)
Set if this layer accepts the user clicks.void
setColor(int color)
Set the color of this element.boolean
setContainer(GISLayerContainer<?> parent)
Sets the container of this MapElement.void
setContainerColorUse(boolean useContainerColor)
Set the flag that indicates if this element use its color or the container's color.void
setReadOnlyObject(boolean readOnly)
Replies if this editable object want to be seen as a reed-only object.void
setRemovable(boolean removable)
Set if this layer is removable from this container.void
setUUID(UUID id)
Set the unique identifier for element.void
setVisible(boolean visible)
Set if this element is assumed to be visible inside a displayer.void
setVisible(boolean visible, boolean setChildrenVisibility)
Set if this element is assumed to be visible inside a displayer.-
Methods inherited from class org.arakhne.afc.gis.primitive.AbstractBoundedGISElement
calcBounds, getBoundingBox, setBoundingBox, toJson
-
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, 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, setName, toMap, toMap, toString
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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.GISBrowsable
setName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISContentElement
getContainer, getTopContainer
-
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, getUUID
-
Methods inherited from interface org.arakhne.afc.vmutil.json.JsonableObject
toJson
-
-
-
-
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_CLICKABLE
public static final String ATTR_CLICKABLE
Name of the attribute that indicates if the element could be clicked.- See Also:
- Constant Field Values
-
ATTR_VISIBLE
public static final String ATTR_VISIBLE
Name of the attribute that indicates if the element is visible.- See Also:
- Constant Field Values
-
ATTR_REMOVABLE
public static final String ATTR_REMOVABLE
Name of the attribute that indicates if the element is removabled from its parent.- See Also:
- Constant Field Values
-
listeners
protected transient ListenerCollection<?> listeners
List of listeners on the events.
-
-
Constructor Detail
-
MapLayer
public MapLayer(UUID id, AttributeCollection attributeSource)
Create a new layer with the specified attribute source.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.attributeSource
- is the provider of the layer's attributes.- Since:
- 4.0
-
MapLayer
public MapLayer(UUID id, AttributeCollection attributeSource, boolean isTemp)
Create a new layer with the specified attribute source.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.attributeSource
- is the provider of the layer's attributes.isTemp
- indicates if this layer is temporary.- Since:
- 4.0
-
-
Method Detail
-
clone
@Pure public MapLayer clone()
Clone this object to obtain a valid copy.- Specified by:
clone
in interfaceAttributeCollection
- Specified by:
clone
in interfaceAttributeProvider
- Specified by:
clone
in interfaceGISCloneable<MapLayer>
- Specified by:
clone
in interfaceGISElement
- Overrides:
clone
in classAbstractBoundedGISElement<GISLayerContainer<?>,MapLayer>
- 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<GISLayerContainer<?>,MapLayer>
- Parameters:
id
- is the new identifier- Since:
- 4.0
-
addLayerListener
public final void addLayerListener(MapLayerListener listener)
Add a listener on the layer's events.- Parameters:
listener
- the listener.
-
removeLayerListener
public final void removeLayerListener(MapLayerListener listener)
Remove a listener on the layer's events.- Parameters:
listener
- the listener.
-
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.
-
getListeners
@Pure protected final MapLayerListener[] getListeners()
Replies the list of listeners on this object.- Returns:
- the list of listeners on this object.
-
fireLayerHierarchyChangedEvent
public void fireLayerHierarchyChangedEvent(MapLayerHierarchyEvent event)
Fire the event that indicates the hierarchy of layers has changed. Only theMapLayerListener
and the container are notified.- Parameters:
event
- the event.
-
fireLayerContentChangedEvent
public void fireLayerContentChangedEvent(MapLayerContentEvent event)
Forward to the parent layer the event that indicates the content of a child layer was changed. Only theMapLayerListener
and the container are notified.- Parameters:
event
- the event.
-
repaint
public final void repaint()
Send a repainting query. Notify listeners about any change in the layer which cause repaint of the panel.
-
fireElementChanged
public void fireElementChanged()
Fire the event that indicates this object has changed. Only theGISEditableChangeListener
are notified.
-
onAttributeChangeEvent
public void onAttributeChangeEvent(AttributeChangeEvent event)
Invoked when the attribute's value changed.- Specified by:
onAttributeChangeEvent
in interfaceAttributeChangeListener
- Overrides:
onAttributeChangeEvent
in classAbstractGISElement<GISLayerContainer<?>,MapLayer>
- Parameters:
event
- describes the changes.
-
fireLayerAttributeChangedEvent
public void fireLayerAttributeChangedEvent(MapLayerAttributeChangeEvent event)
Forward to the parent layer the event that indicates the content of a child layer was changed. Only theMapLayerListener
and the container are notified.- Parameters:
event
- the event
-
fireLayerAttributeChangedEvent
public void fireLayerAttributeChangedEvent(String attributeName, Object oldValue, Object newValue)
Forward to the parent layer the event that indicates the content of a child layer was changed. Only theMapLayerListener
and the container are notified.- Parameters:
attributeName
- is the name of the changed attribute.oldValue
- is the old value of the attribute.newValue
- is the new value of the attribute.
-
resetBoundingBox
public void resetBoundingBox()
Clear the current bounding box to force the computation of it at the next call toAbstractBoundedGISElement.getBoundingBox()
.- Specified by:
resetBoundingBox
in interfaceBoundedGISElement
- Overrides:
resetBoundingBox
in classAbstractBoundedGISElement<GISLayerContainer<?>,MapLayer>
-
setContainer
public boolean setContainer(GISLayerContainer<?> parent)
Description copied from class:AbstractGISElement
Sets the container of this MapElement.- Specified by:
setContainer
in interfaceGISContentElement<GISLayerContainer<?>>
- Overrides:
setContainer
in classAbstractGISElement<GISLayerContainer<?>,MapLayer>
- Parameters:
parent
- the new container.- Returns:
- the success state of the operation.
-
getParentName
@Pure public String getParentName()
Description copied from interface:GISBrowsable
Replies the name of the parent.- Specified by:
getParentName
in interfaceGISBrowsable
- Returns:
- the name of the parent.
-
getGeoLocation
@Pure public GeoLocation getGeoLocation()
Description copied from interface:GISPrimitive
Replies the geo-location.A GeoLocation is unique according to the geo-location of the element. If two elements have the same points in the same order, or if two elements have the same points in a reverse order, they must have equal GeoLocations.
The following code is always true (where the arguments of the constructors are the list of points of the polyline). It illustrates that for two elements with the same geo-localized points, they have the same geo-location identifier (Geo-Id) and they have different unique ientifier (Uid):
GISElement obj1 = new MapPolyline(100,10,200,30,300,4); GISElement obj2 = new MapPolyline(100,10,200,30,300,4); assert( obj1.getGeoId().equals(obj2.getGeoId()) ); assert( obj2.getGeoId().equals(obj1.getGeoId()) ); assert( ! obj1.getUid().equals(obj2.getUid()) ); assert( ! obj2.getUid().equals(obj1.getUid()) );
- Specified by:
getGeoLocation
in interfaceGISPrimitive
- Returns:
- a location
- See Also:
GISPrimitive.getGeoId()
,GISPrimitive.getGeoLocation()
-
contains
@Pure public boolean contains(Point2D<?,?> point, double delta)
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 coordinatedelta
- is the geo-referenced distance that corresponds to a approximation distance in the screen coordinate system- Returns:
true
if this MapElement had an associated figure and the specified point was inside this bounds of this figure, otherwhisefalse
-
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
-
indexInParent
@Pure public int indexInParent()
Replies the index of this layer in its parent.- Returns:
- the index of this layer in its parent, or
-1
if not found.
-
intersects
@Pure public boolean intersects(Shape2d<?> rectangle)
Replies if this element has an intersection with the specified rectangle.If this MapElement has no associated figure, this method always returns
false
.- Parameters:
rectangle
- the rectangle.- Returns:
true
if this MapElement has an associated figure and the specified rectangle intersecting the figure, otherwhisefalse
-
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:GISBrowsable
Set the color of this element.- Specified by:
setColor
in interfaceGISBrowsable
- Specified by:
setColor
in interfaceGISEditable
- Parameters:
color
- the new color.
-
setClickable
public void setClickable(boolean clickable)
Set if this layer accepts the user clicks.- Parameters:
clickable
- istrue
to set this layer allowing mouse click events.
-
isClickable
@Pure public boolean isClickable()
Replies if this layer accepts the user clicks.- Returns:
true
if this layer allows mouse click events, otherwisefalse
-
setVisible
public final void setVisible(boolean visible)
Description copied from interface:GISBrowsable
Set if this element is assumed to be visible inside a displayer. This flag should not be used to adapt the visibility of the element inside the browser.- Specified by:
setVisible
in interfaceGISBrowsable
- Parameters:
visible
- must betrue
if this element is visible, otherwisefalse
-
setVisible
public void setVisible(boolean visible, boolean setChildrenVisibility)
Description copied from interface:GISBrowsable
Set if this element is assumed to be visible inside a displayer. This flag should not be used to adapt the visibility of the element inside the browser.- Specified by:
setVisible
in interfaceGISBrowsable
- Parameters:
visible
- must betrue
if this element is visible, otherwisefalse
setChildrenVisibility
- indicates if the children visibility should be also changed in turn.
-
isTemporaryLayer
@Pure public final boolean isTemporaryLayer()
Replies if this layer was mark as temporary lyer.A temporary layer means that any things inside this layer is assumed to be lost when the layer will be destroyed.
- Returns:
true
if this layer is temporary, otherwisefalse
-
isReadOnlyObject
@Pure public 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 void setReadOnlyObject(boolean readOnly)
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.- Parameters:
readOnly
- the read-only flag.
-
isVisible
@Pure public boolean isVisible()
Description copied from interface:GISBrowsable
Replies if this element is assumed to be visible inside a displayer. This flag should not be used to adapt the visibility of the element inside the browser.- Specified by:
isVisible
in interfaceGISBrowsable
- Returns:
true
if this element is visible, otherwisefalse
-
setRemovable
public void setRemovable(boolean removable)
Set if this layer is removable from this container. This removal value permits to the container to be informed about the desired removal state from its component. The usage of this state by the container depends only of its implementation.- Parameters:
removable
- istrue
to set this layer to be removable from its container, otherwisefalse
-
isRemovable
@Pure public boolean isRemovable()
Replies if this layer is removable from this container. This removal value permits to the container to be informed about the desired removal state from its component. The usage of this state by the container depends only of its implementation.- Returns:
true
if this layer is removable from its container, otherwisefalse
-
-