Package diva.canvas.interactor
Class Manipulator
- java.lang.Object
-
- diva.canvas.AbstractFigure
-
- diva.canvas.AbstractFigureContainer
-
- diva.canvas.FigureDecorator
-
- diva.canvas.interactor.Manipulator
-
- All Implemented Interfaces:
CanvasComponent
,Figure
,FigureContainer
,FigureSet
,VisibleComponent
,UserObjectContainer
- Direct Known Subclasses:
BoundsManipulator
,CircleManipulator
,ConnectorManipulator
,PathManipulator
public abstract class Manipulator extends FigureDecorator
A Manipulator is an object that decorates some figure, and generally paint grab-handles or some other stuff to the figure to that it can be resized and manipulated. This is an abstract class. Concrete subclasses implement particular kinds of manipulator.- Version:
- $Id$
- Author:
- John Reekie, Michael Shilman
-
-
Constructor Summary
Constructors Constructor Description Manipulator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addGrabHandle(GrabHandle gh)
Add a grab-handle to this manipulator's collection of grab-handles.void
clearGrabHandles()
Clear all grab-handles.java.awt.geom.Rectangle2D
getBounds()
Get the bounds.GrabHandleFactory
getGrabHandleFactory()
Get the grab handle factory.DragInteractor
getHandleInteractor()
Get the grab handle interactor.boolean
isRepainting()
Test if this manipulator is in the process of repainting itself and its child.void
paint(java.awt.Graphics2D g)
Paint the manipulator.Figure
pick(java.awt.geom.Rectangle2D r)
Given a rectangle, return the top-most thing that hits it.abstract void
refresh()
Refresh the geometry.void
relocateGrabHandles()
Relocate grab-handles to their correct positions.void
removeGrabHandle(GrabHandle gh)
Remove a grab-handle from this manipulator's collection of grab-handles.void
repaint()
Request a repaint of the manipulator and child.void
repaint(DamageRegion d)
Receive repaint notification.void
repaintAlready()
Request a repaint of the manipulator and child.void
setGrabHandleFactory(GrabHandleFactory factory)
Set the grab handle factory.void
setHandleFilter(MouseFilter filter)
Set the mouse filter that is set in the grab handle interactor.void
setHandleInteractor(DragInteractor interactor)
Set the grab handle interactor.void
setRepainting(boolean repainting)
Set the repainting flag.-
Methods inherited from class diva.canvas.FigureDecorator
add, contains, figures, figuresFromBack, figuresFromFront, getChild, getContainer, getDecoratedFigure, getFigureCount, getShape, hit, newInstance, remove, replaceChild, setChild, transform, translate
-
Methods inherited from class diva.canvas.AbstractFigureContainer
decorate, pick, undecorate
-
Methods inherited from class diva.canvas.AbstractFigure
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, intersects, isVisible, paint, setInteractor, setParent, setToolTipText, setUserObject, setVisible
-
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
getTransformContext
-
Methods inherited from interface diva.canvas.VisibleComponent
isVisible, paint, setVisible
-
-
-
-
Method Detail
-
addGrabHandle
public void addGrabHandle(GrabHandle gh)
Add a grab-handle to this manipulator's collection of grab-handles.
-
clearGrabHandles
public void clearGrabHandles()
Clear all grab-handles.
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Get the bounds. This is the union of the child's bounding box and the bounding boxes of all the grab-handles- Specified by:
getBounds
in interfaceFigure
- Overrides:
getBounds
in classFigureDecorator
- Returns:
- the bounding box of this figure.
-
getGrabHandleFactory
public GrabHandleFactory getGrabHandleFactory()
Get the grab handle factory.
-
getHandleInteractor
public DragInteractor getHandleInteractor()
Get the grab handle interactor.
-
isRepainting
public boolean isRepainting()
Test if this manipulator is in the process of repainting itself and its child.
-
paint
public void paint(java.awt.Graphics2D g)
Paint the manipulator. This default implementation first paints the child figure, and then paints each of the grab-handles.- Specified by:
paint
in interfaceVisibleComponent
- Overrides:
paint
in classFigureDecorator
- Parameters:
g
- The Graphics context
-
pick
public Figure pick(java.awt.geom.Rectangle2D r)
Given a rectangle, return the top-most thing that hits it. This could be one of the grab-handles, or the child. If nothing hits, return null.- Specified by:
pick
in interfaceFigureContainer
- Overrides:
pick
in classAbstractFigureContainer
- Parameters:
r
- The rectangle- Returns:
- The figure
-
removeGrabHandle
public void removeGrabHandle(GrabHandle gh)
Remove a grab-handle from this manipulator's collection of grab-handles.
-
repaint
public void repaint(DamageRegion d)
Receive repaint notification. If the manipulator is already in the middle of repainting, ignore this request. Otherwise, generate another repaint call with the total region covered by the child and its grab-handles both before and after the grab-handles are moved to their new locations. Oh, and move the grab-handles to their new locations.- Specified by:
repaint
in interfaceCanvasComponent
- Overrides:
repaint
in classAbstractFigureContainer
- Parameters:
d
- The region where a repaint has occurred.
-
refresh
public abstract void refresh()
Refresh the geometry. This means that the location of geometry must be adjusted to match the current position of the child figure.
-
relocateGrabHandles
public void relocateGrabHandles()
Relocate grab-handles to their correct positions. This is a utility method to simplify notification callbacks.
-
repaint
public void repaint()
Request a repaint of the manipulator and child. This method generates another repaint call with the total region covered by the child and its grab-handles both before and after the grab-handles are moved to their new locations. It also adjusts the geometry to the current location of the child moves the grab-handles to their new locations.- Specified by:
repaint
in interfaceCanvasComponent
- Overrides:
repaint
in classAbstractFigure
-
repaintAlready
public void repaintAlready()
Request a repaint of the manipulator and child. This method generates another repaint call with the total region covered by the child and its grab-handles both before and after the grab-handles are moved to their new locations. It moves moves the grab-handles to their new locations, but does not adjust the geometry to the location of the child. This method should therefore be used for repaints that are generated by modifications to the geometry.
-
setGrabHandleFactory
public void setGrabHandleFactory(GrabHandleFactory factory)
Set the grab handle factory. This is set by default to an instance of BasicGrabHandleFactory.
-
setHandleFilter
public void setHandleFilter(MouseFilter filter)
Set the mouse filter that is set in the grab handle interactor.
-
setHandleInteractor
public void setHandleInteractor(DragInteractor interactor)
Set the grab handle interactor. The interactor is set by default to an instance of DragInteractor. Note that any previously-set mouse filter will be lost.
-
setRepainting
public void setRepainting(boolean repainting)
Set the repainting flag. This says that the manipulator is in the process of repainting itself and its child, and that it can therefore ignore repaint requests for the children.
-
-