public abstract class Layer extends LocalizedObject implements ILayer, LayerNode, LayerConstants, JMapEventDispatcher, java.lang.Cloneable, java.lang.Comparable<Layer>
All layer instances are managed by a layer manager (LayerManager). When the map is drawn on a view (View), all layers managed by the layer manager associated with this view are drawn, one on top of the other, starting with the lower position layer up to the higher position layer. Every layer has one or more style objects (Style) that define how the content of the layer is rendered in the view.
LayerManager
,
Style
,
Serialized FormModifier and Type | Field and Description |
---|---|
static K2DTransform |
DEFAULT_DRAW_STATE |
protected java.lang.String |
description
The description of the layer.
|
static int |
DRAW_OPTIONS_SYNC
Constant used to specify that layer drawing should be done synchronously.
|
protected K2DTransform |
drawState |
protected int |
dynamicRefresh |
protected K2DElementFactory |
elementFactory |
protected int |
elementType
The type of elements this layer contains.
|
protected LayerEventDispatcher |
eventDispatcher |
protected int |
id
The id of the layer.
|
protected JMapClientInfoReportConfig |
infoReportConfig |
protected long |
lastUpdateTime |
static int |
LAYER_ID_HIGHLIGHT
This constant refers to the reserved layer id for the layer containing
highlight objects NOTE: different than SYS_DRAWINGS layer because the
highlight tool constantly changes its location depending on the highlighted
layer
|
static int |
LAYER_ID_INITIAL_VIEW_BOUNDS
This constant refers to a reserved layer id used by the administration
extension.
|
static int |
LAYER_ID_LABELS
This constant refers to the reserved layer id for the layer containing the
labels
|
static int |
LAYER_ID_MARKERS
This constant refers to a reserved layer id used for the View Markers.
|
static int |
LAYER_ID_SYS_DRAWINGS
This constant refers to a reserved layer id used by drawing tools.
|
static int |
LAYER_ID_TMP_DRAWINGS
This constant refers to the reserved layer id for the layer containing the
temporary drawings Ex: DistanceTool, temporary line drawn when the user
moves the mouse 3D Distance/routing, possible route choices
|
static int |
LAYER_ID_USER_DRAWINGS
Set the correct numbers for the constants below, and use constants instead
of specifying the ID everywhere in JMap This constant refers to the
reserved layer id for the layer containing the user drawings
|
static int |
LAYER_ID_USER_LABELS
This constant refers to a reserved layer id used for user layer labeling.
|
protected long |
layerProperties
Layer properties are stored as bitwise values in this property.
|
protected double |
maximumVisibleScale |
protected java.lang.String |
metadataUrl |
protected double |
minimumVisibleScale |
protected java.lang.String |
name
The name of the layer.
|
protected PrecisionModel |
precisionModel |
protected long |
readOnlyProperties |
protected StyleManager |
styleManager |
protected boolean |
verbose |
serialVersionUID
DEFAULT_MAXIMUM_SCALE, DEFAULT_MINIMUM_SCALE, PERSONAL_LAYER_BASE_ID, PERSONAL_LAYER_MAX_ID, PROJECT_LAYER_BASE_ID, PROJECT_LAYER_MAX_ID, PROPERTY_ALL_SETTINGS, PROPERTY_ALWAYS_DRAW_SELECTION, PROPERTY_DRAW_GRID, PROPERTY_EDITABLE, PROPERTY_EDITING, PROPERTY_INCLUDE_IN_CONTEXT, PROPERTY_INDEX, PROPERTY_LISTED, PROPERTY_LOCAL, PROPERTY_MAX_SCALE, PROPERTY_MIN_SCALE, PROPERTY_PUBLISHED, PROPERTY_QUERIABLE, PROPERTY_SELECTABLE, PROPERTY_USE_CLIENT_CACHE, PROPERTY_VISIBLE, REQUEST_MODE_BY_REGION, REQUEST_MODE_BY_TILE, RESERVED_LAYER_BASE_ID, RESERVED_LAYER_MAX_ID, SYSTEM_LAYER_BASE_AUTO_ID, SYSTEM_LAYER_BASE_ID, SYSTEM_LAYER_MAX_ID, TILING_MODE_AUTO, TILING_MODE_MANUAL, USER_LAYER_BASE_AUTO_ID, USER_LAYER_BASE_ID, USER_LAYER_MAX_ID
Modifier | Constructor and Description |
---|---|
protected |
Layer()
Empty constructor.
|
|
Layer(int id,
int geometryType,
int elementType,
java.lang.String name,
boolean isVisible)
Deprecated.
|
|
Layer(int id,
java.lang.String name,
int elementType)
Creates a new Layer using the specified parameters.
The new layer will be configured with only one tile with an infinite size. |
|
Layer(LayerInfo layerInfo)
Initializes the new layer using the specified JMapClientLayerInfo.
|
Modifier and Type | Method and Description |
---|---|
void |
addLayerEventListener(LayerEventListener listener)
Added the specified listener to the layer listeners list.
|
abstract java.lang.Object |
clone()
Returns a deep clone of the current LayerInfo instance.
|
protected void |
clone(ILayer layer)
Implementation of the clone method.
|
abstract void |
close()
Frees all resources used by the layer.
|
int |
compareTo(Layer layer)
Compares this object with the specified layer for order.
|
void |
dispatchEvent(JMapEvent event)
The
dispatchEvent method is used to dispatch synchronously
JMap events to all registered listeners. |
abstract void |
draw(GraphicsRef gr,
ViewState vs,
OrientedRectangle region,
double scale,
DrawParameters parameters)
Draws layer contained in the specified region to the specified graphics
object and applying the specified transformation.
|
void |
draw(GraphicsRef gr,
ViewState vs,
OrientedRectangle region,
double scale,
int drawOptions)
Deprecated.
|
boolean |
drawGrid()
Returns the draw grid state.
|
abstract void |
drawGrid(GraphicsRef gr,
K2DTransform t)
Draws the tile grid for the layer.
|
protected void |
fireLayerPropertyBeforeChangeEvent(byte property) |
protected void |
fireLayerPropertyChangedEvent(byte property) |
protected void |
fireLayerReceivedDataEvent(LayerReceivedDataEvent event,
boolean sync) |
protected void |
fireRefreshRequestEvent()
Fires refresh request event so that the listener can handle the event
properly
|
protected void |
fireStyleChangedEvent() |
java.lang.String |
getDescription()
Returns the description of the layer.
|
java.lang.String |
getDescription(java.util.Locale locale)
Returns the description of this layer for a specific locale.
|
int |
getDynamicRefresh()
Gets the time at which a layer is automatically refreshed
|
K2DElementFactory |
getElementFactory()
Returns the K2DElementFactory configured for the layer.
|
int |
getElementType()
Returns the layer element type.
|
abstract Rectangle |
getExtent()
Returns the extent of the layer.
|
int |
getId()
Returns the id of the layer.
|
JMapClientInfoReportConfig |
getInfoReportConfig()
Return the information report configuration of the layer.
|
long |
getLastUpdateTime()
Gets the last updated time
|
long |
getLayerProperties()
Returns a bitwise value that contains all layer properties.
|
double |
getMaximumVisibleScale()
Gets the maximum scale at which the layer should be visible.
|
java.lang.String |
getMetadataUrl()
Returns the metadata URL.
|
double |
getMinimumVisibleScale()
Gets the minimum scale at which the layer should be visible.
|
java.lang.String |
getName()
Returns the name of the layer.
|
java.lang.String |
getName(java.util.Locale locale)
Returns the name of this layer for a specific locale.
|
static int |
getNextSystemLayerId() |
static int |
getNextUserLayerId() |
PrecisionModel |
getPrecisionModel()
Returns the precision model to use for geometrical operations.
|
long |
getReadOnlyProperties()
Returns the a mask which contains all read-only properties for this layer.
|
abstract int |
getRequestMode()
Returns the request mode for this layer.
|
Style |
getSelectionStyle()
Returns the default selection style object associated with the layer.
Note: If this layer has more than one style (depending on the zoom level), the lowest level selection style is returned. |
Style |
getSelectionStyle(double scale)
Returns the selection style object associated with the layer for the
specified scale.
|
Style |
getStyle()
Returns the default style object associated with the layer.
Note: If this layer has more than one style (depending on the zoom level), the lowest level style is returned. |
Style |
getStyle(double scale)
Returns the style object associated with the layer (used to draw elements
of the layer).
|
StyleManager |
getStyleManager()
Returns the StyleManager instance used by the Layer.
|
boolean |
getVerbose()
Returns whether or not the verbose mode is enabled.
|
protected LayerEventDispatcher |
initEventDispatcher() |
void |
invalidate()
Invalidates the cached data for vector and raster layers.
|
boolean |
isDrawable(double scale)
Returns true if this layer should be drawn at the specified scale.
|
boolean |
isDynamic() |
boolean |
isIncludeInContext()
Returns whether or not this layer should be included in contexts.
|
boolean |
isIndex()
Returns whether or not this layer should be drawn in the client overview.
|
boolean |
isListed()
Returns the current listed state of the layer.
|
boolean |
isLocal()
Returns the current local state of the layer.
|
boolean |
isNamed(java.lang.String value)
Checks if the layer is named (including available translations, case
insensitive) as the specified value.
|
static boolean |
isPersonalLayerId(int layerId) |
static boolean |
isProjectLayerId(int layerId) |
boolean |
isQueriable()
Deprecated.
As of release 4.0, the QUERIABLE property is not used anymore
|
static boolean |
isReservedLayerId(int layerId) |
boolean |
isSelectable()
Returns the current selectable state of the layer.
|
static boolean |
isSystemLayerId(int layerId) |
static boolean |
isUserLayerId(int layerId) |
boolean |
isVisible()
Returns the current visibility state of the layer
|
abstract void |
loadData(Geometry bounds,
boolean sync)
This method automatically loads the data intersecting with the specified
geometry.
|
void |
removeLayerEventListener(LayerEventListener listener)
Removes the specified listener from the layer listeners list.
|
void |
removeTranslationsOtherThan(java.util.Locale[] locales)
Removes any
Locale from this object that are not in the specified locales . |
void |
revalidate(K2DTransform tr)
Revalidates cached data based on the specified affine transformation.
|
void |
setDescription(java.lang.String description)
Sets the description string for the layer.
|
void |
setDescription(java.lang.String description,
java.util.Locale locale)
Sets the description of this layer for the specified Locale.
|
void |
setDrawGrid(boolean drawGrid)
Sets the draw grid state.
|
void |
setDynamicRefresh(int seconds)
Sets the time at which a layer is automatically refreshed.
|
void |
setElementFactory(K2DElementFactory elementFactory)
Sets the K2DElementFactory to be used by this layer.
|
void |
setElementType(int elementType)
Sets the layer element type.
|
void |
setId(int id)
Sets the id of the layer.
|
void |
setIncludeInContext(boolean includeInContext)
Sets whether or not this layer should be included in contexts.
|
void |
setIndex(boolean flag)
Sets whether or not this layer should be drawn in the client overview.
|
void |
setInfoReportConfig(JMapClientInfoReportConfig infoReportConfig)
Sets the information report configuration of the layer.
|
void |
setLastUpdateTime(long lastUpdateTime)
Sets the last updated time
|
void |
setLayerProperties(long value)
Sets all layer properties.
|
void |
setListed(boolean listed)
Sets the listed state of the layer.
|
void |
setLocal(boolean flag)
Sets the local state of the layer.
|
void |
setMaximumVisibleScale(double scale)
Sets the maximum scale at which the layer should be visible.
|
void |
setMetadataUrl(java.lang.String metadataUrl)
Sets the metadata URL.
|
void |
setMinimumVisibleScale(double scale)
Sets the minimum scale at which the layer should be visible.
|
void |
setName(java.lang.String name)
Sets the layer name.
|
void |
setName(java.lang.String name,
java.util.Locale locale)
Sets the name of this layer for the specified Locale.
|
void |
setPrecisionModel(PrecisionModel precisionModel)
Sets the precision model to use for geometrical operations.
|
void |
setProperty(long property,
boolean enabled)
Sets the state for the specified property.
|
void |
setQueriable(boolean flag)
Deprecated.
As of release 4.0, the QUERIABLE property is not used anymore
|
void |
setReadOnlyProperties(long value)
Sets all read-only properties for the layer.
|
void |
setReadOnlyProperty(long property,
boolean isReadOnly)
Sets the read-only state for the specified property.
|
void |
setSelectable(boolean flag)
Sets the selectable state of the layer.
|
void |
setStyle(Style style)
Deprecated.
since JMap 2.5
|
void |
setStyle(Style style,
double scale)
Sets the default style at the specified scale for this layer.
|
void |
setStyleManager(StyleManager styleManager)
Sets the StyleManager object to be used by the Layer.
|
void |
setVerbose(boolean verbose)
Sets the verbose mode of the layer.
|
void |
setVisible(boolean flag)
Sets the visibility state of the layer.
|
void |
setVisible(boolean flag,
boolean fireEvent)
Sets the visibility state of the layer.
|
abstract LayerInfo |
toLayerInfo() |
java.lang.String |
toString()
Returns the name of the current layer.
|
void |
update(ILayer layer) |
getAvailableLocales, getTranslation, isTranslationExists, setTranslation, updateTranslations
public static final int LAYER_ID_LABELS
public static final int LAYER_ID_HIGHLIGHT
public static final int LAYER_ID_USER_DRAWINGS
public static final int LAYER_ID_TMP_DRAWINGS
public static final int LAYER_ID_SYS_DRAWINGS
public static final int LAYER_ID_USER_LABELS
public static final int LAYER_ID_INITIAL_VIEW_BOUNDS
public static final int LAYER_ID_MARKERS
public static final int DRAW_OPTIONS_SYNC
LayerManager.DRAW_SYNC
,
Constant Field Valuespublic static final K2DTransform DEFAULT_DRAW_STATE
protected int id
protected java.lang.String name
protected java.lang.String description
protected int elementType
protected long layerProperties
protected long readOnlyProperties
protected double maximumVisibleScale
protected double minimumVisibleScale
protected StyleManager styleManager
protected final LayerEventDispatcher eventDispatcher
protected long lastUpdateTime
protected K2DElementFactory elementFactory
protected JMapClientInfoReportConfig infoReportConfig
protected boolean verbose
protected K2DTransform drawState
protected PrecisionModel precisionModel
protected java.lang.String metadataUrl
protected int dynamicRefresh
protected Layer()
public Layer(int id, java.lang.String name, int elementType)
id
- the id of the new layer.name
- the name.elementType
- the element type.@Deprecated public Layer(int id, int geometryType, int elementType, java.lang.String name, boolean isVisible)
id
- the id of the new layer.geometryType
- the geometry type.elementType
- the element type.name
- the name.isVisible
- whether or not this layer is visible.public Layer(LayerInfo layerInfo)
layerInfo
- the new layer configuration.public static int getNextUserLayerId()
public static int getNextSystemLayerId()
public static boolean isProjectLayerId(int layerId)
public static boolean isSystemLayerId(int layerId)
public static boolean isReservedLayerId(int layerId)
public static boolean isUserLayerId(int layerId)
public static boolean isPersonalLayerId(int layerId)
protected LayerEventDispatcher initEventDispatcher()
public void setVerbose(boolean verbose)
verbose
- the verbose modepublic boolean getVerbose()
public final void setProperty(long property, boolean enabled)
setProperty
in interface ILayer
property
- the property to set.enabled
- the property state.public final void setReadOnlyProperty(long property, boolean isReadOnly)
setReadOnlyProperty
in interface ILayer
property
- the property to set.isReadOnly
- the read-only state.public long getReadOnlyProperties()
getReadOnlyProperties
in interface ILayer
public void setReadOnlyProperties(long value)
setReadOnlyProperties
in interface ILayer
value
- a bitwise value that contains all read-only layer properties.public long getLayerProperties()
getLayerProperties
in interface ILayer
public void setLayerProperties(long value)
setLayerProperties
in interface ILayer
value
- a bitwise value that contains all layer properties.public long getLastUpdateTime()
getLastUpdateTime
in interface ILayer
public void setLastUpdateTime(long lastUpdateTime)
setLastUpdateTime
in interface ILayer
lastUpdateTime
- the last updated timepublic void addLayerEventListener(LayerEventListener listener)
listener
- the listener to add.public void removeLayerEventListener(LayerEventListener listener)
listener
- the listener to remove.public boolean isDrawable(double scale)
scale
- the scale used for the calculation.public java.lang.String getName()
public java.lang.String getName(java.util.Locale locale)
public boolean isNamed(java.lang.String value)
value
- public java.lang.String getDescription()
getDescription
in interface ILayer
public java.lang.String getDescription(java.util.Locale locale)
getDescription
in interface ILayer
locale
- public void setDescription(java.lang.String description)
setDescription
in interface ILayer
description
- the description stringpublic void setDescription(java.lang.String description, java.util.Locale locale)
setDescription
in interface ILayer
description
- the new given description.locale
- the locale for this descriptionpublic int getId()
public void setId(int id)
public void setVisible(boolean flag)
setVisible
in interface ILayer
setVisible
in interface LayerNode
flag
- if true, the layer will be visible otherwise invisiblepublic void setVisible(boolean flag, boolean fireEvent)
flag
- if true, the layer will be visible otherwise invisiblefireEvent
- if true, firePropertyChangedEvent and fireVisibilityEvent are
firedpublic boolean isVisible()
@Deprecated public void setQueriable(boolean flag)
flag
- if true, the layer will be queriable otherwise not queriable@Deprecated public boolean isQueriable()
public void setSelectable(boolean flag)
setSelectable
in interface ILayer
flag
- if true, the layer will be selectable otherwise not selectablepublic boolean isSelectable()
isSelectable
in interface ILayer
public void setLocal(boolean flag)
public boolean isLocal()
public void setListed(boolean listed)
public boolean isListed()
public void setIncludeInContext(boolean includeInContext)
includeInContext
- true defines that this layer should be included in contexts.public boolean isIncludeInContext()
public boolean drawGrid()
public void setDrawGrid(boolean drawGrid)
drawGrid
- if true, the grid will be drawnpublic boolean isIndex()
public void setIndex(boolean flag)
public Style getStyle()
StyleManager.getStyle(double scale)
public Style getStyle(double scale)
scale
- the scale of the current View.Style
public Style getSelectionStyle()
Style
,
StyleManager.getSelectionStyle(double scale)
public Style getSelectionStyle(double scale)
scale
- the scale of the current View.Style
,
StyleManager.getSelectionStyle(double scale)
@Deprecated public void setStyle(Style style)
style
- the new default style for the layerLayerStyleChangedEvent
public void setStyleManager(StyleManager styleManager)
setStyleManager
in interface ILayer
styleManager
- the style manager to be used.public StyleManager getStyleManager()
getStyleManager
in interface ILayer
public void setStyle(Style style, double scale)
style
- the new default style for the layerscale
- the scale of the Style to replace.Style
,
LayerStyleChangedEvent
protected void fireStyleChangedEvent()
public abstract int getRequestMode()
public abstract Rectangle getExtent()
public abstract void drawGrid(GraphicsRef gr, K2DTransform t)
gr
- the Graphics wrapper object used to draw the gridt
- the 2D transformation matrix used to draw the grid@Deprecated public void draw(GraphicsRef gr, ViewState vs, OrientedRectangle region, double scale, int drawOptions)
draw(GraphicsRef, ViewState, OrientedRectangle, double, DrawParameters)
instead.gr
- the graphics wrapper object to use.vs
- the view state that provides context information to draw the
layer.region
- the world coordinate region to redraw.scale
- the scale of the current View.drawOptions
- draw options to use. Options can be retrieved with bitwise
operations using LayerManager.DRAW_*
constants.for available draw options constants.
public abstract void draw(GraphicsRef gr, ViewState vs, OrientedRectangle region, double scale, DrawParameters parameters)
gr
- the graphics wrapper object to use.vs
- the view state that provides context information to draw the
layer.region
- the world coordinate region to redraw.scale
- the scale of the current View.parameters
- draw parameters.public abstract void close()
public void dispatchEvent(JMapEvent event)
dispatchEvent
method is used to dispatch synchronously
JMap events to all registered listeners. The main use of the JMapEventDispatcher
interface is to dispatch events that were previously added to the JMap event queue. LayerEvent
will be accepted by this method. Any
other JMap event types will cause the layer to throw an exception.dispatchEvent
in interface JMapEventDispatcher
event
- the event to be dispatched.java.lang.IllegalArgumentException
- will be thrown if the JMapEvent
instance is no an
instance of the LayerEvent
class.JMapEventQueue.push(JMapEvent, JMapEventDispatcher)
protected void fireLayerReceivedDataEvent(LayerReceivedDataEvent event, boolean sync)
protected void fireRefreshRequestEvent()
protected void fireLayerPropertyChangedEvent(byte property)
protected void fireLayerPropertyBeforeChangeEvent(byte property)
public void setMinimumVisibleScale(double scale)
setMinimumVisibleScale
in interface ILayer
scale
- the minimum scale limit for the layerpublic double getMinimumVisibleScale()
getMinimumVisibleScale
in interface ILayer
public void setMaximumVisibleScale(double scale)
setMaximumVisibleScale
in interface ILayer
scale
- the maximum scale limit for the layerpublic double getMaximumVisibleScale()
getMaximumVisibleScale
in interface ILayer
public void setName(java.lang.String name)
public void setName(java.lang.String name, java.util.Locale locale)
public K2DElementFactory getElementFactory()
getElementFactory
in interface ILayer
public void setElementFactory(K2DElementFactory elementFactory)
setElementFactory
in interface ILayer
elementFactory
- the K2DElementFactory to use.public int getElementType()
getElementType
in interface ILayer
ElementTypes
public void setElementType(int elementType)
setElementType
in interface ILayer
elementType
- the element type to set.ElementTypes
public JMapClientInfoReportConfig getInfoReportConfig()
getInfoReportConfig
in interface ILayer
public void setInfoReportConfig(JMapClientInfoReportConfig infoReportConfig)
setInfoReportConfig
in interface ILayer
infoReportConfig
- the infoReportConfig to set.public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(Layer layer)
It implements the compareTo from the Comparable interface If the object is null, the method returns -1
compareTo
in interface java.lang.Comparable<Layer>
layer
- the layer to compare to.Comparable
public abstract java.lang.Object clone()
ILayer
protected void clone(ILayer layer)
layer
- the new layer instance.public void update(ILayer layer)
public abstract LayerInfo toLayerInfo()
public abstract void loadData(Geometry bounds, boolean sync)
bounds
- the geometry used to delimit the boundssync
- whether his method is synchronizedpublic void invalidate()
public void revalidate(K2DTransform tr)
tr
- the transformation to set. If null is specified, this method has
the same effect as the invalidate()
method.public void setPrecisionModel(PrecisionModel precisionModel)
precisionModel
- the precision model to use.public PrecisionModel getPrecisionModel()
public java.lang.String getMetadataUrl()
getMetadataUrl
in interface ILayer
public void setMetadataUrl(java.lang.String metadataUrl)
setMetadataUrl
in interface ILayer
metadataUrl
- the metadata URLpublic boolean isDynamic()
public int getDynamicRefresh()
getDynamicRefresh
in interface ILayer
public void setDynamicRefresh(int seconds)
setDynamicRefresh
in interface ILayer
public void removeTranslationsOtherThan(java.util.Locale[] locales)
LocalizedObject
Locale
from this object that are not in the specified locales
.
locales[0]
should be the default languageremoveTranslationsOtherThan
in class LocalizedObject