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, setParent
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getParent, getTransformContext, repaint, repaint
public FigureLayer()
public FigureLayer(CanvasPane pane)
public FigureLayer(CanvasPane pane, ZList zlist)
public FigureLayer(ZList zlist)
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(AWTEvent event)
dispatchEvent
in interface EventAcceptor
public Iterator figures()
public Iterator figuresFromBack()
figuresFromBack
in interface FigureSet
public 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 Rectangle2D getLayerBounds()
getLayerBounds
in class CanvasLayer
public final double getPickHalo()
public void grabPointer(LayerEvent e, Figure f)
public 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(Graphics2D g)
paint
in interface VisibleComponent
public void paint(Graphics2D g, Rectangle2D region)
paint
in interface VisibleComponent
public Figure pick(Rectangle2D region)
pick
in interface FigureContainer
public Figure pick(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(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.
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
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)
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.