diva.canvas
Class CanvasLayer

java.lang.Object
  extended by diva.canvas.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: CanvasLayer.java 38798 2005-07-08 20:00:01Z cxh $
Author:
John Reekie
Accepted Rating:
Yellow

Field Summary
(package private)  CanvasPane _containingPane
          The pane containing this layer.
 
Constructor Summary
CanvasLayer()
          Create a new layer that is not in a pane.
CanvasLayer(CanvasPane pane)
          Create a new layer within the given pane.
 
Method Summary
 CanvasPane getCanvasPane()
          Get the pane containing this layer.
 java.awt.geom.Rectangle2D getLayerBounds()
          Get the bounds of the shapes draw in this layer.
 CanvasComponent getParent()
          Get the parent component, or null if there isn't one.
 java.lang.String getToolTipText(LayerEvent e)
          Get the toolTipText for the point in the given MouseEvent.
 TransformContext getTransformContext()
          Return the transform context of the parent pane, if there is one.
 void repaint()
          Schedule a repaint of this layer.
 void repaint(DamageRegion d)
          Accept notification that a repaint has occurred somewhere in this layer.
 void setParent(CanvasComponent parent)
          Set the parent component of this layer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_containingPane

CanvasPane _containingPane
The pane containing this layer.

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.

Method Detail

getCanvasPane

public final CanvasPane getCanvasPane()
Get the pane containing this layer. This may be null.


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.


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

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.


getTransformContext

public final TransformContext getTransformContext()
Return the transform context of the parent pane, if there is one.

Specified by:
getTransformContext in interface CanvasComponent

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

setParent

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