- 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 classMapLayer.SpecialAttributeValueAttribute value with a special meaning in MapLayer.
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_CLICKABLEName of the attribute that indicates if the element could be clicked.static StringATTR_COLORAttribute: color of the element.static StringATTR_REMOVABLEName of the attribute that indicates if the element is removabled from its parent.static StringATTR_USE_CONTAINER_COLORName of the attribute that indicates if the element must use its container's color.static StringATTR_VISIBLEName of the attribute that indicates if the element is visible.protected ListenerCollection<?>listenersList 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 voidaddGISEditableChangeListener(GISEditableChangeListener listener)Add listener.voidaddLayerListener(MapLayerListener listener)Add a listener on the layer's events.MapLayerclone()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.booleancontains(Point2D<?,?> point, double delta)Replies if the specified point (x,y) was inside the figure of this MapElement.voidfireElementChanged()Fire the event that indicates this object has changed.voidfireLayerAttributeChangedEvent(String attributeName, Object oldValue, Object newValue)Forward to the parent layer the event that indicates the content of a child layer was changed.voidfireLayerAttributeChangedEvent(MapLayerAttributeChangeEvent event)Forward to the parent layer the event that indicates the content of a child layer was changed.voidfireLayerContentChangedEvent(MapLayerContentEvent event)Forward to the parent layer the event that indicates the content of a child layer was changed.voidfireLayerHierarchyChangedEvent(MapLayerHierarchyEvent event)Fire the event that indicates the hierarchy of layers has changed.intgetColor()Replies the color of this element or the color of the container.GeoLocationgetGeoLocation()Replies the geo-location.protected MapLayerListener[]getListeners()Replies the list of listeners on this object.StringgetParentName()Replies the name of the parent.IntegergetRawColor()Replies the color stored inside this element.intindexInParent()Replies the index of this layer in its parent.booleanintersects(Shape2d<?> rectangle)Replies if this element has an intersection with the specified rectangle.booleanisClickable()Replies if this layer accepts the user clicks.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.booleanisRemovable()Replies if this layer is removable from this container.booleanisTemporaryLayer()Replies if this layer was mark as temporary lyer.booleanisVisible()Replies if this element is assumed to be visible inside a displayer.voidonAttributeChangeEvent(AttributeChangeEvent event)Invoked when the attribute's value changed.voidremoveGISEditableChangeListener(GISEditableChangeListener listener)Remove listener.voidremoveLayerListener(MapLayerListener listener)Remove a listener on the layer's events.voidrepaint()Send a repainting query.voidresetBoundingBox()Clear the current bounding box to force the computation of it at the next call toAbstractBoundedGISElement.getBoundingBox().voidsetClickable(boolean clickable)Set if this layer accepts the user clicks.voidsetColor(int color)Set the color of this element.booleansetContainer(GISLayerContainer<?> parent)Sets the container of this MapElement.voidsetContainerColorUse(boolean useContainerColor)Set the flag that indicates if this element use its color or the container's color.voidsetReadOnlyObject(boolean readOnly)Replies if this editable object want to be seen as a reed-only object.voidsetRemovable(boolean removable)Set if this layer is removable from this container.voidsetUUID(UUID id)Set the unique identifier for element.voidsetVisible(boolean visible)Set if this element is assumed to be visible inside a displayer.voidsetVisible(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, ornullif 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, ornullif 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:
clonein interfaceAttributeCollection- Specified by:
clonein interfaceAttributeProvider- Specified by:
clonein interfaceGISCloneable<MapLayer>- Specified by:
clonein interfaceGISElement- Overrides:
clonein 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:
setUUIDin 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: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.
-
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 theMapLayerListenerand 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 theMapLayerListenerand 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 theGISEditableChangeListenerare notified.
-
onAttributeChangeEvent
public void onAttributeChangeEvent(AttributeChangeEvent event)
Invoked when the attribute's value changed.- Specified by:
onAttributeChangeEventin interfaceAttributeChangeListener- Overrides:
onAttributeChangeEventin 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 theMapLayerListenerand 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 theMapLayerListenerand 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:
resetBoundingBoxin interfaceBoundedGISElement- Overrides:
resetBoundingBoxin classAbstractBoundedGISElement<GISLayerContainer<?>,MapLayer>
-
setContainer
public boolean setContainer(GISLayerContainer<?> parent)
Description copied from class:AbstractGISElementSets the container of this MapElement.- Specified by:
setContainerin interfaceGISContentElement<GISLayerContainer<?>>- Overrides:
setContainerin classAbstractGISElement<GISLayerContainer<?>,MapLayer>- Parameters:
parent- the new container.- Returns:
- the success state of the operation.
-
getParentName
@Pure public String getParentName()
Description copied from interface:GISBrowsableReplies the name of the parent.- Specified by:
getParentNamein interfaceGISBrowsable- Returns:
- the name of the parent.
-
getGeoLocation
@Pure public GeoLocation getGeoLocation()
Description copied from interface:GISPrimitiveReplies 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:
getGeoLocationin 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:
trueif 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:
trueif 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
-1if 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:
trueif 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 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:GISBrowsableSet the color of this element.- Specified by:
setColorin interfaceGISBrowsable- Specified by:
setColorin interfaceGISEditable- Parameters:
color- the new color.
-
setClickable
public void setClickable(boolean clickable)
Set if this layer accepts the user clicks.- Parameters:
clickable- istrueto set this layer allowing mouse click events.
-
isClickable
@Pure public boolean isClickable()
Replies if this layer accepts the user clicks.- Returns:
trueif this layer allows mouse click events, otherwisefalse
-
setVisible
public final void setVisible(boolean visible)
Description copied from interface:GISBrowsableSet 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:
setVisiblein interfaceGISBrowsable- Parameters:
visible- must betrueif this element is visible, otherwisefalse
-
setVisible
public void setVisible(boolean visible, boolean setChildrenVisibility)Description copied from interface:GISBrowsableSet 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:
setVisiblein interfaceGISBrowsable- Parameters:
visible- must betrueif this element is visible, otherwisefalsesetChildrenVisibility- 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:
trueif this layer is temporary, otherwisefalse
-
isReadOnlyObject
@Pure public 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 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:GISBrowsableReplies 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:
isVisiblein interfaceGISBrowsable- Returns:
trueif 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- istrueto 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:
trueif this layer is removable from its container, otherwisefalse
-
-