Package diva.canvas.toolbox
Class BasicCanvasPane
- java.lang.Object
-
- diva.canvas.CanvasPane
-
- 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$
- Author:
- John Reekie
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLayer(int index, CanvasLayer layer)
Insert the given layer into the list of layers at the given index.void
addLayer(CanvasLayer layer)
Add the given layer to the list of layers.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
-
-
-
-
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 classCanvasPane
- Returns:
- The iterator.
-
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 classCanvasPane
- Returns:
- The iterator.
-
removeLayer
public void removeLayer(CanvasLayer layer)
Remove the given layer. Do nothing if the layer is not in this pane.
-
-