Class 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 a Rendering.
Version:
$revision$ $date$
  • Constructor Details

    • Layer

      protected Layer(LayerType layerType)
    • Layer

      protected Layer(LayerType layerType, PropertySet configuration)
      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

      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 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

      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 -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

      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 by getLayerModelBounds() and getChildrenModelBounds().
      Returns:
      The bounds of the layer in model coordinates or null if 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 by getModelBounds(). The default implementation returns null.
      Returns:
      The bounds of the layer in model coordinates or null if this layer has no specified boundary.
    • getChildrenModelBounds

      protected Rectangle2D getChildrenModelBounds()
      Gets the bounds (bounding box) of the child layers in model coordinates. Called by getModelBounds(). 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

      public final void render(Rendering rendering)
      Renders the layer. Calls render(rendering,null).
      Parameters:
      rendering - The rendering to which the layer will be rendered.
      See Also:
    • 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. Then renderLayer(com.bc.ceres.grender.Rendering) followed by renderChildren(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 be null.
    • renderLayer

      protected void renderLayer(Rendering rendering)
      Renders the layer. Called by render(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 by render(com.bc.ceres.grender.Rendering). The default implementation calls render(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 be null.
    • 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, calls disposeChildren() followed by disposeLayer().
    • disposeLayer

      protected void disposeLayer()
      Disposes the layer. Called by dispose(). The default implementation does nothing.
    • disposeChildren

      protected void disposeChildren()
      Disposes the child layers of this layer. Called by dispose(). The default implementation calls dispose() on all child layers and removes them from this layer.
    • 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)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • regenerate

      public void regenerate()
      Regenerates the layer. May be called to update the layer data. The default implementation does nothing.