Package diva.canvas
Class GraphicsPane
- java.lang.Object
-
- diva.canvas.CanvasPane
-
- 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$
- Author:
- Michael Shilman, John Reekie
- Pt.AcceptedRating:
- Yellow
-
-
Field Summary
Fields Modifier and Type Field Description protected EventLayer
_backgroundEventLayer
protected CanvasLayer
_backgroundLayer
protected EventLayer
_foregroundEventLayer
protected FigureLayer
_foregroundLayer
protected CanvasLayer[]
_layers
protected OverlayLayer
_overlayLayer
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
-
-
-
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.- Parameters:
foregroundLayer
- The foreground layer
-
-
Method Detail
-
getBackgroundEventLayer
public EventLayer getBackgroundEventLayer()
Get the background event layer.- Returns:
- The layer.
- See Also:
setBackgroundEventLayer(EventLayer)
-
getBackgroundLayer
public CanvasLayer getBackgroundLayer()
Get the background layer.- Returns:
- The layer.
- See Also:
setBackgroundLayer(CanvasLayer)
-
getForegroundLayer
public FigureLayer getForegroundLayer()
Get the foreground layer.- Returns:
- The layer.
- See Also:
setForegroundLayer(FigureLayer)
-
getOverlayLayer
public OverlayLayer getOverlayLayer()
Get the overlay layer.- Returns:
- The layer.
- See Also:
setOverlayLayer(OverlayLayer)
-
getForegroundEventLayer
public EventLayer getForegroundEventLayer()
Get the foreground event layer.- Returns:
- The layer.
- See Also:
setForegroundEventLayer(EventLayer)
-
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.
-
setBackgroundEventLayer
public void setBackgroundEventLayer(EventLayer l)
Set the background event layer.- Parameters:
l
- The layer.- See Also:
getBackgroundEventLayer()
-
setBackgroundLayer
public void setBackgroundLayer(CanvasLayer l)
Set the background figure layer.- Parameters:
l
- The layer.- See Also:
getBackgroundLayer()
-
setForegroundLayer
public void setForegroundLayer(FigureLayer l)
Set the foreground figure layer.- Parameters:
l
- The layer.- See Also:
getForegroundLayer()
-
setOverlayLayer
public void setOverlayLayer(OverlayLayer l)
Set the overlay layer.- Parameters:
l
- The layer.- See Also:
getOverlayLayer()
-
setForegroundEventLayer
public void setForegroundEventLayer(EventLayer l)
Set the foreground event layer.- Parameters:
l
- The layer.- See Also:
getForegroundEventLayer()
-
_rebuildLayerArray
protected void _rebuildLayerArray()
Rebuild the array of layers for use by iterators.
-
-