public class FigureLayer extends CanvasLayer implements FigureContainer, EventAcceptor
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).
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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(AWTEvent event)
Dispatch an AWT event on this layer.
|
Iterator |
figures()
Return an iteration of the figures in this container.
|
Iterator |
figuresFromBack()
Return an iteration of the figures in this container, from
back to front.
|
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.
|
int |
getFigureCount()
Return the number of figures in this layer.
|
ZList |
getFigures()
Get the internal z-list.
|
Rectangle2D |
getLayerBounds()
Get the bounds of the shapes draw in this layer.
|
double |
getPickHalo()
Get the "pick halo".
|
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(Graphics2D g)
Paint this layer onto a 2D graphics object.
|
void |
paint(Graphics2D g,
Rectangle2D region)
Paint this layer onto a 2D graphics object, within the given
region.
|
Figure |
pick(Rectangle2D region)
Get the picked figure.
|
Figure |
pick(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(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.
|
getCanvasPane, getParent, getTransformContext, repaint, repaint, setParentclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetParent, getTransformContext, repaint, repaintpublic FigureLayer()
public FigureLayer(CanvasPane pane)
public FigureLayer(CanvasPane pane, ZList zlist)
public FigureLayer(ZList zlist)
public void add(Figure f)
add in interface FigureContainerpublic 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 FigureContainercontains in interface FigureSetpublic void decorate(Figure child, FigureDecorator decorator)
decorate in interface FigureContainerpublic void dispatchEvent(AWTEvent event)
dispatchEvent in interface EventAcceptorpublic Iterator figures()
public Iterator figuresFromBack()
figuresFromBack in interface FigureSetpublic Iterator figuresFromFront()
figuresFromFront in interface FigureSetpublic Figure get(int index)
public int getFigureCount()
getFigureCount in interface FigureContainerpublic Figure getCurrentFigure()
public ZList getFigures()
public Rectangle2D getLayerBounds()
getLayerBounds in class CanvasLayerpublic final double getPickHalo()
public void grabPointer(LayerEvent e, Figure f)
public String getToolTipText(LayerEvent e)
getToolTipText in class CanvasLayerpublic int indexOf(Figure f)
public final boolean isEnabled()
isEnabled in interface EventAcceptorpublic final boolean isVisible()
isVisible in interface VisibleComponentpublic void paint(Graphics2D g)
paint in interface VisibleComponentpublic void paint(Graphics2D g, Rectangle2D region)
paint in interface VisibleComponentpublic Figure pick(Rectangle2D region)
pick in interface FigureContainerpublic Figure pick(Rectangle2D region, Filter filter)
pick in interface FigureContainerpublic void remove(Figure f)
remove in interface FigureContainerpublic void remove(int index)
public void repaint(Rectangle2D region)
public final void setEnabled(boolean flag)
setEnabled in interface EventAcceptorpublic 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.
IndexOutOfBoundsException - The new index is out of range.public final void setVisible(boolean flag)
setVisible in interface VisibleComponentpublic void undecorate(FigureDecorator decorator)
undecorate in interface FigureContainerprotected 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)
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.