Package diva.canvas

Class CanvasLayer

  • All Implemented Interfaces:
    CanvasComponent
    Direct Known Subclasses:
    EventLayer, FigureLayer, GridLayer, OverlayLayer

    public abstract class CanvasLayer
    extends java.lang.Object
    implements CanvasComponent
    A canvas layer is a single layer that lives within a CanvasPane. This is an abstract class -- concrete subclasses provide facilities for drawing graphics or handling events.
    Version:
    $Id$
    Author:
    John Reekie
    Pt.AcceptedRating:
    Yellow
    • Constructor Detail

      • CanvasLayer

        public CanvasLayer()
        Create a new layer that is not in a pane. The layer will not be displayed, and its coordinate transformation will be as though it were a one-to-one mapping. Use of this constructor is strongly discouraged, as many of the geometry-related methods expect to see a pane.
      • CanvasLayer

        public CanvasLayer​(CanvasPane pane)
        Create a new layer within the given pane.
        Parameters:
        pane - The pane in which to create the layer
    • Method Detail

      • getCanvasPane

        public final CanvasPane getCanvasPane()
        Get the pane containing this layer. This may be null.
        Returns:
        The pane containing the layter
      • getLayerBounds

        public java.awt.geom.Rectangle2D getLayerBounds()
        Get the bounds of the shapes draw in this layer. In this base class, return an empty rectangle.
        Returns:
        The bounds of this layer.
      • getParent

        public final CanvasComponent getParent()
        Get the parent component, or null if there isn't one. This will return the same object as getCanvasPane().
        Specified by:
        getParent in interface CanvasComponent
        Returns:
        The parent of this component.
      • getToolTipText

        public java.lang.String getToolTipText​(LayerEvent e)
        Get the toolTipText for the point in the given MouseEvent. This works pretty much as regular event propagation in processLayerEvent.
        Parameters:
        e - The layer event, ignored in this class.
        Returns:
        This method always returns null.
      • getTransformContext

        public final TransformContext getTransformContext()
        Return the transform context of the parent pane, if there is one.
        Specified by:
        getTransformContext in interface CanvasComponent
        Returns:
        The transform context of this component.
      • repaint

        public void repaint()
        Schedule a repaint of this layer. The layer passes the repaint request to its containing pane, if there is one. Otherwise it does nothing.
        Specified by:
        repaint in interface CanvasComponent
      • repaint

        public void repaint​(DamageRegion d)
        Accept notification that a repaint has occurred somewhere in this layer. Pass the notification up to the parent pane.
        Specified by:
        repaint in interface CanvasComponent
        Parameters:
        d - The region where a repaint has occurred.
      • setParent

        public final void setParent​(CanvasComponent parent)
        Set the parent component of this layer. This must be an instance of CanvasPane.
        Parameters:
        parent - The parent of this layer