Eclipse GEF
3.0

org.eclipse.gef.handles
Class AbstractHandle

java.lang.Object
  extended byFigure
      extended byorg.eclipse.gef.handles.AbstractHandle
All Implemented Interfaces:
Handle
Direct Known Subclasses:
MoveHandle, SquareHandle

public abstract class AbstractHandle
extends Figure
implements Handle

Base implementation for handles. This class keeps track of the typical data needed by a handle, such as a drag tracker, a locator to place the handle, a cursor, and the editpart to which the handle belongs. AbstractHandle will add an AncestorListener to the owner's figure, and will automatically revalidate this handle whenever the owner's figure moves.

See Also:
Serialized Form

Constructor Summary
AbstractHandle()
          Null constructor
AbstractHandle(GraphicalEditPart owner, Locator loc)
          Creates a handle for the given GraphicalEditPart using the given Locator.
AbstractHandle(GraphicalEditPart owner, Locator loc, Cursor c)
          Creates a handle for the given GraphicalEditPart using the given Locator and Cursor.
 
Method Summary
 void addNotify()
          Adds this as an AncestorListener to the owner's Figure.
 void ancestorAdded(IFigure ancestor)
           
 void ancestorMoved(IFigure ancestor)
           
 void ancestorRemoved(IFigure ancestor)
           
protected abstract  DragTracker createDragTracker()
          Creates a new drag tracker to be returned by getDragTracker().
 Point getAccessibleLocation()
          By default, the center of the handle is returned.
 Cursor getDragCursor()
          Deprecated. use getCursor()
 DragTracker getDragTracker()
          Returns the drag tracker to use when the user clicks on this handle.
 Locator getLocator()
          Returns the Locator used to position this handle.
protected  GraphicalEditPart getOwner()
          Returns the GraphicalEditPart associated with this handle.
protected  IFigure getOwnerFigure()
          Convenience method to return the owner's figure.
 void removeNotify()
           
 void setDragCursor(Cursor c)
          Deprecated. use setCursor()
 void setDragTracker(DragTracker t)
          Sets the drag tracker for this handle.
protected  void setLocator(Locator locator)
          Sets the locator which position this handle.
protected  void setOwner(GraphicalEditPart editpart)
          Sets the owner editpart associated with this handle.
 void validate()
          Extends validate() to place the handle using its locator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHandle

public AbstractHandle()
Null constructor


AbstractHandle

public AbstractHandle(GraphicalEditPart owner,
                      Locator loc)
Creates a handle for the given GraphicalEditPart using the given Locator.

Parameters:
owner - The editpart which provided this handle
loc - The locator to position the handle

AbstractHandle

public AbstractHandle(GraphicalEditPart owner,
                      Locator loc,
                      Cursor c)
Creates a handle for the given GraphicalEditPart using the given Locator and Cursor.

Parameters:
owner - The editpart which provided this handle
loc - The locator to position the handle
c - The cursor to display when the mouse is over the handle
Method Detail

addNotify

public void addNotify()
Adds this as an AncestorListener to the owner's Figure.


ancestorMoved

public void ancestorMoved(IFigure ancestor)
See Also:
AncestorListener

ancestorAdded

public void ancestorAdded(IFigure ancestor)
See Also:
AncestorListener

ancestorRemoved

public void ancestorRemoved(IFigure ancestor)
See Also:
AncestorListener

createDragTracker

protected abstract DragTracker createDragTracker()
Creates a new drag tracker to be returned by getDragTracker().

Returns:
a new drag tracker

getAccessibleLocation

public Point getAccessibleLocation()
By default, the center of the handle is returned.

Specified by:
getAccessibleLocation in interface Handle
Returns:
null or the absolute location
See Also:
Handle.getAccessibleLocation()

getDragCursor

public Cursor getDragCursor()
Deprecated. use getCursor()

Returns the cursor. The cursor is displayed whenever the mouse is over the handle.

Returns:
the cursor

getDragTracker

public DragTracker getDragTracker()
Returns the drag tracker to use when the user clicks on this handle. If the drag tracker has not been set, it will be lazily created by calling createDragTracker().

Specified by:
getDragTracker in interface Handle
Returns:
the drag tracker

getLocator

public Locator getLocator()
Returns the Locator used to position this handle.

Returns:
the locator

getOwner

protected GraphicalEditPart getOwner()
Returns the GraphicalEditPart associated with this handle.

Returns:
the owner editpart

getOwnerFigure

protected IFigure getOwnerFigure()
Convenience method to return the owner's figure.

Returns:
the owner editpart's figure

removeNotify

public void removeNotify()
See Also:
IFigure

setDragCursor

public void setDragCursor(Cursor c)
                   throws Exception
Deprecated. use setCursor()

Sets the Cursor for the handle.

Parameters:
c - the cursor
Throws:
Exception - a bogus excpetion declaration

setDragTracker

public void setDragTracker(DragTracker t)
Sets the drag tracker for this handle.

Parameters:
t - the drag tracker

setLocator

protected void setLocator(Locator locator)
Sets the locator which position this handle.

Parameters:
locator - the new locator

setOwner

protected void setOwner(GraphicalEditPart editpart)
Sets the owner editpart associated with this handle.

Parameters:
editpart - the owner

validate

public void validate()
Extends validate() to place the handle using its locator.

See Also:
IFigure

Eclipse GEF
3.0

Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.