diva.canvas
Class GraphicsPane

java.lang.Object
  extended by diva.canvas.CanvasPane
      extended by diva.canvas.GraphicsPane
All Implemented Interfaces:
CanvasComponent, EventAcceptor
Direct Known Subclasses:
GraphPane, SimplePane

public class GraphicsPane
extends CanvasPane

A CanvasPane which has a default set of layers that are useful for interactive drawing and editing applications. The layers are organized as follows:

   (front)  Foreground event
            Overlay
            Foreground graphics
            Background graphics
            Background event
 
This organization allows applications to easily overlay and underlay graphics and event handling around the main application window.

Typical uses of each of these layers include:

Foreground event layer
Grid or object snapping, stroke filtering, event monitoring and debugging, event grab, etc. By default, this layer is not enabled. If you enable it, but still want events to go through to the underlying figure layers, use setConsuming(false).
Overlay
An overlay layer for drag-selection outlining and so on. By default, this layer is an instance of OverlayLayer and is set visible.
Foreground graphics
The main application graphics. By default, this layer is an instance of FigureLayer and is set enabled and visible.
Background graphics
Auxiliary, non-interactive graphics. By default, this layer is an instance of FigureLayer but is set not visible and not enabled..
Background Event
"Last chance" event handling layer, for things such as drag-selection rectangle, panning/zooming, etc. By default, this layer is enabled.

Version:
$Id: GraphicsPane.java 43472 2006-08-21 23:16:56Z cxh $
Author:
Michael Shilman, John Reekie
Accepted Rating:
Yellow

Field Summary
protected  EventLayer _backgroundEventLayer
           
protected  CanvasLayer _backgroundLayer
           
protected  EventLayer _foregroundEventLayer
           
protected  FigureLayer _foregroundLayer
           
protected  CanvasLayer[] _layers
           
protected  OverlayLayer _overlayLayer
           
 
Constructor Summary
GraphicsPane()
          Create a new Graphics pane with an instance of FigureLayer as the main figure layer.
GraphicsPane(FigureLayer foregroundLayer)
          Create a new Graphics pane with the passed Layer as the main graphics pane.
 
Method Summary
protected  void _rebuildLayerArray()
          Rebuild the array of layers for use by iterators
 EventLayer getBackgroundEventLayer()
          Get the background event layer
 CanvasLayer getBackgroundLayer()
          Get the background layer
 EventLayer getForegroundEventLayer()
          Get the foreground event layer
 FigureLayer getForegroundLayer()
          Get the foreground layer
 OverlayLayer getOverlayLayer()
          Get the overlay layer
 java.util.Iterator layersFromBack()
          Return an iteration of the layers, in redraw order (that is, from back to front).
 java.util.Iterator layersFromFront()
          Return an iteration of the layers, in event-processing order (that is, from front to back).
 void setBackgroundEventLayer(EventLayer l)
          Set the background event layer
 void setBackgroundLayer(CanvasLayer l)
          Set the background figure layer
 void setForegroundEventLayer(EventLayer l)
          Set the foreground event layer
 void setForegroundLayer(FigureLayer l)
          Set the foreground figure layer
 void setOverlayLayer(OverlayLayer l)
          Set the overlay layer
 
Methods inherited from class diva.canvas.CanvasPane
_initNewLayer, _nullifyLayer, dispatchEvent, getCanvas, getParent, getSize, getToolTipText, getTransformContext, isAntialiasing, isEnabled, layers, paint, paint, processLayerEvent, repaint, repaint, scale, setAntialiasing, setCanvas, setEnabled, setParent, setSize, setSize, setTransform, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_layers

protected CanvasLayer[] _layers

_foregroundEventLayer

protected EventLayer _foregroundEventLayer

_overlayLayer

protected OverlayLayer _overlayLayer

_foregroundLayer

protected FigureLayer _foregroundLayer

_backgroundLayer

protected CanvasLayer _backgroundLayer

_backgroundEventLayer

protected EventLayer _backgroundEventLayer
Constructor Detail

GraphicsPane

public GraphicsPane()
Create a new Graphics pane with an instance of FigureLayer as the main figure layer.


GraphicsPane

public GraphicsPane(FigureLayer foregroundLayer)
Create a new Graphics pane with the passed Layer as the main graphics pane.

Method Detail

getBackgroundEventLayer

public EventLayer getBackgroundEventLayer()
Get the background event layer


getBackgroundLayer

public CanvasLayer getBackgroundLayer()
Get the background layer


getForegroundLayer

public FigureLayer getForegroundLayer()
Get the foreground layer


getOverlayLayer

public OverlayLayer getOverlayLayer()
Get the overlay layer


getForegroundEventLayer

public EventLayer getForegroundEventLayer()
Get the foreground event layer


layersFromFront

public java.util.Iterator layersFromFront()
Return an iteration of the layers, in event-processing order (that is, from front to back).

Specified by:
layersFromFront in class CanvasPane

layersFromBack

public java.util.Iterator layersFromBack()
Return an iteration of the layers, in redraw order (that is, from back to front).

Specified by:
layersFromBack in class CanvasPane

setBackgroundEventLayer

public void setBackgroundEventLayer(EventLayer l)
Set the background event layer


setBackgroundLayer

public void setBackgroundLayer(CanvasLayer l)
Set the background figure layer


setForegroundLayer

public void setForegroundLayer(FigureLayer l)
Set the foreground figure layer


setOverlayLayer

public void setOverlayLayer(OverlayLayer l)
Set the overlay layer


setForegroundEventLayer

public void setForegroundEventLayer(EventLayer l)
Set the foreground event layer


_rebuildLayerArray

protected void _rebuildLayerArray()
Rebuild the array of layers for use by iterators