Package com.bc.ceres.glayer
Class Layer
java.lang.Object
com.bc.ceres.core.ExtensibleObject
com.bc.ceres.glayer.Layer
- All Implemented Interfaces:
Extensible
- Direct Known Subclasses:
BackgroundLayer
,CollectionLayer
,GraticuleLayer
,ImageLayer
,ShapeLayer
A layer contributes graphical elements to a drawing represented by a
Rendering
.- Version:
- $revision$ $date$
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
Layer
(LayerType layerType, PropertySet configuration) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(LayerListener listener) Adds a change listener to this layer.final void
dispose()
Disposes all allocated resources.protected void
Disposes the child layers of this layer.protected void
Disposes the layer.protected void
fireLayerDataChanged
(Rectangle2D modelRegion) protected void
protected void
fireLayerPropertyChanged
(String propertyName, Object oldValue, Object newValue) protected void
fireLayersAdded
(Layer[] layers) protected void
fireLayersRemoved
(Layer[] layers) int
getChildIndex
(String id) Gets the index of the first child layer having the given identifier.Gets the child layers of this layer.protected Rectangle2D
Gets the bounds (bounding box) of the child layers in model coordinates.Returns the composite of this layer.Returns the configuration which can be used by the layer type to recreate this layer.protected final <T> T
getConfigurationProperty
(String propertyName, T defaultValue) getId()
protected Rectangle2D
Gets the bounds (bounding box) of this layer in model coordinates.final Rectangle2D
Gets the model bounds (bounding box) of the layer in model coordinates.getName()
double
Returns the swipe position of this layer.double
Returns the transparency of this layer.boolean
boolean
void
Regenerates the layer.void
removeListener
(LayerListener listener) Removes a change listener from this layer.final void
Renders the layer.final void
render
(Rendering rendering, LayerFilter filter) Renders the layer.protected void
renderChildren
(Rendering rendering, LayerFilter filter) Renders the child layers of this layer.protected void
renderLayer
(Rendering rendering) Renders the layer.void
setComposite
(Composite composite) Sets the composite of this layer.void
void
void
setSwipePercent
(double swipePercent) Sets the swipe position of this layer to a new value.void
setTransparency
(double transparency) Sets the transparency of this layer to a new value.void
setVisible
(boolean visible) toString()
Methods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension
-
Constructor Details
-
Layer
-
Layer
Constructor. The following default properties are used:name = getClass().getName()
visible = true
transparency = 0.0
swipePercent = 1.0
- Parameters:
layerType
- the layer type.configuration
- the configuration used by the layer type to create this layer.
-
-
Method Details
-
getLayerType
- Returns:
- The layer type.
-
getConfiguration
Returns the configuration which can be used by the layer type to recreate this layer.- Returns:
- the configuration.
-
getParent
- Returns:
- The parent layer, or
null
if this layer is not a child of any other layer.
-
isCollectionLayer
public boolean isCollectionLayer()- Returns:
- true, if this layer is a collection of other layers.
-
getChildren
Gets the child layers of this layer. The returned list is "life", modifying the list's content will cause this layer to fire change events.- Returns:
- The child layers of this layer. May be empty.
-
getName
- Returns:
- The name.
-
setName
- Parameters:
name
- The name.
-
getId
- Returns:
- An identifier which can be used to search for special layers.
- Since:
- Ceres 0.9
-
setId
- Parameters:
id
- An identifier which can be used to search for special layers.- Since:
- Ceres 0.9
-
getChildIndex
Gets the index of the first child layer having the given identifier.- Parameters:
id
- The identifier.- Returns:
- The child index, or
-1
if no such layer exists. - Since:
- Ceres 0.9
-
isVisible
public boolean isVisible()- Returns:
true
, if this layer is visible.
-
setVisible
public void setVisible(boolean visible) - Parameters:
visible
-true
, if this layer is visible.
-
getTransparency
public double getTransparency()Returns the transparency of this layer.- Returns:
- the transparency of this layer.
-
setTransparency
public void setTransparency(double transparency) Sets the transparency of this layer to a new value.- Parameters:
transparency
- the new transparency value of this layer.
-
getSwipePercent
public double getSwipePercent()Returns the swipe position of this layer.- Returns:
- the swipe position of this layer.
-
setSwipePercent
public void setSwipePercent(double swipePercent) Sets the swipe position of this layer to a new value.- Parameters:
swipePercent
- the new swipe position value of this layer.
-
getComposite
Returns the composite of this layer.- Returns:
- the composite of this layer.
-
setComposite
Sets the composite of this layer.- Parameters:
composite
- the new composite of this layer.
-
getConfigurationProperty
-
getModelBounds
Gets the model bounds (bounding box) of the layer in model coordinates. The default implementation returns the union of the model bounds (if any) returned bygetLayerModelBounds()
andgetChildrenModelBounds()
.- Returns:
- The bounds of the layer in model coordinates or
null
if this layer and all children have no specified boundary.
-
getLayerModelBounds
Gets the bounds (bounding box) of this layer in model coordinates. Called bygetModelBounds()
. The default implementation returnsnull
.- Returns:
- The bounds of the layer in model coordinates or
null
if this layer has no specified boundary.
-
getChildrenModelBounds
Gets the bounds (bounding box) of the child layers in model coordinates. Called bygetModelBounds()
. The default implementation returns the union bounds (if any) of all child layers.- Returns:
- The bounds of the child layers in model coordinates or
null
none of the children have a specified boundary.
-
render
Renders the layer. Callsrender(rendering,null)
.- Parameters:
rendering
- The rendering to which the layer will be rendered.- See Also:
-
render
Renders the layer. The base class implementation configures the rendering with respect to the "transparency" and "composite" style properties. ThenrenderLayer(com.bc.ceres.grender.Rendering)
followed byrenderChildren(com.bc.ceres.grender.Rendering, LayerFilter)
are called.- Parameters:
rendering
- The rendering to which the layer will be rendered.filter
- An optional layer filter. May benull
.
-
renderLayer
Renders the layer. Called byrender(com.bc.ceres.grender.Rendering)
. The default implementation does nothing.- Parameters:
rendering
- The rendering to which the layer will be rendered.
-
renderChildren
Renders the child layers of this layer. Called byrender(com.bc.ceres.grender.Rendering)
. The default implementation callsrender(com.bc.ceres.grender.Rendering)
on all child layers.- Parameters:
rendering
- The rendering to which the layer will be rendered.filter
- A layer filter. May benull
.
-
dispose
public final void dispose()Disposes all allocated resources. Called if the layer will no longer be in use. The default implementation removes all registered listeners, callsdisposeChildren()
followed bydisposeLayer()
. -
disposeLayer
protected void disposeLayer()Disposes the layer. Called bydispose()
. The default implementation does nothing. -
disposeChildren
protected void disposeChildren() -
addListener
Adds a change listener to this layer.- Parameters:
listener
- The listener.
-
removeListener
Removes a change listener from this layer.- Parameters:
listener
- The listener.
-
getListeners
- Returns:
- The listeners added to this layer..
-
fireLayerPropertyChanged
-
fireLayerPropertyChanged
-
fireLayerDataChanged
-
fireLayersAdded
-
fireLayersRemoved
-
toString
-
regenerate
public void regenerate()Regenerates the layer. May be called to update the layer data. The default implementation does nothing.
-