Module org.arakhne.afc.gis.giscore
Package org.arakhne.afc.gis.maplayer
Class GridMapElementLayer<E extends MapElement>
- 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
-
- org.arakhne.afc.gis.maplayer.MapElementLayer<E>
-
- org.arakhne.afc.gis.maplayer.GridMapElementLayer<E>
-
- Type Parameters:
E
- is the type of the elements inside this layer.
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<E>
,EventListener
,AttributeChangeListener
,AttributeCollection
,AttributeProvider
,GISElementContainer<E>
,BoundedGISElement
,GISBrowsable
,GISCloneable<MapLayer>
,GISContainer<E>
,GISContentElement<GISLayerContainer<?>>
,GISEditable
,GISElement
,GISPrimitive
,BoundedElement2afp<Rectangle2d>
,InformedIterable<E>
,JsonableObject
public class GridMapElementLayer<E extends MapElement> extends MapElementLayer<E>
This class represents a layer that contains map elements stored in a grid data structure. The minimum size of the cells is defined byMINIMUM_CELL_SIZE
. The preferred number of cells per row or per column is given byMAXIMUM_CELL_COUNT
.- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:53
- Author:
- Stéphane GALLAND
- See Also:
ArrayMapElementLayer
,TreeMapElementLayer
, Serialized Form- Maven Group Id:
- org.arakhne.afc.gis
- Maven Artifact Id:
- giscore
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.arakhne.afc.gis.maplayer.MapLayer
MapLayer.SpecialAttributeValue
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAXIMUM_CELL_COUNT
The maximum number of cells per row or per column.static float
MINIMUM_CELL_SIZE
The minimum size of the cells (in meters).-
Fields inherited from class org.arakhne.afc.gis.maplayer.MapElementLayer
ATTR_ELEMENT_ATTRIBUTES_URL, ATTR_ELEMENT_GEOMETRY_PROJECTION, ATTR_ELEMENT_GEOMETRY_URL
-
Fields inherited from class org.arakhne.afc.gis.maplayer.MapLayer
ATTR_CLICKABLE, ATTR_COLOR, ATTR_REMOVABLE, ATTR_USE_CONTAINER_COLOR, ATTR_VISIBLE, listeners
-
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 GridMapElementLayer(boolean isTemp, Rectangle2d bounds)
Create a new layer with the specified attribute source.GridMapElementLayer(UUID id, boolean isTemp, Rectangle2d bounds)
Create a new layer with the specified attribute source.GridMapElementLayer(UUID id, AttributeCollection attributeSource, boolean isTemp, Rectangle2d bounds)
Create a new layer with the specified attribute source.GridMapElementLayer(UUID id, AttributeCollection attributeSource, Rectangle2d bounds)
Create a new layer with the specified attribute source.GridMapElementLayer(UUID id, Rectangle2d bounds)
Create a new layer with the specified attribute source.GridMapElementLayer(AttributeCollection attributeSource, boolean isTemp, Rectangle2d bounds)
Create a new layer with the specified attribute source.GridMapElementLayer(AttributeCollection attributeSource, Rectangle2d bounds)
Create a new layer with the specified attribute source.GridMapElementLayer(Rectangle2d bounds)
Create a new layer with the specified attribute source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addMapElement(E element)
Add a map element inside this container.boolean
addMapElements(Collection<? extends E> elements)
Add map elements inside this container.protected Rectangle2d
calcBounds()
Compute the bounds of this element.GridMapElementLayer<E>
clone()
Clone this object to obtain a valid copy.Set<E>
getAllMapElements()
Replies the map elements as an array.int
getColumnCount()
Replies the number of columns in the grid.Class<? extends E>
getElementType()
Replies the class of the elements in this iterable object.E
getMapElementAt(int index)
Replies the map element at the specified index.int
getMapElementCount()
Replies the count of map elements.int
getRowCount()
Replies the number of rows in the grid.Shape2d<?>
getShape()
Replies the shape of this this element.Iterator<E>
iterator()
Iterator<E>
iterator(Rectangle2afp<?,?,?,?,?,?> bounds)
Iterates on the elements that intersect the specified bounds.boolean
removeAllMapElements()
Remove all the map elements from this container.boolean
removeMapElement(MapElement element)
Remove a map element from this container.int
size()
Replies the count of map elements inside this container.-
Methods inherited from class org.arakhne.afc.gis.maplayer.MapElementLayer
bindChangeListener, fireElementChanged, fireLayerContentChangedEvent, getElementAttributeSourceURL, getElementGeometrySourceProjection, getElementGeometrySourceURL, onMapElementGraphicalAttributeChanged, setElementAttributeSourceURL, setElementGeometrySource, toJson
-
Methods inherited from class org.arakhne.afc.gis.maplayer.MapLayer
addGISEditableChangeListener, addLayerListener, contains, contains, fireLayerAttributeChangedEvent, fireLayerAttributeChangedEvent, fireLayerContentChangedEvent, fireLayerHierarchyChangedEvent, getColor, getGeoLocation, getListeners, getParentName, getRawColor, indexInParent, intersects, isClickable, isContainerColorUsed, isReadOnlyObject, isRemovable, isTemporaryLayer, isVisible, onAttributeChangeEvent, removeGISEditableChangeListener, removeLayerListener, repaint, resetBoundingBox, setClickable, setColor, setContainer, setContainerColorUse, setReadOnlyObject, setRemovable, setUUID, setVisible, setVisible
-
Methods inherited from class org.arakhne.afc.gis.primitive.AbstractBoundedGISElement
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, 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.math.geometry.d2.afp.BoundedElement2afp
getBoundingBox
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISBrowsable
setName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISContainer
getColor, getName, resetBoundingBox
-
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 java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
MINIMUM_CELL_SIZE
public static final float MINIMUM_CELL_SIZE
The minimum size of the cells (in meters).- See Also:
- Constant Field Values
-
MAXIMUM_CELL_COUNT
public static final int MAXIMUM_CELL_COUNT
The maximum number of cells per row or per column.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GridMapElementLayer
public GridMapElementLayer(Rectangle2d bounds)
Create a new layer with the specified attribute source.- Parameters:
bounds
- are the bounds covered by the layer
-
GridMapElementLayer
public GridMapElementLayer(AttributeCollection attributeSource, Rectangle2d bounds)
Create a new layer with the specified attribute source.- Parameters:
attributeSource
- is the provider of the layer's attributes.bounds
- are the bounds covered by the layer
-
GridMapElementLayer
public GridMapElementLayer(boolean isTemp, Rectangle2d bounds)
Create a new layer with the specified attribute source.- Parameters:
isTemp
- indicates if this layer is temporary.bounds
- are the bounds covered by the layer
-
GridMapElementLayer
public GridMapElementLayer(AttributeCollection attributeSource, boolean isTemp, Rectangle2d bounds)
Create a new layer with the specified attribute source.- Parameters:
attributeSource
- is the provider of the layer's attributes.isTemp
- indicates if this layer is temporary.bounds
- are the bounds covered by the layer
-
GridMapElementLayer
public GridMapElementLayer(UUID id, Rectangle2d bounds)
Create a new layer with the specified attribute source.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.bounds
- are the bounds covered by the layer
-
GridMapElementLayer
public GridMapElementLayer(UUID id, AttributeCollection attributeSource, Rectangle2d bounds)
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.bounds
- are the bounds covered by the layer
-
GridMapElementLayer
public GridMapElementLayer(UUID id, boolean isTemp, Rectangle2d bounds)
Create a new layer with the specified attribute source.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.isTemp
- indicates if this layer is temporary.bounds
- are the bounds covered by the layer
-
GridMapElementLayer
public GridMapElementLayer(UUID id, AttributeCollection attributeSource, boolean isTemp, Rectangle2d bounds)
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.bounds
- are the bounds covered by the layer
-
-
Method Detail
-
clone
@Pure public GridMapElementLayer<E> clone()
Description copied from class:MapLayer
Clone this object to obtain a valid copy.- Specified by:
clone
in interfaceAttributeCollection
- Specified by:
clone
in interfaceAttributeProvider
- Specified by:
clone
in interfaceGISCloneable<E extends MapElement>
- Specified by:
clone
in interfaceGISElement
- Overrides:
clone
in classMapLayer
- Returns:
- a copy
-
getRowCount
@Pure public int getRowCount()
Replies the number of rows in the grid.- Returns:
- the number of rows in the grid.
-
getColumnCount
@Pure public int getColumnCount()
Replies the number of columns in the grid.- Returns:
- the number of columns in the grid.
-
calcBounds
@Pure protected Rectangle2d calcBounds()
Description copied from class:AbstractBoundedGISElement
Compute the bounds of this element. This function does not update the internal attribute replied byAbstractBoundedGISElement.getBoundingBox()
- Specified by:
calcBounds
in classAbstractBoundedGISElement<GISLayerContainer<?>,MapLayer>
- Returns:
- the bounds
-
getShape
public Shape2d<?> getShape()
Description copied from interface:BoundedGISElement
Replies the shape of this this element.The bounding box replied by
BoundedElement2afp.getBoundingBox()
encloses the replied shape.- Returns:
- the shape or
null
if not applicable.
-
size
@Pure public int size()
Description copied from interface:GISContainer
Replies the count of map elements inside this container.- Returns:
- the count of map elements inside this container.
-
getMapElementAt
@Pure public E getMapElementAt(int index)
Description copied from interface:GISElementContainer
Replies the map element at the specified index.- Parameters:
index
- the index.- Returns:
- the element at the given index
-
getAllMapElements
@Pure public Set<E> getAllMapElements()
Description copied from interface:GISElementContainer
Replies the map elements as an array.- Returns:
- all the elements.
-
addMapElements
public boolean addMapElements(Collection<? extends E> elements)
Description copied from interface:GISElementContainer
Add map elements inside this container.- Parameters:
elements
- the new elements.- Returns:
true
if at least one element was added, otherwisefalse
-
addMapElement
public boolean addMapElement(E element)
Description copied from interface:GISElementContainer
Add a map element inside this container.- Parameters:
element
- the new element.- Returns:
true
if the element was added successfully, otherwisefalse
-
removeMapElement
public boolean removeMapElement(MapElement element)
Description copied from interface:GISElementContainer
Remove a map element from this container.- Parameters:
element
- the element to remove.- Returns:
true
if the element was removed successfully, otherwisefalse
-
removeAllMapElements
public boolean removeAllMapElements()
Description copied from interface:GISElementContainer
Remove all the map elements from this container.- Returns:
true
if container has changed, otherwisefalse
-
getElementType
@Pure public Class<? extends E> getElementType()
Description copied from interface:InformedIterable
Replies the class of the elements in this iterable object.- Returns:
- the type of the elements.
-
getMapElementCount
@Pure public int getMapElementCount()
Description copied from interface:GISElementContainer
Replies the count of map elements.- Returns:
- the count of map elements.
-
iterator
@Pure public Iterator<E> iterator(Rectangle2afp<?,?,?,?,?,?> bounds)
Iterates on the elements that intersect the specified bounds.- Parameters:
bounds
- is the rectangle inside which the replied elements must be located- Returns:
- an iterator on the map elements.
-
-