JHotDraw 7.1

org.jhotdraw.draw
Class AbstractHandle

java.lang.Object
  extended by org.jhotdraw.draw.AbstractHandle
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener, FigureListener, Handle
Direct Known Subclasses:
AbstractConnectionHandle, AbstractRotateHandle, BezierControlPointHandle, BezierNodeHandle, BezierOutlineHandle, BezierScaleHandle, BoundsOutlineHandle, ConnectorHandle, DragHandle, LocatorHandle, ODGPathOutlineHandle, ODGRectRadiusHandle, RoundRectangleRadiusHandle, SVGPathOutlineHandle, SVGRectRadiusHandle, TextOverflowHandle, TriangleRotationHandler

public abstract class AbstractHandle
extends java.lang.Object
implements Handle, FigureListener

AbstractHandle.

Version:
1.0 2003-12-01 Derived from JHotDraw 5.4b1.
Author:
Werner Randelshofer

Field Summary
protected  javax.swing.event.EventListenerList listenerList
           
protected  DrawingView view
           
 
Constructor Summary
AbstractHandle(Figure owner)
          Creates a new instance.
 
Method Summary
 void addHandleListener(HandleListener l)
          Adds a listener for this handle.
 void areaInvalidated(FigureEvent evt)
          Sent when a region used by the figure needs to be repainted.
 void attributeChanged(FigureEvent e)
          Sent when an attribute of the figure has changed.
protected abstract  java.awt.Rectangle basicGetBounds()
           
 boolean contains(java.awt.Point p)
          Tests if a point is contained in the handle.
 java.util.Collection<Handle> createSecondaryHandles()
          Creates secondary handles.
 void dispose()
          Disposes the resources aquired by the handler.
 void draw(java.awt.Graphics2D g)
          Draws this handle.
protected  void drawCircle(java.awt.Graphics2D g, java.awt.Color fill, java.awt.Color stroke)
           
protected  void drawDiamond(java.awt.Graphics2D g, java.awt.Color fill, java.awt.Color stroke)
           
protected  void drawRectangle(java.awt.Graphics2D g, java.awt.Color fill, java.awt.Color stroke)
           
 void figureAdded(FigureEvent e)
          Sent when a figure was added.
 void figureChanged(FigureEvent evt)
          Sent when the bounds or shape of a figure has changed.
 void figureHandlesChanged(FigureEvent e)
          Sent when handles of a Figure have been added, removed or replaced.
 void figureRemoved(FigureEvent e)
          Sent when a figure was removed.
 void figureRequestRemove(FigureEvent e)
          Sent when a figure requests to be removed.
protected  void fireAreaInvalidated(java.awt.Rectangle invalidatedArea)
          Notify all listenerList that have registered interest for notification on this event type.
protected  void fireHandleRequestRemove(java.awt.Rectangle invalidatedArea)
          Notify all listenerList that have registered interest for notification on this event type.
protected  void fireHandleRequestSecondaryHandles()
          Notify all listenerList that have registered interest for notification on this event type.
protected  void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
          Notify all listenerList that have registered interest for notification on this event type.
 java.awt.Rectangle getBounds()
          Returns the bounding box of the handle.
 java.awt.Cursor getCursor()
          Returns a cursor for the handle.
 java.awt.Rectangle getDrawingArea()
          Returns the drawing area of the handle.
protected  int getHandlesize()
          FIXME - Get this form the drawing view.
 Figure getOwner()
          Returns the owner of this handle.
 java.lang.String getToolTipText(java.awt.Point p)
          Returns a tooltip for the specified location.
 DrawingView getView()
           
 void invalidate()
          Invalidates the handle.
 boolean isCombinableWith(Handle handle)
          Returns true, if the given handle is an instance of the same class or of a subclass of this handle,.
 void keyPressed(java.awt.event.KeyEvent evt)
           
 void keyReleased(java.awt.event.KeyEvent evt)
           
 void keyTyped(java.awt.event.KeyEvent evt)
           
 void removeHandleListener(HandleListener l)
          Removes a listener for this handle.
 void setView(DrawingView view)
          Sets the view of the handle.
 void trackDoubleClick(java.awt.Point p, int modifiersEx)
          Tracks a double click.
protected  void updateBounds()
           
 void viewTransformChanged()
          This method is invoked by the drawing view, when its transform has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jhotdraw.draw.Handle
trackEnd, trackStart, trackStep
 

Field Detail

view

protected DrawingView view

listenerList

protected javax.swing.event.EventListenerList listenerList
Constructor Detail

AbstractHandle

public AbstractHandle(Figure owner)
Creates a new instance.

Method Detail

getHandlesize

protected int getHandlesize()
FIXME - Get this form the drawing view.


addHandleListener

public void addHandleListener(HandleListener l)
Adds a listener for this handle.

Specified by:
addHandleListener in interface Handle

removeHandleListener

public void removeHandleListener(HandleListener l)
Removes a listener for this handle.

Specified by:
removeHandleListener in interface Handle

getOwner

public Figure getOwner()
Description copied from interface: Handle
Returns the owner of this handle.

Specified by:
getOwner in interface Handle

setView

public void setView(DrawingView view)
Description copied from interface: Handle
Sets the view of the handle.

Specified by:
setView in interface Handle

getView

public DrawingView getView()

fireAreaInvalidated

protected void fireAreaInvalidated(java.awt.Rectangle invalidatedArea)
Notify all listenerList that have registered interest for notification on this event type.


fireUndoableEditHappened

protected void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
Notify all listenerList that have registered interest for notification on this event type.


fireHandleRequestRemove

protected void fireHandleRequestRemove(java.awt.Rectangle invalidatedArea)
Notify all listenerList that have registered interest for notification on this event type.


fireHandleRequestSecondaryHandles

protected void fireHandleRequestSecondaryHandles()
Notify all listenerList that have registered interest for notification on this event type.


draw

public void draw(java.awt.Graphics2D g)
Draws this handle.

Specified by:
draw in interface Handle

drawCircle

protected void drawCircle(java.awt.Graphics2D g,
                          java.awt.Color fill,
                          java.awt.Color stroke)

drawRectangle

protected void drawRectangle(java.awt.Graphics2D g,
                             java.awt.Color fill,
                             java.awt.Color stroke)

drawDiamond

protected void drawDiamond(java.awt.Graphics2D g,
                           java.awt.Color fill,
                           java.awt.Color stroke)

contains

public boolean contains(java.awt.Point p)
Description copied from interface: Handle
Tests if a point is contained in the handle.

Specified by:
contains in interface Handle

invalidate

public void invalidate()
Description copied from interface: Handle
Invalidates the handle. This method informs its listeners that its current display box is invalid and should be refreshed.

Specified by:
invalidate in interface Handle

dispose

public void dispose()
Description copied from interface: Handle
Disposes the resources aquired by the handler.

Specified by:
dispose in interface Handle

areaInvalidated

public void areaInvalidated(FigureEvent evt)
Sent when a region used by the figure needs to be repainted. The implementation of this method assumes that the handle is located on the bounds of the figure or inside the figure. If the handle is located elsewhere this method must be reimpleted by the subclass.

Specified by:
areaInvalidated in interface FigureListener

figureAdded

public void figureAdded(FigureEvent e)
Sent when a figure was added.

Specified by:
figureAdded in interface FigureListener

figureRemoved

public void figureRemoved(FigureEvent e)
Sent when a figure was removed.

Specified by:
figureRemoved in interface FigureListener

figureRequestRemove

public void figureRequestRemove(FigureEvent e)
Sent when a figure requests to be removed.

Specified by:
figureRequestRemove in interface FigureListener

figureChanged

public void figureChanged(FigureEvent evt)
Sent when the bounds or shape of a figure has changed.

Specified by:
figureChanged in interface FigureListener

getCursor

public java.awt.Cursor getCursor()
Returns a cursor for the handle.

Specified by:
getCursor in interface Handle

isCombinableWith

public boolean isCombinableWith(Handle handle)
Returns true, if the given handle is an instance of the same class or of a subclass of this handle,.

Specified by:
isCombinableWith in interface Handle

keyTyped

public void keyTyped(java.awt.event.KeyEvent evt)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent evt)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
Specified by:
keyPressed in interface java.awt.event.KeyListener

getBounds

public final java.awt.Rectangle getBounds()
Description copied from interface: Handle
Returns the bounding box of the handle. Note: The bounding box must be returned in the coordinate system of the DrawingView.

Specified by:
getBounds in interface Handle

getDrawingArea

public java.awt.Rectangle getDrawingArea()
Description copied from interface: Handle
Returns the drawing area of the handle. Note: The drawing area must be returned in the coordinate system of the DrawingView.

Specified by:
getDrawingArea in interface Handle

basicGetBounds

protected abstract java.awt.Rectangle basicGetBounds()

updateBounds

protected void updateBounds()

trackDoubleClick

public void trackDoubleClick(java.awt.Point p,
                             int modifiersEx)
Tracks a double click.

Specified by:
trackDoubleClick in interface Handle

attributeChanged

public void attributeChanged(FigureEvent e)
Description copied from interface: FigureListener
Sent when an attribute of the figure has changed.

Specified by:
attributeChanged in interface FigureListener

viewTransformChanged

public void viewTransformChanged()
Description copied from interface: Handle
This method is invoked by the drawing view, when its transform has changed. This means, that DrawingView.viewToDrawing and DrawingView.drawingToView will return different values than they did before.

Specified by:
viewTransformChanged in interface Handle

createSecondaryHandles

public java.util.Collection<Handle> createSecondaryHandles()
Description copied from interface: Handle
Creates secondary handles.

Specified by:
createSecondaryHandles in interface Handle

getToolTipText

public java.lang.String getToolTipText(java.awt.Point p)
Description copied from interface: Handle
Returns a tooltip for the specified location.

Specified by:
getToolTipText in interface Handle

figureHandlesChanged

public void figureHandlesChanged(FigureEvent e)
Description copied from interface: FigureListener
Sent when handles of a Figure have been added, removed or replaced.

DrawingViews listen to this event to repopulate the Handles.

A Figure should not fire this event, if just the state or the location of Handle has changed.

Specified by:
figureHandlesChanged in interface FigureListener

Copyright 1996-2007 (c) JHotDraw.org.
Some rights reserved.