com.nwoods.jgo
Class JGoHandle

java.lang.Object
  extended bycom.nwoods.jgo.JGoObject
      extended bycom.nwoods.jgo.JGoDrawable
          extended bycom.nwoods.jgo.JGoRectangle
              extended bycom.nwoods.jgo.JGoHandle
All Implemented Interfaces:
JGoXMLSaveRestore, java.io.Serializable

public class JGoHandle
extends JGoRectangle

Represents a handle used for selecting, resizing, etc. an object. Handles also can define what the mouse cursor looks like when it is over the handle.

Handles are normally only added to views, not to documents. They should not be selected.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.nwoods.jgo.JGoObject
Bottom, BottomCenter, BottomLeft, BottomMiddle, BottomRight, Center, CenterLeft, CenterRight, Changed4ResizeHandles, ChangedAutoRescale, ChangedBrush, ChangedDraggable, ChangedDragsNode, ChangedGeometry, ChangedGrabChildSelection, ChangedInitializing, ChangedPen, ChangedResizable, ChangedSelectable, ChangedUpdatePartner, ChangedVisible, ChangedZOrder, LastChangedHint, Left, LeftCenter, NoHandle, NoSpot, NumReservedHandles, RepaintAll, Right, RightCenter, SideLeft, SideRight, Top, TopCenter, TopLeft, TopMiddle, TopRight
 
Constructor Summary
JGoHandle()
          Create a default new handle, with no particular rectangle and for no object.
JGoHandle(org.eclipse.swt.graphics.Rectangle rect, int cursorType)
          Create a new handle with the given rectangle and the given cursor.
JGoHandle(org.eclipse.swt.graphics.Rectangle rect, int cursorType, int handleType)
          Create a new handle with the given rectangle and the given cursor and handle types.
 
Method Summary
 JGoObject copyObject(JGoCopyEnvironment env)
          By default, handles are not copied.
 boolean doUncapturedMouseMove(int flags, org.eclipse.swt.graphics.Point dc, org.eclipse.swt.graphics.Point vc, JGoView view)
          Called when the mouse moves over this handle --- we set the cursor based on what type of handle we are.
protected  void gainedSelection(JGoSelection selection)
          Handles are not selectable.
 int getCursorType()
          Get the type of the cursor for this handle.
static int getDefaultHandleHeight()
          Return the default height for a handle.
static int getDefaultHandleWidth()
          Return the default width for a handle.
 JGoObject getHandleFor()
          Get the object for which this is a handle.
 int getHandleType()
          Get the type of this handle.
 JGoObject getPartner()
          Sometimes it is convenient to be able to associate an object with another object, without any predetermined knowledge about the class.
protected  void lostSelection(JGoSelection selection)
          Handles are not selectable.
 JGoObject redirectSelection()
          Handles are not selectable.
 void setCursorType(int cursorType)
          Set the type of the cursor for this handle.
static void setDefaultHandleHeight(int h)
          Change the default height for newly created handles.
static void setDefaultHandleWidth(int w)
          Change the default width for newly created handles.
 void setHandleFor(JGoObject obj)
          Set the object for which this is a handle.
 void setHandleType(int type)
          Change the type (location) of this handle.
 void setPartner(JGoObject obj)
          Sometimes it is convenient to be able to associate an object with another object, without any predetermined knowledge about the class.
 
Methods inherited from class com.nwoods.jgo.JGoRectangle
getNearestIntersectionPoint, paint, SVGReadAttributes, SVGReadObject, SVGWriteAttributes, SVGWriteObject
 
Methods inherited from class com.nwoods.jgo.JGoDrawable
changeValue, copyNewValueForRedo, draw3DRect, draw3DRect, drawEllipse, drawEllipse, drawEllipse, drawLine, drawLine, drawPath, drawPolygon, drawPolygon, drawRect, drawRect, drawRect, drawRoundRect, drawRoundRect, expandRectByPenWidth, getBrush, getNearestIntersectionPoint, getPen, setBrush, setPen, SVGAddPathArgs, SVGUpdateReference
 
Methods inherited from class com.nwoods.jgo.JGoObject
canView, computeBoundingRect, computeMove, computeResize, copy, copyObjectDelayed, copyOldValueForUndo, copyRect, doMouseClick, doMouseDblClick, findCommonParent, foredate, geometryChange, geometryChangeChild, getBoundingRect, getDocument, getDraggingObject, getFlags, getHeight, getLayer, getLeft, getLocation, getLocation, getParent, getParentJGoNode, getParentNode, getRectangleSpotLocation, getSize, getSize, getSpotLocation, getSpotLocation, getToolTipText, getTop, getTopLeft, getTopLeft, getTopLevelObject, getView, getWidth, growRect, handleMove, handleResize, hideSelectionHandles, is4ResizeHandles, isAutoRescale, isBoundingRectInvalid, isChildOf, isDraggable, isDragsNode, isInitializing, isPointInObj, isResizable, isSelectable, isSkipsUndoManager, isSuspendUpdates, isTopLevel, isUpdatePartner, isVisible, ownerChange, partnerUpdate, pick, remove, set4ResizeHandles, setAutoRescale, setBoundingRect, setBoundingRect, setBoundingRect, setBoundingRectInvalid, setBoundsRect, setDraggable, setDragsNode, setFlags, setHeight, setInitializing, setLeft, setLocation, setLocation, setLocationOffset, setLocationOffset, setParent, setRectangleSpotLocation, setResizable, setSelectable, setSize, setSize, setSizeKeepingLocation, setSkipsUndoManager, setSpotLocation, setSpotLocation, setSpotLocation, setSpotLocationOffset, setSuspendUpdates, setTop, setTopLeft, setTopLeft, setUpdatePartner, setVisible, setWidth, showSelectionHandles, spotOpposite, update, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGoHandle

public JGoHandle()
Create a default new handle, with no particular rectangle and for no object.


JGoHandle

public JGoHandle(org.eclipse.swt.graphics.Rectangle rect,
                 int cursorType)
Create a new handle with the given rectangle and the given cursor.


JGoHandle

public JGoHandle(org.eclipse.swt.graphics.Rectangle rect,
                 int cursorType,
                 int handleType)
Create a new handle with the given rectangle and the given cursor and handle types.

Method Detail

copyObject

public JGoObject copyObject(JGoCopyEnvironment env)
By default, handles are not copied.

Overrides:
copyObject in class JGoRectangle
Parameters:
env - the environment for the copy operation - keeps track of copied objects.

doUncapturedMouseMove

public boolean doUncapturedMouseMove(int flags,
                                     org.eclipse.swt.graphics.Point dc,
                                     org.eclipse.swt.graphics.Point vc,
                                     JGoView view)
Called when the mouse moves over this handle --- we set the cursor based on what type of handle we are. If the object for this handle is in a not modifiable layer/document, we do not change the cursor.

Overrides:
doUncapturedMouseMove in class JGoObject
Parameters:
flags - event specific flags
dc - the point of the click in document coordinates
vc - the point of the click in view coordinates
view - the view in which this event occured
Returns:
true if handled here and the view doesn't need to try this object's parent to see if it's interested
See Also:
JGoView.doUncapturedMouseMove(int, org.eclipse.swt.graphics.Point, org.eclipse.swt.graphics.Point)

gainedSelection

protected void gainedSelection(JGoSelection selection)
Handles are not selectable.

Overrides:
gainedSelection in class JGoObject
Parameters:
selection - the selection into which this object was added

lostSelection

protected void lostSelection(JGoSelection selection)
Handles are not selectable.

Overrides:
lostSelection in class JGoObject
Parameters:
selection - the selection from which this object was removed

redirectSelection

public JGoObject redirectSelection()
Handles are not selectable.

Overrides:
redirectSelection in class JGoObject
Returns:
by default, returns this object

getPartner

public JGoObject getPartner()
Description copied from class: JGoObject
Sometimes it is convenient to be able to associate an object with another object, without any predetermined knowledge about the class. Although JGoObject does not provide any storage for this "property", subclasses may decide to do so.

By default this returns null.

Overrides:
getPartner in class JGoObject

setPartner

public void setPartner(JGoObject obj)
Description copied from class: JGoObject
Sometimes it is convenient to be able to associate an object with another object, without any predetermined knowledge about the class. Although JGoObject does not provide any storage for this "property", subclasses may decide to do so.

By default this is a no-op.

Overrides:
setPartner in class JGoObject

setHandleFor

public final void setHandleFor(JGoObject obj)
Set the object for which this is a handle.

Parameters:
obj - the object for which this is a handle

getHandleFor

public final JGoObject getHandleFor()
Get the object for which this is a handle.

Returns:
the object for which this is a handle

setHandleType

public void setHandleType(int type)
Change the type (location) of this handle. The standard types are: Center, TopLeft, TopMiddle, TopRight, SideLeft, SideRight, BottomLeft, BottomMiddle, BottomRight Setting the handle type also sets the cursor type to a corresponding default value.

Parameters:
type - the new type for this handle

getHandleType

public int getHandleType()
Get the type of this handle.

Returns:
the type of the handle.

setCursorType

public void setCursorType(int cursorType)
Set the type of the cursor for this handle.

Parameters:
cursorType - the type of the cursor.

getCursorType

public int getCursorType()
Get the type of the cursor for this handle.

Returns:
the type of the cursor.

getDefaultHandleWidth

public static int getDefaultHandleWidth()
Return the default width for a handle. The initial value is 5.


setDefaultHandleWidth

public static void setDefaultHandleWidth(int w)
Change the default width for newly created handles.


getDefaultHandleHeight

public static int getDefaultHandleHeight()
Return the default height for a handle. The initial value is 5.


setDefaultHandleHeight

public static void setDefaultHandleHeight(int h)
Change the default height for newly created handles.