|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.nwoods.jgo.JGoObject
com.nwoods.jgo.JGoArea
com.nwoods.jgo.JGoNode
com.nwoods.jgo.JGoSubGraphBase
com.nwoods.jgo.JGoSubGraph
A node class that can contain and display a subgraph of other nodes and links, and that permits links to cross levels across the subgraph boundary, and that displays its own background color and border, and a label, and can be collapsed to just display a collapsed object and a label.
The bounding rectangle, as with any JGoArea, is determined by the computeBoundingRect method, considering the positions and sizes of the visible child objects. The rectangular region that displays the background color and a border is determined by the computeBorder method. The BackgroundColor, Opacity, and BorderPen properties control the appearance of the bordered region. This bordered region surrounds the region occupied by the child objects (nodes and links) and determined by the computeInsideMargins method, with margins all around as specified by the Insets or CollapsedInsets property. You can change the size of the margins in order to provide additional space between the child objects (typically nodes) and the border. If the subgraph is Resizable, the user can resize the border rectangle. This will modify the Insets property. As the child objects are moved around, or as new child objects are added, the new margin insets will be maintained around all of the subgraph's children.
Each JGoSubGraph has a small rectangular JGoSubGraphHandle that users can click on to collapse or expand the size of the node. Collapsing is accomplished by making all of the children (except the label and the subgraph handle) not visible and moving them to be centered in the top-left corner of the subgraph. The original positions are remembered so that an expand will restore the positions. If there is a CollapsedObject, it is made visible. You can check if a subgraph is collapsed or expanded by calling the isExpanded() predicate, and you can change its state by calling the collapse and expand methods. The Collapsible property controls whether the user can click on the Handle to collapse or expand the subgraph. You can override the createHandle method to return null if you don't want a handle at all.
Each subgraph also has a Label, a JGoText object, that can name the whole subgraph rather than any individual child object. The Label, like the Handle, is normally not Selectable, so the user can drag the subgraph around by dragging the Label or the Handle.
There are layout... methods that are called by layoutChildren to position each of the special child objects: the Handle, the Label, the CollapsedObject, and the Port. These methods position the child relative to rectangle returned by a call to computeInsideMargins or computeBorder. You can override these methods to do what you want, but you can set the LabelSpot and CollapsedLabelSpot properties to affect the behavior of the layoutLabel method.
If you override any of layout methods, you may also need to override the computeInsideMarginsSkip method, depending on whether any particular child object should contribute toward the size of the area inside the margins. Also, if you want to change the position of the collapsed subgraph relative to the Handle, you will need to override the computeCollapsedRectangle method.
Each JGoSubGraph can also have a JGoPort, as the Port property, that can have links connected to it to represent connecting to the subgraph as a whole node, rather than to any particular child node. By default the createPort method returns null, so a subgraph will not have any port for itself. But you can override createPort to return a JGoPort, or you can set the Port property. By default layoutPort will give the port the same bounding rect as the Handle. But you can override layoutPort to give it larger bounds, such as the rectangle returned by computeBorder(). See the example subgraph classes.
By default a JGoSubGraph has no CollapsedObject either. You can override createCollapsedObject to return some object, or you can set the CollapsedObject property. By default the CollapsedObject should be not Visible when the subgraph is expanded, and Visible when the subgraph is collapsed. It is fairly common to have the CollapsedObject be an instance of a JGoImage, thereby giving a collapsed subgraph the appearance of an icon with a label.
Field Summary | |
static int |
ChangedBackgroundColor
a CHANGED JGoDocumentEvent subhint: the background color has changed |
static int |
ChangedBorderPen
a CHANGED JGoDocumentEvent subhint: the pen for drawing the border has changed |
static int |
ChangedCollapsedInsets
a CHANGED JGoDocumentEvent subhint: the collapsed insets have changed |
static int |
ChangedCollapsedLabelSpot
a CHANGED JGoDocumentEvent subhint: the collapsed label spot has changed |
static int |
ChangedCollapsedObject
a CHANGED JGoDocumentEvent subhint: the CollapsedObject has been replaced |
static int |
ChangedCollapsible
a CHANGED JGoDocumentEvent subhint: whether the node is collapsible has changed |
static int |
ChangedExpandedResizable
|
static int |
ChangedInsets
a CHANGED JGoDocumentEvent subhint: the insets have changed |
static int |
ChangedLabel
a CHANGED JGoDocumentEvent subhint: the Label has been replaced |
static int |
ChangedLabelSpot
a CHANGED JGoDocumentEvent subhint: the spot for the label has changed |
static int |
ChangedOpacity
a CHANGED JGoDocumentEvent subhint: the opacity has changed |
static int |
ChangedPort
a CHANGED JGoDocumentEvent subhint: the Port has been replaced |
static int |
ChangedSavedBounds
|
static int |
ChangedSavedPaths
|
static int |
ChangedState
a CHANGED JGoDocumentEvent subhint: the state has changed |
static int |
ChangedWasExpanded
|
static int |
StateCollapsed
The value of getState() after a call to collapse(). |
static int |
StateCollapsing
The value of getState() during a call to collapse(). |
static int |
StateExpanded
The value of getState() after a call to expand(). |
static int |
StateExpanding
The value of getState() during a call to expand(). |
Fields inherited from class com.nwoods.jgo.JGoNode |
ChangedPartID, ChangedToolTipText, ChangedUserObject, PartsLinks, PartsLinksIn, PartsLinksOut, PartsNodes, PartsNodesIn, PartsNodesOut, PartsNotSelf, PartsPorts |
Fields inherited from class com.nwoods.jgo.JGoArea |
ChangedPickableBackground |
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 | |
JGoSubGraph()
Construct an empty JGoSubGraph--call the initialize method before further use. |
|
JGoSubGraph(java.lang.String labeltext)
Construct a JGoSubGraph containing a Label and a Handle, but no other children. |
Method Summary | |
JGoListPosition |
addObjectAtHead(JGoObject obj)
When adding an object, assume it can be dragged around by itself, without dragging the whole JGoSubGraph. |
JGoListPosition |
addObjectAtTail(JGoObject obj)
When adding an object, assume it can be dragged around by itself, without dragging the whole JGoSubGraph. |
void |
changeValue(JGoDocumentChangedEdit e,
boolean undo)
This method is called by the JGoDocumentChangedEdit.undo and redo methods to actually perform the property value change for a JGoObject. |
void |
collapse()
Reposition all of the children so that this node takes a minimum amount of space. |
protected void |
collapseChild(JGoObject child,
org.eclipse.swt.graphics.Rectangle sgrect)
Center all the objects that aren't links (besides Handle, Label, and a port) and make everything invisible (besides Label and Handle and ports). |
org.eclipse.swt.graphics.Rectangle |
computeBorder()
The border goes around the rectangle returned by computeInsideMargins() augmented by margins all around. |
protected org.eclipse.swt.graphics.Rectangle |
computeBoundingRect()
Computation of the bounding rectangle for this area includes all visible child objects plus the region of the painted background and border, as returned by computeBorder(). |
protected org.eclipse.swt.graphics.Rectangle |
computeCollapsedRectangle(Dimension s)
Given a desired collapsed size, return the expected collapsed area, ignoring any collapsed insets. |
Dimension |
computeCollapsedSize(boolean visible)
Determine the size that this subgraph should be when collapsed, excluding any collapsed margin. |
protected boolean |
computeCollapsedSizeSkip(JGoObject child)
This predicate is called by computeCollapsedSize() to decide if a child object should take part in the size calculation. |
org.eclipse.swt.graphics.Rectangle |
computeInsideMargins(JGoObject ignore)
Determine the region occupied by the subgraph's child nodes, excluding any margins. |
protected boolean |
computeInsideMarginsSkip(JGoObject child)
This method is called by computeInsideMargins to see if a given child of this subgraph should be ignored. |
protected org.eclipse.swt.graphics.Point |
computeReferencePoint()
Return the point from which the relative positions of the children are calculated. |
protected void |
copyChildren(JGoArea newarea,
JGoCopyEnvironment env)
Copy all of the subgraph state, including the saved bounds and the saved paths. |
void |
copyNewValueForRedo(JGoDocumentChangedEdit e)
This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed. |
void |
copyOldValueForUndo(JGoDocumentChangedEdit e)
This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed. |
protected JGoObject |
createCollapsedObject()
Return the object to be shown, instead of the standard background color and border, when this subgraph is collapsed. |
JGoSubGraphHandle |
createHandle()
Create a JGoSubGraphHandle. |
JGoText |
createLabel(java.lang.String labeltext)
Create and initialize a text label displaying the given string. |
protected JGoPort |
createPort()
This method is called to create a port that represents the subgraph as a whole. |
void |
expand()
Restore the position of all of the children so that this subgraph is editable again. |
void |
expandAll()
This method calls expand() on this node and then recursively proceeds through all of the children, expanding them. |
protected void |
expandChild(JGoObject child,
org.eclipse.swt.graphics.Point hpos)
Restore a child to its original size and position. |
void |
expandRectByPenWidth(org.eclipse.swt.graphics.Rectangle rect)
Account for the width of the border and BorderPen, if any. |
protected void |
finishCollapse(org.eclipse.swt.graphics.Rectangle sgrect)
This method is called towards the end of the process of a collapse() call. |
protected void |
finishExpand(org.eclipse.swt.graphics.Point hpos)
This method is called at the end of the process of an expand() call. |
protected void |
gainedSelection(JGoSelection selection)
Resize handles are placed at the four or eight spots of the rectangle given by computeBorder(), not at the standard spots of the getBoundingRect(). |
org.eclipse.swt.graphics.RGB |
getBackgroundColor()
Return the color of the background. |
JGoPen |
getBorderPen()
Return the JGoPen used to draw the border. |
Insets |
getCollapsedInsets()
Return the margins when this subgraph is collapsed. |
int |
getCollapsedLabelSpot()
Return the spot at which the Label should be positioned relative to the object returned by getCollapsedObject() when this subgraph is in a collapsed state, or if there is no collapsed object, relative to the hidden child nodes. |
JGoObject |
getCollapsedObject()
Return an object to be shown when the subgraph is collapsed. |
JGoSubGraphHandle |
getHandle()
Return the small rectangular Handle that the user can click on to collapse or expand the subgraph. |
Insets |
getInsets()
Return the margin insets to be added on all sides when computing the size of this node. |
JGoText |
getLabel()
Return the JGoText label. |
int |
getLabelSpot()
Return the spot at which the Label should be positioned relative to the rest of the children of this node. |
double |
getOpacity()
Return a number from 0.0 to 1.0 that describes how opaquely the BackgroundColor, if solid, should be drawn. |
JGoPort |
getPort()
Return the JGoPort, if any, that represents the subgraph as a whole. |
java.util.HashMap |
getSavedBounds()
Return a HashMap that remembers the relative position and original dimensions of each child object when the subgraph is collapsed. |
java.util.HashMap |
getSavedPaths()
Return a HashMap that remembers the stroke points of each link that is a child of this subgraph when the subgraph is collapsed. |
protected int |
getState()
Return one of StateExpanded, StateCollapsed, StateExpanding, or StateCollapsing. |
protected org.eclipse.swt.graphics.Rectangle |
handleResize(Graphics2D g,
JGoView view,
org.eclipse.swt.graphics.Rectangle origRect,
org.eclipse.swt.graphics.Point newPoint,
int whichHandle,
int evttype,
int minWidth,
int minHeight)
Let the user change the size of this subgraph without resizing or repositioning any of the subgraph's child objects. |
void |
initialize(java.lang.String labeltext)
Initialize the subgraph by creating a label and a handle. |
JGoListPosition |
insertObjectAfter(JGoListPosition pos,
JGoObject obj)
When adding an object, assume it can be dragged around by itself, without dragging the whole JGoSubGraph. |
JGoListPosition |
insertObjectBefore(JGoListPosition pos,
JGoObject obj)
When adding an object, assume it can be dragged around by itself, without dragging the whole JGoSubGraph. |
boolean |
isCollapsible()
Return whether the user can collapse or expand the node by clicking on the Handle. |
boolean |
isExpanded()
Gets whether this subgraph is in an expanded state. |
void |
layoutChildren(JGoObject child)
Always update the positions of the Label, the Handle, and the Port. |
protected void |
layoutCollapsedObject()
This positions the CollapsedObject (if any) within the subgraph. |
protected void |
layoutHandle()
Position the Handle, if any, at the top-left corner of this node, inside the margin. |
protected void |
layoutLabel()
This positions the Label, if any, according to the LabelSpot relative to all the children, excluding any Handle and any invisible links. |
void |
layoutPort()
Position and size the Port, if any, to have the same bounding rectangle as the Handle. |
void |
paint(Graphics2D g,
JGoView view)
Paint first calls paintDecoration before painting the child objects, if the paintsDecoration predicate returns true. |
protected void |
paintDecoration(Graphics2D g,
JGoView view)
Fill the BackgroundColor and draw the BorderPen. |
protected boolean |
paintsDecoration(JGoView view)
Return true if there is no CollapsedObject, or if the CollapsedObject is not Visible. |
protected void |
prepareCollapse()
Do any work before collapsing this subgraph. |
protected void |
prepareExpand()
Do any work before expanding the children. |
JGoObject |
removeObjectAtPos(JGoListPosition pos)
When an object is removed, make sure there are no more references from fields. |
protected void |
saveChildBounds(JGoObject child,
org.eclipse.swt.graphics.Rectangle sgrect)
Save the original size and relative position for all non-links, and the paths of all links. |
void |
setBackgroundColor(org.eclipse.swt.graphics.RGB c)
Change the background color. |
void |
setBorderPen(JGoPen p)
Change the pen used to draw the border. |
void |
setCollapsedInsets(Insets x)
Change the insets around this node when it is collapsed. |
void |
setCollapsedLabelSpot(int value)
Change the spot of the Label relative to the object returned by getCollapsedObject() when this subgraph is collapsed, or if there is no collapsed object, relative to the hidden child nodes. |
void |
setCollapsedObject(JGoObject value)
Replace the collapsed object to be shown when this subgraph is collapsed. |
void |
setCollapsible(boolean bFlag)
Change whether the user is allowed to toggle whether this node is expanded or collapsed. |
void |
setInsets(Insets x)
Change the insets around this node. |
void |
setLabel(JGoText value)
Replace the Label. |
void |
setLabelSpot(int s)
Change the positioning spot for the label. |
void |
setOpacity(double opacity)
Change the opacity of the background. |
void |
setPort(JGoPort value)
|
protected void |
setState(int value)
Change the current exansion state to one of StateExpanded, StateCollapsed, StateExpanding, or StateCollapsing. |
DomNode |
SVGReadObject(DomDoc svgDoc,
JGoDocument jGoDoc,
DomElement svgElement,
DomElement jGoChildElement)
Read this object in from a DomDoc representing a Scalable Vector Graphics (SVG) XML document. |
void |
SVGUpdateReference(java.lang.String attr,
java.lang.Object referencedObject)
This method will be called to fill in object references. |
void |
SVGWriteObject(DomDoc svgDoc,
DomElement jGoElementGroup)
Write this object out to a DomDoc representing a Scalable Vector Graphics (SVG) XML document. |
void |
toggle()
This convenience method calls either collapse() or expand(), depending on the value of isExpanded(). |
Methods inherited from class com.nwoods.jgo.JGoSubGraphBase |
findParentSubGraph, pickObjects, reparentAllLinksToSubGraphs, reparentAllLinksToSubGraphs, reparentToCommonSubGraph |
Methods inherited from class com.nwoods.jgo.JGoNode |
copyObject, findAll, getPartID, getText, getToolTipText, getUserObject, setPartID, setText, setToolTipText, setUserObject |
Methods inherited from class com.nwoods.jgo.JGoArea |
addCollection, addCollection, bringObjectToFront, findObject, geometryChange, geometryChangeChild, getFirstObjectPos, getLastObjectPos, getNearestIntersectionPoint, getNextObjectPos, getNextObjectPosAtTop, getNumObjects, getObjectAtPos, getPrevObjectPos, isEmpty, isPickableBackground, moveChildren, pick, pickObject, removeObject, rescaleChildren, sendObjectToBack, setPickableBackground |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int StateExpanded
public static final int StateCollapsed
public static final int StateExpanding
public static final int StateCollapsing
public static final int ChangedBackgroundColor
public static final int ChangedBorderPen
public static final int ChangedLabelSpot
public static final int ChangedCollapsible
public static final int ChangedInsets
public static final int ChangedOpacity
public static final int ChangedCollapsedLabelSpot
public static final int ChangedCollapsedInsets
public static final int ChangedCollapsedObject
public static final int ChangedLabel
public static final int ChangedPort
public static final int ChangedState
public static final int ChangedSavedBounds
public static final int ChangedSavedPaths
public static final int ChangedWasExpanded
public static final int ChangedExpandedResizable
Constructor Detail |
public JGoSubGraph()
public JGoSubGraph(java.lang.String labeltext)
labeltext
- the initial string for the label; this is passed to createLabelMethod Detail |
public void initialize(java.lang.String labeltext)
This calls createLabel and createHandle and adds the resulting objects, if any, to this subgraph as the Label and Handle properties.
public JGoText createLabel(java.lang.String labeltext)
By default the JGoText object is not Selectable, but is Editable, Bold, Multiline and supports Wrapping.
labeltext
- the String to be displayed; if null, no JGoText label is returnedpublic JGoSubGraphHandle createHandle()
protected JGoPort createPort()
By default this returns null--the subgraph does not have a port.
protected JGoObject createCollapsedObject()
By default this returns null.
protected void copyChildren(JGoArea newarea, JGoCopyEnvironment env)
copyChildren
in class JGoArea
newarea
- the area newly created by copyObject() to which we need to
add copies of the children of this areaenv
- the environment for the copy operation - keeps track of copied objects.public JGoListPosition addObjectAtHead(JGoObject obj)
JGoObject.setDragsNode(false)
on the object.
addObjectAtHead
in interface JGoObjectCollection
addObjectAtHead
in class JGoArea
obj
- the child object to add.
public JGoListPosition addObjectAtTail(JGoObject obj)
JGoObject.setDragsNode(false)
on the object.
addObjectAtTail
in interface JGoObjectCollection
addObjectAtTail
in class JGoArea
obj
- the child object to add.
public JGoListPosition insertObjectBefore(JGoListPosition pos, JGoObject obj)
JGoObject.setDragsNode(false)
on the object.
insertObjectBefore
in interface JGoObjectCollection
insertObjectBefore
in class JGoArea
pos
- the position before which to add the child.obj
- the child object to add.public JGoListPosition insertObjectAfter(JGoListPosition pos, JGoObject obj)
JGoObject.setDragsNode(false)
on the object.
insertObjectAfter
in interface JGoObjectCollection
insertObjectAfter
in class JGoArea
pos
- the position after which to add the child.obj
- the child object to add.
public JGoObject removeObjectAtPos(JGoListPosition pos)
removeObjectAtPos
in interface JGoObjectCollection
removeObjectAtPos
in class JGoArea
public void paint(Graphics2D g, JGoView view)
paint
in class JGoArea
g
- the graphics context on which to draw this area.view
- the view we're drawing inprotected boolean paintsDecoration(JGoView view)
This is called by the paint method to decide whether to call paintDecoration.
protected void paintDecoration(Graphics2D g, JGoView view)
When the BackgroundColor is solid/opaque, the Opacity property controls the translucency of the background.
public void expandRectByPenWidth(org.eclipse.swt.graphics.Rectangle rect)
expandRectByPenWidth
in class JGoArea
rect
- a rectangle to be modifiedprotected org.eclipse.swt.graphics.Rectangle computeBoundingRect()
computeBoundingRect
in class JGoArea
public org.eclipse.swt.graphics.Rectangle computeBorder()
public org.eclipse.swt.graphics.Rectangle computeInsideMargins(JGoObject ignore)
If all child objects are skipped, as when there are no nodes in the subgraph, this will try to provide a reasonable value for the region inside the margins, by using the CollapsedObject, if any. Otherwise the return value may well have a width and height of zero.
This is called by computeBorder with a null argument. layoutCollapsedObject calls this method passing the CollapsedObject, and layoutLabel calls this method passing the Label, so that those layout methods can determine the region without the collapsed-object and label, respectively, affecting the calculations.
ignore
- a child object to ignore, in addition to children
skipped because computeInsideMarginsSkip returned true
protected boolean computeInsideMarginsSkip(JGoObject child)
Child objects such as the Handle, Port, an invisible Label or CollapsedObject, and invisible links or internal links connected to this subgraph's Port should not be included in the computation of the computeInsideMargins method, because they may be outside of the inside area where the child nodes are.
Any override of this method to return true for additional objects may also override one of the layout... methods to make sure those objects are positioned in the desired manner.
child
- a child object of this subgraph
protected void gainedSelection(JGoSelection selection)
gainedSelection
in class JGoObject
selection
- the selection into which this object was addedprotected org.eclipse.swt.graphics.Rectangle handleResize(Graphics2D g, JGoView view, org.eclipse.swt.graphics.Rectangle origRect, org.eclipse.swt.graphics.Point newPoint, int whichHandle, int evttype, int minWidth, int minHeight)
This just calls setInsets() or setCollapsedInsets(), depending on isExpanded(). Of course this method isn't used unless this subgraph isResizable(), which by default it is not.
handleResize
in class JGoObject
g
- the graphics context to draw onview
- the view we're being resizing inorigRect
- the object's original bounding rectanglenewPoint
- the location of the new pointwhichHandle
- the handle number of the point being movedevttype
- one of: JGoView.EventMouseUp, JGoView.EventMouseMove, JGoView.EventMouseDownminWidth
- the minimum width of the object (defaults to zero)minHeight
- the minimum height of the object (defaults to zero)public void layoutChildren(JGoObject child)
This method does nothing if isInitializing() is true. This just calls layoutCollapsedObject(), layoutLabel(), layoutHandle(), and layoutPort(), unless the child that was moved/resized is the Handle or the Port.
layoutChildren
in class JGoArea
child
- the child JGoObject that was moved or changed
size; this may be null, indicating that everything should
be reconsideredJGoArea.geometryChange(org.eclipse.swt.graphics.Rectangle)
,
JGoArea.geometryChangeChild(com.nwoods.jgo.JGoObject, org.eclipse.swt.graphics.Rectangle)
protected void layoutCollapsedObject()
By default the position of the CollapsedObject is set to be in the top-left corner of the rectangle returned by computeInsideMargins (ignoring the CollapsedObject itself, of course) if isExpanded() is true. For a collapsed subgraph, the collapsed object is positioned at the top-left corner of the rectangle returned by computeCollapsedRectangle.
protected void layoutLabel()
When isExpanded() is false, the CollapsedLabelSpot is used instead. The Label will normally be positioned inside the margin, according to the Insets if expanded or the CollapsedInsets when collapsed.
protected void layoutHandle()
public void layoutPort()
public Dimension computeCollapsedSize(boolean visible)
Unlinke computeBoundingRect(), this method is used to calculate the expected size of this node when collapsed, so that collapse() can call collapseChild() and finishCollapse() with the intended collapsed bounds. This method does not augment the size to include the CollapsedInsets.
Note that the standard behavior of this method makes sure the resulting size is wide enough to hold each child node and tall enough to hold each child node--it is not just the size of any CollapsedObject. The reason is that the standard behavior wants to insure that all links connected to child nodes will end at or in the collapsed subgraph, not potentially far away from the subgraph. You may wish to override this method to return the size of the getCollapsedObject() or some fixed dimensions.
visible
- true when the size of any getCollapsedObject() should be considered.
protected boolean computeCollapsedSizeSkip(JGoObject child)
This is similar to computeInsideMarginsSkip, but is called by computeCollapsedSize.
child
-
protected org.eclipse.swt.graphics.Point computeReferencePoint()
protected org.eclipse.swt.graphics.Rectangle computeCollapsedRectangle(Dimension s)
This depends on the result of a call to computeReferencePoint().
s
- a Dimension in document coordinates, normally the result of a call to computeCollapsedSize().
public void collapse()
This method will first set the State to StateCollapsing and set Initializing to true, and then calls prepareCollapse().
It will call computeReferencePoint() to determine the reference position for the collapsed subgraph and computeCollapsedSize() to determine the desired size of the collapsed subgraph.
It then will call saveChildBounds() to remember the expanded size and relative position of each child, will call collapseChild() to actually move and perhaps resize each child, and then will call finishCollapse() to make any CollapsedObject visible.
It then sets JGoObject's Initializing property to false and sets the State to StateCollapsed.
Afterwards, isExpanded() will be false, and this method calls layoutChildren(null) to give LayoutLabel(), LayoutHandle(), and LayoutPort() a chance.
This method does nothing if this node is already collapsed or if isCollapsible() is false.
protected void prepareCollapse()
By default this does nothing.
This is called while isInitializing() is true.
protected void saveChildBounds(JGoObject child, org.eclipse.swt.graphics.Rectangle sgrect)
This saves the points of link strokes, relative to the sgrect's position, in the SavedPaths hash table. For other objects, besides the Handle, a port, Label, or CollapsedObject, this saves the current size and position relative to the sgrect in the SavedBounds hash table.
This is called while isInitializing() is true.
child
- sgrect
- the expected bounding rectangle of the collapsed subgraph,
without the collapsed insetsprotected void collapseChild(JGoObject child, org.eclipse.swt.graphics.Rectangle sgrect)
This will collapse() each child JGoSubGraph. This is called while isInitializing() is true.
child
- sgrect
- the expected bounding rectangle of the collapsed subgraph,
without the collapsed insetsprotected void finishCollapse(org.eclipse.swt.graphics.Rectangle sgrect)
By default this method makes any CollapsedObject visible and makes the whole subgraph not resizable.
This is called while isInitializing() is true.
sgrect
- the expected bounding rectangle of the collapsed subgraph,
without the collapsed insetspublic void expand()
The collapse() call saved the original bounds of all of the non-link children. These saved relative positions and dimensions are used to move all of the children back again, and making them all visible too.
This method will first set the State to StateExpanding and set JGoObject's Initializing property to true, and then call prepareExpand() for any preparatory work.
It will call computeReferencePoint() to determine the reference position for the expanded subgraph.
It calls expandChild() on each child to move them back to their original locations, and will call finishExpand() for any clean-up work.
It then sets Initializing back to false and sets the State to StateExpanded.
This method does nothing if this node is already expanded or if isCollapsible() is false.
In case the sizes of objects have changed while the subgraph was collapsed, this method also calls layoutChildren(null) afterwards, mostly to make sure the Handle and Label are positioned correctly again.
protected void prepareExpand()
By default this does nothing.
This is called while isInitializing() is true.
protected void expandChild(JGoObject child, org.eclipse.swt.graphics.Point hpos)
This uses the SavedBounds hashtable for getting the saved size and relative position of a child, and this uses the SavedPaths hashtable for getting the relative points of link strokes.
This method also makes sure each child is made Visible again, except for the CollapsedObject.
This is called while isInitializing() is true.
child
- hpos
- the reference point for restoring the new position, the Handle's top-left positionprotected void finishExpand(org.eclipse.swt.graphics.Point hpos)
By default this just clears all saved information in the SavedBounds and SavedPaths hashtables, it makes any CollapsedObject not visible, and it restores whether the expanded subgraph is resizable.
This is called while isInitializing() is true.
hpos
- the reference point for restoring the new position, the Handle's top-left positionpublic void toggle()
public void expandAll()
public java.util.HashMap getSavedBounds()
This maps child JGoObjects to Rectangles, where each Rectangle holds the pre-collapse position and dimensions of each child object. The position is relative to the Handle, not an absolute position in document coordinates.
public java.util.HashMap getSavedPaths()
This maps JGoStrokes to ArrayLists of Points, where each Point has been offset relative to the Handle.
public JGoSubGraphHandle getHandle()
public JGoText getLabel()
The Label is created by createLabel() when the subgraph is initialized.
getLabel
in interface JGoLabeledPart
getLabel
in class JGoNode
public void setLabel(JGoText value)
setLabel
in class JGoNode
value
- a different JGoText object,
presumably one that has the Selectable property set to false,
and likely to be a subclass of JGoText.public JGoPort getPort()
public void setPort(JGoPort value)
public JGoObject getCollapsedObject()
By default this is null, which is the default result of the createCollapsedObject method, called when initialized. In this case paintDecoration will instead show the standard background color and border.
public void setCollapsedObject(JGoObject value)
You will probably want this object to be not Selectable. The new collapsed object will get the same visibility as the old object, if there was one. If there was no CollapsedObject, you will probably want to make sure the object's Visible property is set to the appropriate value given the isExpanded() state of the subgraph.
value
- a JGoObject that will become a child of this subgraph,
and whose visibility will be toggled as the subgraph is collapsed
and expanded; may be null, so that only the background color and
border pen are paintedpublic org.eclipse.swt.graphics.RGB getBackgroundColor()
public void setBackgroundColor(org.eclipse.swt.graphics.RGB c)
public void setOpacity(double opacity)
opacity
- A value of 0.0 means transparent; a value of 1.0 means completely opaque.
Values less than zero or greater than 1.0 are ignored.public double getOpacity()
public JGoPen getBorderPen()
By default, there is no border pen.
public void setBorderPen(JGoPen p)
p
- a null value will cause no border to be drawnpublic Insets getInsets()
By default there will be a border of width or height 4 all around the node.
public void setInsets(Insets x)
x
- the new Insets; each value (top, left, bottom, right) must be non-negative.public Insets getCollapsedInsets()
By default there are no insets on any side.
public void setCollapsedInsets(Insets x)
x
- the new Insets; each value (top, left, bottom, right) must be non-negative.public int getLabelSpot()
By default, this is JGoObject.TopCenter.
public void setLabelSpot(int s)
public int getCollapsedLabelSpot()
This defaults to JGoObject.Center.
public void setCollapsedLabelSpot(int value)
public boolean isExpanded()
The initial value is true.
protected int getState()
protected void setState(int value)
This should only be called by implementations of collapse() and expand().
public void setCollapsible(boolean bFlag)
When the value is true, the handle will be drawn as either a "-" or a "+". When this value is false, the handle will be drawn in a different fashion.
public boolean isCollapsible()
The default value is true.
public void copyOldValueForUndo(JGoDocumentChangedEdit e)
JGoObject
The exact nature of the Object depends on the particular event hint or sub-hint, of course, but is typically a Rectangle or Point or some similar structure that is actually owned by the object. The responsibility for copying rests with the document event listener rather than the code calling JGoObject.update for efficiency when there is no undo/redo manager.
copyOldValueForUndo
in class JGoObject
e
- the UndoableEdit that also remembers the kind of change and any
appropriate previous state that should be copied in-placepublic void copyNewValueForRedo(JGoDocumentChangedEdit e)
JGoObject
Just as the previous/old value/state information is stored as one or both of an integer and an Object, the new value/state information may be stored as either or both of an integer or an Object.
The responsibility for copying rests with the document event listener rather than the code calling JGoObject.update for efficiency when there is no undo/redo manager.
copyNewValueForRedo
in class JGoNode
public void changeValue(JGoDocumentChangedEdit e, boolean undo)
JGoObject
You will want to override this method to handle changing the additional state of your object subclasses.
changeValue
in class JGoNode
public void SVGUpdateReference(java.lang.String attr, java.lang.Object referencedObject)
JGoObject
This is called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() after all the objects have been created and if DomDoc.registerReferencingObject() has been previously called by SVGReadObject().
Typically, an implementation of this method will first call the superclass and then fill in the appropriate object reference based on the attr argument.
Refer to com.nwoods.jgo.examples.SimpleNode.SVGWriteObject() for an example using this method.
SVGUpdateReference
in class JGoNode
public void SVGWriteObject(DomDoc svgDoc, DomElement jGoElementGroup)
JGoXMLSaveRestore
This method will be called by com.nwoods.jgo.svg.DefaultDocument.SVGWriteDoc() for every JGoObject contained within a JGoDocument. The following example uses a JGoRectangle to illustrate the format of a generated SVG JGoObject:
<g>
<JGoClass class="com.nwoods.jgo.JGoRectangle"\>
<rect height="75" style="stroke:black;stroke-width:1;fill:rgb(255,0,0);" width="75" x="65" y="71"/>
<JGoClass class="com.nwoods.jgo.JGoDrawable" drawablebrush="jgoid1" drawablepen="jgoid2" embeddedpenbrush="false"/>
<JGoClass class="com.nwoods.jgo.JGoObject" obj_flags="1054"/>
</g>
Note that the entire JGoObject is enclosed in a group (<g>). Each subclass of the JGoObject is described by a <JGoClass> element, starting with the most specific class and moving to the more general. Each <JGoClass> element has a "class" attribute which defines the class name. Each <JGoClass> element may also have several other attributes which uniquely describe that state of that class. Following the <JGoClass> element, each class may also genereate any other elements that are required, including representations of contained objects and standard SVG elements such as the <rect> element shown in the above example. The generation of SVG elements in the output makes it possible for the output to be read by SVG viewers and other SVG aware applications. The information contained in the <JGoClass> elements allows us to accurately save and restore all the information in a particular JGoObject subclass.
If this class contains a reference to another object, call DomDoc.registerReferencingNode() to register that reference. This will cause the element representing the referenced object to be identified with a unique id attribute, and cause the element representing the referring object to have a user defined attribute containing a reference to that id. See DomDoc.registerReferencingNode() for more information.
Typically, an implementation of this method will generate a <JGoClass> element using the DomDoc.createJGoClassElement() method, adding whatever attributes are necessary to describe the class. It will then call its superclass so that the superclass can add its own <JGoClass> element and other information to jGoElementGroup within the DomDoc.
Refer to com.nwoods.jgo.examples.flower.ActivityNode.SVGWriteObject() and com.nwoods.jgo.examples.SimpleNode.SVGWriteObject() for examples using this method.
Refer to the file com.nwoods.jgo.svg\xsvg.dtd for a formal description of JGo extensions to the SVG document type.
SVGWriteObject
in interface JGoXMLSaveRestore
SVGWriteObject
in class JGoSubGraphBase
public DomNode SVGReadObject(DomDoc svgDoc, JGoDocument jGoDoc, DomElement svgElement, DomElement jGoChildElement)
JGoXMLSaveRestore
This method will be called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() for every <JGoClass> element encountered in a DomDoc. First, an object of the type specified by the class attribute will be created and then the SVGReadObject() method will be called on that newly created object. Refer to SVGWriteObject() for a description of the expected format of the SVG document.
This method may also be called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() when reading any SVG document, including those not generated by JGo and therefore not containing any <JGoClass> elements. In such cases, the DefaultDocument.SVGReadElement() method may be subclassed to examine the SVG element and cause the appropriate JGoObject to be created to represent that element and call SVGReadObject() on that newly created object. By default, standard JGoObjects such as JGoRectangles, JGoStrokes, etc will be created to represent these objects.
If this class contains a reference to another object, call DomDoc.registerReferencingObject() to register that reference. This will cause the JGoObject.SVGUpdateReference() to be called on the referencing object after all the objects have been created, passing in the object befing referenced. See DomDoc.registerReferencingObject() for more information.
Typically, an implementation of this method starts by verifying that the element being read is a <JGoClass> element (which will be true if jGoChildElement is not null). This will always be true unless you have subclassed the DefaultDocument.SVGReadElement() method as described above. It will then read the expected attributes of the <JGoClass> element (as written by SVGReadObject()), call SVGReadObject() on its superclass, and finally return the next element by calling svgElement.getNextSibling().
Refer to com.nwoods.jgo.examples.flower.ActivityNode.SVGReadObject() and com.nwoods.jgo.examples.SimpleNode.SVGReadObject() for examples using this method.
SVGReadObject
in interface JGoXMLSaveRestore
SVGReadObject
in class JGoSubGraphBase
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |