diva.canvas.interactor
Class Manipulator

java.lang.Object
  extended by diva.canvas.AbstractFigure
      extended by diva.canvas.AbstractFigureContainer
          extended by diva.canvas.FigureDecorator
              extended by 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: Manipulator.java 40092 2005-12-14 04:17:17Z cxh $
Author:
John Reekie, Michael Shilman

Field Summary
private  GrabHandleFactory _factory
          The factory that builds the grab handles.
private  java.util.ArrayList _grabHandles
          The grab-handles that belong to this manipulator
private  DragInteractor _handleInteractor
          The interactor for grab-handles
private  boolean _repainting
          A nasty little flag that turns off child repaints
 
Constructor Summary
Manipulator()
           
 
Method Summary
 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.VisibleComponent
isVisible, paint, setVisible
 
Methods inherited from interface diva.canvas.CanvasComponent
getParent, getTransformContext
 

Field Detail

_factory

private GrabHandleFactory _factory
The factory that builds the grab handles.


_grabHandles

private java.util.ArrayList _grabHandles
The grab-handles that belong to this manipulator


_handleInteractor

private DragInteractor _handleInteractor
The interactor for grab-handles


_repainting

private boolean _repainting
A nasty little flag that turns off child repaints

Constructor Detail

Manipulator

public Manipulator()
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 interface Figure
Overrides:
getBounds in class FigureDecorator

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 interface VisibleComponent
Overrides:
paint in class FigureDecorator

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 interface FigureContainer
Overrides:
pick in class AbstractFigureContainer

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 interface CanvasComponent
Overrides:
repaint in class AbstractFigureContainer

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 interface CanvasComponent
Overrides:
repaint in class AbstractFigure

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.