com.nwoods.jgo
Class JGoControl

java.lang.Object
  extended bycom.nwoods.jgo.JGoObject
      extended bycom.nwoods.jgo.JGoControl
All Implemented Interfaces:
JGoXMLSaveRestore, java.io.Serializable
Direct Known Subclasses:
JGoButton, JGoScrollBar, JGoTextEdit

public abstract class JGoControl
extends JGoObject

The parent of any class that defines a JGoObject represented by an SWT Control. Subclasses of JGoControl allow standard Controls to be used in a view with other JGoObjects, with some restrictions.

Normally JGoControls should be used as part of a view, not part of a document. If the JGoControl is part of a document it will have to create a separate, independent SWT Control for each view, and each view will have to resize, reposition, and repaint them.

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
JGoControl()
          Construct a new JGoControl.
JGoControl(org.eclipse.swt.graphics.Point location, Dimension size)
          Construct a JGoControl at a given location with a given size.
JGoControl(org.eclipse.swt.graphics.Rectangle rect)
          Construct a JGoControl with a bounding rectangle.
 
Method Summary
abstract  org.eclipse.swt.widgets.Control createControl(JGoView view)
          Each JGoControl subclass is responsible for representing the JGoControl with a Control that will be added to the JGoView's canvas.
protected  void geometryChange(org.eclipse.swt.graphics.Rectangle prevRect)
          If the object has been moved or resized, adjust the SWT Controls in all views accordingly.
 org.eclipse.swt.widgets.Control getControl(JGoView view)
          Returns an SWT Control associated with the JGoControl.
 java.util.Iterator getIterator()
          Return an iterator for getting all the known JGoView/Control mappings.
protected  void ownerChange(JGoObjectCollection oldOwner, JGoObjectCollection newOwner, JGoObject mainObject)
          We need to remove the SWT Control from the all of this document's JGoViews when this JGoControl is removed from the document.
 void paint(Graphics2D g, JGoView view)
          Cause the SWT Control associated with this JGoControl, as returned by getComponent(), to be drawn on the screen.
 void setVisible(boolean bFlag)
          If this JGoObject becomes visible, we need to make sure the SWT Control is created and is visible.
 
Methods inherited from class com.nwoods.jgo.JGoObject
canView, changeValue, computeBoundingRect, computeMove, computeResize, copy, copyNewValueForRedo, copyObject, copyObjectDelayed, copyOldValueForUndo, copyRect, doMouseClick, doMouseDblClick, doUncapturedMouseMove, expandRectByPenWidth, findCommonParent, foredate, gainedSelection, geometryChangeChild, getBoundingRect, getDocument, getDraggingObject, getFlags, getHeight, getLayer, getLeft, getLocation, getLocation, getNearestIntersectionPoint, getParent, getParentJGoNode, getParentNode, getPartner, 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, lostSelection, partnerUpdate, pick, redirectSelection, remove, set4ResizeHandles, setAutoRescale, setBoundingRect, setBoundingRect, setBoundingRect, setBoundingRectInvalid, setBoundsRect, setDraggable, setDragsNode, setFlags, setHeight, setInitializing, setLeft, setLocation, setLocation, setLocationOffset, setLocationOffset, setParent, setPartner, setRectangleSpotLocation, setResizable, setSelectable, setSize, setSize, setSizeKeepingLocation, setSkipsUndoManager, setSpotLocation, setSpotLocation, setSpotLocation, setSpotLocationOffset, setSuspendUpdates, setTop, setTopLeft, setTopLeft, setUpdatePartner, setWidth, showSelectionHandles, spotOpposite, SVGReadAttributes, SVGReadObject, SVGUpdateReference, SVGWriteAttributes, SVGWriteObject, update, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGoControl

public JGoControl()
Construct a new JGoControl.


JGoControl

public JGoControl(org.eclipse.swt.graphics.Rectangle rect)
Construct a JGoControl with a bounding rectangle.

Parameters:
rect - the bounding rectangle

JGoControl

public JGoControl(org.eclipse.swt.graphics.Point location,
                  Dimension size)
Construct a JGoControl at a given location with a given size.

Parameters:
location - the upper left corner, in document coordinates
size - the dimensions of the rectangle, in document coordinates
Method Detail

ownerChange

protected void ownerChange(JGoObjectCollection oldOwner,
                           JGoObjectCollection newOwner,
                           JGoObject mainObject)
We need to remove the SWT Control from the all of this document's JGoViews when this JGoControl is removed from the document. When it is added to a document, we need to make sure the SWT Control exists in each of the views, if this object is visible.

We need to remove the SWT Control from the JGoView's canvas when this JGoControl is removed from the view. When it is added to a view, we need to make sure the SWT Control exists, if this object is visible.

Overrides:
ownerChange in class JGoObject
Parameters:
oldOwner - the previous owner object
newOwner - the new owner object
mainObject - the object being inserted or removed from the document or view

getControl

public org.eclipse.swt.widgets.Control getControl(JGoView view)
Returns an SWT Control associated with the JGoControl. If there is not already a Control for this JGoControl in this JGoView, the method calls createControl(), caches the result, and adds the new Control to the view's canvas.

Parameters:
view - the view for which this control should be found or created
Returns:
a Control for this particular view

createControl

public abstract org.eclipse.swt.widgets.Control createControl(JGoView view)
Each JGoControl subclass is responsible for representing the JGoControl with a Control that will be added to the JGoView's canvas.

You may wish to return null when no Control is desired for this JGoControl, perhaps just for the given view.

Parameters:
view - the view for which this control should be created
Returns:
a Control

setVisible

public void setVisible(boolean bFlag)
If this JGoObject becomes visible, we need to make sure the SWT Control is created and is visible. If this JGoObject becomes invisible, we need to remove the SWT Control from the view.

Overrides:
setVisible in class JGoObject
Parameters:
bFlag - true if visible, false if not

geometryChange

protected void geometryChange(org.eclipse.swt.graphics.Rectangle prevRect)
If the object has been moved or resized, adjust the SWT Controls in all views accordingly.

Overrides:
geometryChange in class JGoObject

paint

public void paint(Graphics2D g,
                  JGoView view)
Cause the SWT Control associated with this JGoControl, as returned by getComponent(), to be drawn on the screen.

Subclasses will need to override this to handle the scaling issues involved with positioning and sizing the component. Painting should not be done with JGo's translated/scaled Graphics2D but later with the normal GC when this view's Control children are painted.

Overrides:
paint in class JGoObject
Parameters:
g - this Graphics should be ignored, because it is transformed
view - the view in which this control should be displayed

getIterator

public java.util.Iterator getIterator()
Return an iterator for getting all the known JGoView/Control mappings.