Class Layer

    • 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 = 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 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 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.
      • 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.
      • 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)
      • regenerate

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