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
public abstract class Layer extends ExtensibleObject
A layer contributes graphical elements to a drawing represented by aRendering.- Version:
- $revision$ $date$
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLayer(LayerType layerType)protectedLayer(LayerType layerType, PropertySet configuration)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(LayerListener listener)Adds a change listener to this layer.voiddispose()Disposes all allocated resources.protected voiddisposeChildren()Disposes the child layers of this layer.protected voiddisposeLayer()Disposes the layer.protected voidfireLayerDataChanged(Rectangle2D modelRegion)protected voidfireLayerPropertyChanged(PropertyChangeEvent event)protected voidfireLayerPropertyChanged(String propertyName, Object oldValue, Object newValue)protected voidfireLayersAdded(Layer[] layers)protected voidfireLayersRemoved(Layer[] layers)intgetChildIndex(String id)Gets the index of the first child layer having the given identifier.List<Layer>getChildren()Gets the child layers of this layer.protected Rectangle2DgetChildrenModelBounds()Gets the bounds (bounding box) of the child layers in model coordinates.CompositegetComposite()Returns the composite of this layer.PropertySetgetConfiguration()Returns the configuration which can be used by the layer type to recreate this layer.protected <T> TgetConfigurationProperty(String propertyName, T defaultValue)StringgetId()protected Rectangle2DgetLayerModelBounds()Gets the bounds (bounding box) of this layer in model coordinates.LayerTypegetLayerType()LayerListener[]getListeners()Rectangle2DgetModelBounds()Gets the model bounds (bounding box) of the layer in model coordinates.StringgetName()LayergetParent()doublegetSwipePercent()Returns the swipe position of this layer.doublegetTransparency()Returns the transparency of this layer.booleanisCollectionLayer()booleanisVisible()voidregenerate()Regenerates the layer.voidremoveListener(LayerListener listener)Removes a change listener from this layer.voidrender(Rendering rendering)Renders the layer.voidrender(Rendering rendering, LayerFilter filter)Renders the layer.protected voidrenderChildren(Rendering rendering, LayerFilter filter)Renders the child layers of this layer.protected voidrenderLayer(Rendering rendering)Renders the layer.voidsetComposite(Composite composite)Sets the composite of this layer.voidsetId(String id)voidsetName(String name)voidsetSwipePercent(double swipePercent)Sets the swipe position of this layer to a new value.voidsetTransparency(double transparency)Sets the transparency of this layer to a new value.voidsetVisible(boolean visible)StringtoString()-
Methods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension
-
-
-
-
Constructor Detail
-
Layer
protected Layer(LayerType layerType)
-
Layer
protected Layer(LayerType layerType, PropertySet configuration)
Constructor. The following default properties are used:name = getClass().getName()visible = truetransparency = 0.0swipePercent = 1.0
- Parameters:
layerType- the layer type.configuration- the configuration used by the layer type to create this layer.
-
-
Method Detail
-
getLayerType
public LayerType getLayerType()
- Returns:
- The layer type.
-
getConfiguration
public PropertySet getConfiguration()
Returns the configuration which can be used by the layer type to recreate this layer.- Returns:
- the configuration.
-
getParent
public Layer getParent()
- Returns:
- The parent layer, or
nullif 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
public List<Layer> 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
public String getName()
- Returns:
- The name.
-
setName
public void setName(String name)
- Parameters:
name- The name.
-
getId
public String getId()
- Returns:
- An identifier which can be used to search for special layers.
- Since:
- Ceres 0.9
-
setId
public void setId(String id)
- Parameters:
id- An identifier which can be used to search for special layers.- Since:
- Ceres 0.9
-
getChildIndex
public int getChildIndex(String id)
Gets the index of the first child layer having the given identifier.- Parameters:
id- The identifier.- Returns:
- The child index, or
-1if 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
public Composite getComposite()
Returns the composite of this layer.- Returns:
- the composite of this layer.
-
setComposite
public void setComposite(Composite composite)
Sets the composite of this layer.- Parameters:
composite- the new composite of this layer.
-
getConfigurationProperty
protected final <T> T getConfigurationProperty(String propertyName, T defaultValue)
-
getModelBounds
public final Rectangle2D 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
nullif this layer and all children have no specified boundary.
-
getLayerModelBounds
protected Rectangle2D 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
nullif this layer has no specified boundary.
-
getChildrenModelBounds
protected Rectangle2D 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
nullnone of the children have a specified boundary.
-
render
public final void render(Rendering rendering)
Renders the layer. Callsrender(rendering,null).- Parameters:
rendering- The rendering to which the layer will be rendered.- See Also:
render(com.bc.ceres.grender.Rendering, LayerFilter)
-
render
public final void render(Rendering rendering, LayerFilter filter)
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
protected void renderLayer(Rendering rendering)
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
protected void renderChildren(Rendering rendering, LayerFilter filter)
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
public void addListener(LayerListener listener)
Adds a change listener to this layer.- Parameters:
listener- The listener.
-
removeListener
public void removeListener(LayerListener listener)
Removes a change listener from this layer.- Parameters:
listener- The listener.
-
getListeners
public LayerListener[] getListeners()
- Returns:
- The listeners added to this layer..
-
fireLayerPropertyChanged
protected void fireLayerPropertyChanged(String propertyName, Object oldValue, Object newValue)
-
fireLayerPropertyChanged
protected void fireLayerPropertyChanged(PropertyChangeEvent event)
-
fireLayerDataChanged
protected void fireLayerDataChanged(Rectangle2D modelRegion)
-
fireLayersAdded
protected void fireLayersAdded(Layer[] layers)
-
fireLayersRemoved
protected void fireLayersRemoved(Layer[] layers)
-
regenerate
public void regenerate()
Regenerates the layer. May be called to update the layer data. The default implementation does nothing.
-
-