|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.canvas.CanvasLayer
diva.canvas.FigureLayer
public class FigureLayer
A figure layer is a layer on which Figures can be drawn. It contains a z-list in which all the contained figures are held, and implements wrappers for most of the z-list methods to provide flexible access to the contained figures. Figures are also stored at contiguous integer indexes, with index zero being the "topmost" figure and the highest index being the "lowest" figure.
FigureLayer responds to events on figures themselves by forwarding the events to interactors attached to a hit figure. It does not support events on the layer itself (see EventLayer for that).
Yellow |
Field Summary | |
---|---|
private boolean |
_enabled
The enabled flag. |
private LayerEvent |
_lastLayerEvent
The last layer event processed by this layer. |
private double |
_pickHalo
The size of the halo to use for "picking." |
private Figure |
_pointerGrabber
The figure that has currently grabbed the pointer. |
private Figure |
_pointerOver
The figure that the pointer is currently over. |
private boolean |
_visible
The visibility flag. |
private ZList |
_zlist
The figures contained in this layer. |
Fields inherited from class diva.canvas.CanvasLayer |
---|
_containingPane |
Constructor Summary | |
---|---|
FigureLayer()
Create a new figure layer that is not in a pane. |
|
FigureLayer(CanvasPane pane)
Create a new figure layer within the given pane. |
|
FigureLayer(CanvasPane pane,
ZList zlist)
Create a new figure layer within the given pane and with the given ZList to hold the figures it contains. |
|
FigureLayer(ZList zlist)
Create a new figure layer with the given ZList to hold its figures. |
Method Summary | |
---|---|
void |
add(Figure f)
Add a figure to the layer. |
void |
add(int index,
Figure f)
Insert a figure into the layer at the given position. |
void |
clear()
Removes all of the figures from this layer. |
boolean |
contains(Figure f)
Test if the layer contains the given figure. |
void |
decorate(Figure child,
FigureDecorator decorator)
Decorate a child figure, replacing the child figure with the decorator. |
void |
dispatchEvent(java.awt.AWTEvent event)
Dispatch an AWT event on this layer. |
private void |
dispatchEventUpTree(Figure f,
LayerEvent e)
Dispatch a layer event up the tree. |
private void |
dispatchMotionEventUpTree(Figure f,
LayerEvent e)
Dispatch a layer motion event up the tree. |
java.util.Iterator |
figures()
Return an iteration of the figures in this container. |
java.util.Iterator |
figuresFromBack()
Return an iteration of the figures in this container, from back to front. |
java.util.Iterator |
figuresFromFront()
Return an iteration of the figures in this container, from front to back. |
Figure |
get(int index)
Get the figure at the given index. |
Figure |
getCurrentFigure()
Return the figure that the mouse pointer is currently over, or null if none. |
protected Figure |
getFigure(LayerEvent e)
Return the figure pointed to by the given LayerEvent. |
int |
getFigureCount()
Return the number of figures in this layer. |
ZList |
getFigures()
Get the internal z-list. |
java.awt.geom.Rectangle2D |
getLayerBounds()
Get the bounds of the shapes draw in this layer. |
double |
getPickHalo()
Get the "pick halo". |
java.lang.String |
getToolTipText(LayerEvent e)
Get the toolTipText for the point in the given LayerEvent. |
void |
grabPointer(LayerEvent e,
Figure f)
"Grab" the pointer. |
int |
indexOf(Figure f)
Return the index of the given figure. |
boolean |
isEnabled()
Test the enabled flag of this layer. |
boolean |
isVisible()
Test the visibility flag of this layer. |
void |
paint(java.awt.Graphics2D g)
Paint this layer onto a 2D graphics object. |
void |
paint(java.awt.Graphics2D g,
java.awt.geom.Rectangle2D region)
Paint this layer onto a 2D graphics object, within the given region. |
Figure |
pick(java.awt.geom.Rectangle2D region)
Get the picked figure. |
Figure |
pick(java.awt.geom.Rectangle2D region,
Filter filter)
Get the picked figure. |
protected void |
processLayerEvent(LayerEvent e)
Process a layer event. |
protected void |
processLayerMotionEvent(LayerEvent e)
Process a layer motion event. |
void |
remove(Figure f)
Remove the given figure from this layer. |
void |
remove(int index)
Remove the figure at the given position in the list. |
void |
repaint(java.awt.geom.Rectangle2D region)
Repaint all figures that intersect the given rectangle. |
void |
setEnabled(boolean flag)
Set the enabled flag of this layer. |
void |
setIndex(int index,
Figure f)
Set the index of the given figure. |
void |
setPickHalo(double halo)
Set the "pick halo". |
void |
setVisible(boolean flag)
Set the visibility flag of this layer. |
void |
undecorate(FigureDecorator decorator)
Remove a figure from the given decorator and add it back into this container. |
Methods inherited from class diva.canvas.CanvasLayer |
---|
getCanvasPane, getParent, getTransformContext, repaint, repaint, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface diva.canvas.CanvasComponent |
---|
getParent, getTransformContext, repaint, repaint |
Field Detail |
---|
private ZList _zlist
private double _pickHalo
private boolean _visible
private boolean _enabled
private Figure _pointerOver
private Figure _pointerGrabber
private LayerEvent _lastLayerEvent
Constructor Detail |
---|
public FigureLayer()
public FigureLayer(CanvasPane pane)
public FigureLayer(CanvasPane pane, ZList zlist)
public FigureLayer(ZList zlist)
Method Detail |
---|
public void add(Figure f)
add
in interface FigureContainer
public void add(int index, Figure f)
Clients should assume that an implementation of this method does not check if the figure is already contained -- clients are therefore responsible for being bug-free.
public void clear()
public boolean contains(Figure f)
contains
in interface FigureContainer
contains
in interface FigureSet
public void decorate(Figure child, FigureDecorator decorator)
decorate
in interface FigureContainer
public void dispatchEvent(java.awt.AWTEvent event)
dispatchEvent
in interface EventAcceptor
public java.util.Iterator figures()
figures
in interface FigureSet
public java.util.Iterator figuresFromBack()
figuresFromBack
in interface FigureSet
public java.util.Iterator figuresFromFront()
figuresFromFront
in interface FigureSet
public Figure get(int index)
public int getFigureCount()
getFigureCount
in interface FigureContainer
public Figure getCurrentFigure()
public ZList getFigures()
public java.awt.geom.Rectangle2D getLayerBounds()
getLayerBounds
in class CanvasLayer
public final double getPickHalo()
public void grabPointer(LayerEvent e, Figure f)
public java.lang.String getToolTipText(LayerEvent e)
getToolTipText
in class CanvasLayer
public int indexOf(Figure f)
public final boolean isEnabled()
isEnabled
in interface EventAcceptor
public final boolean isVisible()
isVisible
in interface VisibleComponent
public void paint(java.awt.Graphics2D g)
paint
in interface VisibleComponent
public void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D region)
paint
in interface VisibleComponent
public Figure pick(java.awt.geom.Rectangle2D region)
pick
in interface FigureContainer
public Figure pick(java.awt.geom.Rectangle2D region, Filter filter)
pick
in interface FigureContainer
public void remove(Figure f)
remove
in interface FigureContainer
public void remove(int index)
public void repaint(java.awt.geom.Rectangle2D region)
public final void setEnabled(boolean flag)
setEnabled
in interface EventAcceptor
public final void setPickHalo(double halo)
public void setIndex(int index, Figure f)
Note that this method does not check if the figure is already contained -- clients are therefore responsible for being bug-free.
java.lang.IndexOutOfBoundsException
- The new index is out of range.public final void setVisible(boolean flag)
setVisible
in interface VisibleComponent
public void undecorate(FigureDecorator decorator)
undecorate
in interface FigureContainer
private void dispatchEventUpTree(Figure f, LayerEvent e)
private void dispatchMotionEventUpTree(Figure f, LayerEvent e)
protected final Figure getFigure(LayerEvent e)
protected void processLayerEvent(LayerEvent e)
If the event type is MOUSE_DRAGGED or MOUSE_RELEASED, then the downwards recursion is skipped, and the upwards propagation is begun from the figure remembered from the MOUSE_PRESSED processing. Again, the propagation stops when the event is consumed.
Note: the above strategy will not work with more than one input device. Is there anything in MouseEvent that allows us to identify the input device?
protected void processLayerMotionEvent(LayerEvent e)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |