diva.canvas.toolbox
Class BasicCanvasPane

java.lang.Object
  extended by diva.canvas.CanvasPane
      extended by diva.canvas.toolbox.BasicCanvasPane
All Implemented Interfaces:
CanvasComponent, EventAcceptor

public class BasicCanvasPane
extends CanvasPane

A basic implementation of a canvas pane, provided for simple applications. This class keeps a linear list of canvas layers, and provides a couple of methods so that layers can be added to it. Real applications will probably want to create their own CanvasPane subclass, instead of using this class.

Version:
$Id: BasicCanvasPane.java 47877 2008-01-24 00:35:12Z cxh $
Author:
John Reekie

Field Summary
(package private)  java.util.ArrayList _layers
          The array of layers
 
Constructor Summary
BasicCanvasPane()
          Create a new canvas pane with a single figure layer at index zero.
BasicCanvasPane(CanvasLayer layer)
          Create a new canvas pane with the given layer at index zero.
 
Method Summary
 void addLayer(CanvasLayer layer)
          Add the given layer to the list of layers.
 void addLayer(int index, CanvasLayer layer)
          Insert the given layer into the list of layers at the given index.
 FigureLayer getLayer(int index)
          Get the layer at the given index.
 int indexOf(CanvasLayer layer)
          Get the index of the given layer, or -1 if it is not in this pane.
 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 removeLayer(CanvasLayer layer)
          Remove the given 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

java.util.ArrayList _layers
The array of layers

Constructor Detail

BasicCanvasPane

public BasicCanvasPane()
Create a new canvas pane with a single figure layer at index zero. This is a convenience constructor for test suites and simple demos -- in general, an application will want to construct a more sophisticated set of layers.


BasicCanvasPane

public BasicCanvasPane(CanvasLayer layer)
Create a new canvas pane with the given layer at index zero.

Method Detail

addLayer

public void addLayer(CanvasLayer layer)
Add the given layer to the list of layers. The new layer will be drawn over the top of any existing layers.


addLayer

public void addLayer(int index,
                     CanvasLayer layer)
Insert the given layer into the list of layers at the given index. Lower indexes are drawn above higher indexes.


getLayer

public FigureLayer getLayer(int index)
Get the layer at the given index.


indexOf

public int indexOf(CanvasLayer layer)
Get the index of the given layer, or -1 if it is not in this pane.


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

removeLayer

public void removeLayer(CanvasLayer layer)
Remove the given layer. Do nothing if the layer is not in this pane.