Package diva.canvas

Class CanvasLayer

  • All Implemented Interfaces:
    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.
    John Reekie
    • 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.
        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.
        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.
        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
        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.
        e - The layer event, ignored in this class.
        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
        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
        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.
        parent - The parent of this layer