Class Layer
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
FeatureLayer
,GridLayer
,MbTilesFeatureLayer
,RasterLayer
,TileSet3DLayer
A layer has a few properties that can be changed.
- visibility
- title
An observer can be attached to get notifications about layer changes.
Use one of the concrete classes extending this class.
Note that this class tracks on which thread it is constructed. This is done so that, in subsequent calls, it can verify that the same threads are used consistently. When an inconsistency is detected, an assertion is triggered. This means that all functions on Layer
(and its subclasses) must be called on the thread on which the Map
was constructed (the "UI" thread). The only exception is adding and removing observers. Related article: Threading rules for the Map
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Property name for theLayerEvent
that is fired as a result of changing the layer's title.static final String
Property name for theLayerEvent
that is fired as a result of changing the layer's visible flag. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addObserver
(ILayerObserver layerObserver) Adds an observer that allows to receive change events from this layer.void
close()
protected void
finalize()
long
getId()
Returns the layer's unique id.getTitle()
Returns the layer's title.boolean
Returns whether this layer is visible.void
removeObserver
(ILayerObserver layerObserver) Removes the given observer.void
Sets the layer's title.void
setVisible
(boolean visible) Sets whether this layer is visible.
-
Field Details
-
PropertyTitle
Property name for theLayerEvent
that is fired as a result of changing the layer's title.- See Also:
-
PropertyVisible
Property name for theLayerEvent
that is fired as a result of changing the layer's visible flag.- See Also:
-
-
Constructor Details
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
getId
public long getId()Returns the layer's unique id.- Returns:
- the layer's unique id.
-
getTitle
Returns the layer's title.Should be suitable for presenting to the user.
- Returns:
- the layer's title, should be suitable for presenting to the user.
-
setTitle
Sets the layer's title.Should be suitable for presenting to the user.
If the new title is indeed different from the old one, a
LayerEvent
is delivered to the observers with the property name PropertyTitle.- Parameters:
title
- the new title.
-
isVisible
public boolean isVisible()Returns whether this layer is visible.- Returns:
- whether this layer is visible.
-
setVisible
public void setVisible(boolean visible) Sets whether this layer is visible.Changes this layer's visibility. If the new visibility is different from the old one, a
LayerEvent
is delivered to the observers with the property name PropertyVisible.- Parameters:
visible
- the new visibility.
-
addObserver
public void addObserver(@NotNull ILayerObserver layerObserver) throws IllegalArgumentException, NullPointerException Adds an observer that allows to receive change events from this layer.Adding the same observer twice is forbidden, and will cause an exception to be thrown.
- Parameters:
layerObserver
- an observer.- Throws:
IllegalArgumentException
- when the observer was already added.NullPointerException
- when the observer isnull
.
-
removeObserver
public void removeObserver(@NotNull ILayerObserver layerObserver) throws IllegalArgumentException, NullPointerException Removes the given observer.If the given observer was never added, an exception is thrown.
- Parameters:
layerObserver
- an observer.- Throws:
IllegalArgumentException
- when the observer is not known.NullPointerException
- when the observer isnull
.
-