|
||||||||||
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.JGoDrawable
com.nwoods.jgo.JGoStroke
com.nwoods.jgo.JGoLink
JGoLink is a JGoStroke that connects two different JGoPorts.
If the position of one or both of its JGoPorts changes, the JGoLink redraws itself to connect the new positions.
The default link stroke will consist of three segments. The end segments, at the ports, will be relatively short and either horizontal or vertical. The middle segment will be just a straight line connecting the two short segments at the ports. There is no short end segment if the corresponding port does not have a link port spot (i.e., the value is NoSpot).
By turning on the Orthogonal property, a link will have segments that are all either horizontal or vertical. To handle what would normally be "Z" shaped links, there are five segments (i.e. six stroke points).
A selected link will not have selection handles at the very end points, unless there are only one or two segments in the stroke. Resizing a link causes a new link to be started, keeping one of the ports for the new link.
You can define your own style of link by overriding calculateStroke() or by overriding paint().
"Resizing" the first or last pick points continues to have the old behavior of disconnecting the link and starting to create a new one. Furthermore, if the link isOrthogonal, and the resize handle is one of the two middle ones, then it also moves the other middle stroke point to maintain orthogonality of that middle segment.
The resize behavior for the user's "relinking" an existing link to a different port sets the link's corresponding port to null and calls the JGoView.startReLink method. The static boolean property DefaultResizingRelinks has been added to control whether resizing links should use the new modify-the-existing-link behavior or the delete-and-create-anew behavior. The default value is true, to use the view's ReLink methods. The value of false would use the view's NewLink methods.
A Relinkable link (by default true) allows the user to interactively reconnect one end of the link to another valid port (or to the original port; or to nothing, thereby deleting the link).
A link that AvoidsNodes has a smarter implementation of calculateStroke() that routes the path of the link so as to try not to cross any avoidable objects. Of course, if either end of the link is inside an object, or if there is no non-area-crossing path that be found, the path of the link may default to the standard calculateStroke behavior. You can customize the objects to be avoided by overriding JGoDocument.isAvoidable and JGoDocument.getAvoidableRectangle -- by default JGoDocument.isAvoidable is true for instances of JGoArea, and the size and position of the object to be avoided is just the bounding rectangle of the area. This property, by default false, only applies when isOrthogonal() is true and isCubic() is false. Setting this property to true will incur some additional overhead to search for the shortest, straightest path between the ports. You may wish to set JGoView.setDragsRealtime(false) in order to improve responsiveness while dragging.
A link that JumpsOver is drawn with small half-ellipses where the path of the segment crosses over another link whose isJumpsOver() property is true. Both the link that crosses over and the link that is crossed over must have the Orthogonal property true, the Cubic property false, and the JumpsOver property true. The crossed over link must be "behind" the crossing link. This property is false by default. Setting this property to true will incur some additional overhead to detect segment intersections. You may wish to set JGoView.setDragsRealtime(false) in order to improve responsiveness while dragging. This property may also be ignored when the view's scale is small.
Orthogonal links can also be drawn with rounded corners--turn on the RoundedCorners property. The size of the corner is specified by the Curviness property, but is limited by the lengths of the segments meeting at a corner.
The Curviness property not only controls rounded corners for Orthogonal links, but the default curve for Cubic (Bezier) strokes. Positive values cause the Bezier stroke to curve clockwise; negative values curve counter-clockwise; and a value of zero produces a straight line.
Field Summary | |
static int |
AdjustingStyleCalculate
Clear all of the existing points and add points for the standard kinds of strokes. |
static int |
AdjustingStyleEnd
When there are more than the standard number of points in the stroke, or if the stroke is orthogonal, just modify the end points, while leaving the intermediate points unchanged. |
static int |
AdjustingStyleScale
When there are more than the standard number of points in the stroke, scale and rotate the intermediate points so that the link's shape stays approximately the same. |
static int |
AdjustingStyleStretch
When there are more than the standard number of points in the stroke, linearly interpolate the intermediate points along the X and Y dimensions between the ports. |
static int |
ChangedAdjustingStyle
a CHANGED JGoDocumentEvent or JGoViewEvent hint: how calculateStroke determines the path of the link |
static int |
ChangedAvoidsNodes
a CHANGED JGoDocumentEvent or JGoViewEvent hint: the link "jumps over" other Orthogonal links |
static int |
ChangedCurviness
a CHANGED JGoDocumentEvent or JGoViewEvent hint: how curvy a Cubic link is when the path is automatically calculated |
static int |
ChangedFromPort
a CHANGED JGoDocumentEvent or JGoViewEvent hint: the "from" port has changed |
static int |
ChangedJumpsOver
a CHANGED JGoDocumentEvent or JGoViewEvent hint: the link "jumps over" other Orthogonal links |
static int |
ChangedOrthogonal
a CHANGED JGoDocumentEvent or JGoViewEvent hint: the link routing style has changed |
static int |
ChangedPartID
a CHANGED JGoDocumentEvent or JGoViewEvent hint: |
static int |
ChangedRelinkable
a CHANGED JGoDocumentEvent or JGoViewEvent hint: whether the user can reconnect this link has changed |
static int |
ChangedRoundedCorners
a CHANGED JGoDocumentEvent or JGoViewEvent hint: |
static int |
ChangedToPort
a CHANGED JGoDocumentEvent or JGoViewEvent hint: the "to" port has changed |
static int |
ChangedUserObject
a CHANGED JGoDocumentEvent or JGoViewEvent hint: |
static int |
RelinkableFromHandle
a handle ID: the user can relink from the "from" port |
static int |
RelinkableToHandle
a handle ID: the user can relink from the "to" port |
Fields inherited from class com.nwoods.jgo.JGoStroke |
ChangedAddPoint, ChangedAllPoints, ChangedArrowHeads, ChangedArrowLength, ChangedArrowShaftLength, ChangedArrowWidth, ChangedCubic, ChangedHighlight, ChangedModifiedPoint, ChangedRemovePoint, myPoints |
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 | |
JGoLink()
Create an unconnected link. |
|
JGoLink(JGoPort from,
JGoPort to)
Create a link from one port to another. |
Method Summary | |
protected void |
addOrthoPoints(int startFromX,
int startFromY,
double fromDir,
int endToX,
int endToY,
double toDir)
If the link should be routed orthogonally, this method is called in order to add stroke points between the end segments. |
protected boolean |
adjustPoints(int startIndex,
int nFx,
int nFy,
int endIndex,
int nTx,
int nTy)
Adjust all of the existing points in this link's stroke in an inclusive range according to new first and last stroke points. |
void |
calculateStroke()
Given the information (start and end port) of this link we need to calculate the JGoStroke that goes between them. |
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 |
copyNewValueForRedo(JGoDocumentChangedEdit e)
This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed. |
JGoObject |
copyObject(JGoCopyEnvironment env)
Create a copy of the JGoLink, but do not copy or share the links ports. |
void |
copyObjectDelayed(JGoCopyEnvironment env,
JGoObject newobj)
This is called in the second pass of copying objects, so that each JGoLink can find and hook up to the appropriate new copies of ports. |
protected void |
gainedSelection(JGoSelection selection)
Called whenever this link is added to a selection in some view. |
int |
getAdjustingStyle()
Return the current behavior for the calculateStroke method. |
int |
getCurviness()
Returns the offset from a straight line used to position the control points of a cubic (Bezier) link between two ports that have NoSpot. |
int |
getFirstPickPoint()
Return the start point to display a handle on. |
JGoPort |
getFromPort()
Returns the source port of this link. |
int |
getLastPickPoint()
Return the end point to display a handle on. |
protected int |
getMidOrthoPosition(int from,
int to,
boolean vertical)
Return the horizontal or vertical position for the middle segment of the orthogonally routed link. |
JGoPort |
getOtherPort(JGoPort p)
Sometimes when you get a link connected to a port, you don't know which end was connected to the port. |
int |
getPartID()
Return the integer PartID for this JGoObject that is in a JGoDocument. |
JGoPort |
getToPort()
Returns the destination port of this link. |
java.lang.Object |
getUserObject()
Gets an Object value that is not used by JGo. |
org.eclipse.swt.graphics.Rectangle |
handleResize(Graphics2D g,
JGoView view,
org.eclipse.swt.graphics.Rectangle prevRect,
org.eclipse.swt.graphics.Point newPoint,
int whichHandle,
int event,
int minWidth,
int minHeight)
Called when a link point is moved. |
boolean |
isAvoidsNodes()
Return whether this orthogonal link's path should try to avoid any JGoAreas. |
boolean |
isCubic()
Links are automatically Cubic if isSelfLoop() is true and isOrthogonal() is false |
static boolean |
isDefaultResizingRelinks()
Return whether reconnecting an existing link by dragging its end resize handles just modifies the link or deletes it and starts creating a new link. |
boolean |
isJumpsOver()
Return whether this link changes its path to "jump over" any Orthogonal, non-Cubic links that it crosses. |
boolean |
isOrthogonal()
This predicate is true if the link should be routed vertically and horizontally. |
boolean |
isRelinkable()
Return whether the user can interactively reconnect one end of this link to another valid port. |
boolean |
isRoundedCorners()
Return whether this link, when Orthogonal, draws its path with round corners. |
boolean |
isSelfLoop()
Returns true when both ports are the same and non-null. |
protected boolean |
modifyEndPoints(int startIndex,
int nFx,
int nFy,
int endIndex,
int nTx,
int nTy)
Modify only the end points of this stroke to match the new From and To points; intermediate points are not changed. |
protected void |
ownerChange(JGoObjectCollection oldOwner,
JGoObjectCollection newOwner,
JGoObject mainObject)
When a link is "deleted", we need to unlink from the ports. |
void |
paint(Graphics2D g,
JGoView view)
Draw the stroke on the graphics context. |
void |
portChange(JGoPort port,
int hint,
int prevInt,
java.lang.Object prevVal)
Called when a port is changed (or moved or resized, etc.) |
protected boolean |
rescalePoints(int startIndex,
int nFx,
int nFy,
int endIndex,
int nTx,
int nTy)
Maintain the same shape for the stroke, but scale and rotate according to the new points (nFx,nFy) and (nTx,nTy). |
void |
setAdjustingStyle(int adj)
Specify how calculateStroke modifies the stroke path of a link. |
void |
setAvoidsNodes(boolean bFlag)
Change whether this link's path, when Orthogonal, tries to avoid any JGoAreas. |
void |
setCurviness(int c)
Change how curvy a cubic link will be between two ports with NoSpot, or how rounded the corners of an orthogonal link will be (if isRoundedCorners() is true). |
static void |
setDefaultResizingRelinks(boolean reuse)
Change whether the user's dragging the end selection handle points of a link will cause the link to be removed from the document and an entirely new link created by the view, or whether the link will be retained in the document and only its port is modified. |
void |
setFromPort(JGoPort from)
Sets the source port of this link. |
void |
setJumpsOver(boolean bFlag)
Change whether this link, when Orthogonal, "jumps over" other orthogonal links to avoid the appearance of a junction. |
void |
setOrthogonal(boolean bOrtho)
Change whether the link will be routed vertically and horizontally. |
void |
setPartID(int id)
Change the PartID for a JGoObject; this is normally only called by JGoDocument code when this object is added to a document layer. |
void |
setRelinkable(boolean bFlag)
Change whether this link can be reconnected interactively by the user. |
void |
setRoundedCorners(boolean bFlag)
Change whether this link, when Orthogonal, has rounded corners. |
void |
setToPort(JGoPort to)
Sets the destination port of this link. |
void |
setUserObject(java.lang.Object obj)
Sets an Object value that is not used by JGo. |
protected boolean |
stretchPoints(int startIndex,
int nFx,
int nFy,
int endIndex,
int nTx,
int nTy)
Stretch the points of this stroke by interpolating the points from startIndex to endIndex between the new points (nFx,nFy) and (nTx,nTy). |
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 |
unlink()
Called when we want to remove this link. |
Methods inherited from class com.nwoods.jgo.JGoDrawable |
draw3DRect, draw3DRect, drawEllipse, drawEllipse, drawEllipse, drawLine, drawLine, drawPath, drawPolygon, drawPolygon, drawRect, drawRect, drawRect, drawRoundRect, drawRoundRect, getBrush, getPen, setBrush, setPen, SVGAddPathArgs, SVGReadAttributes, SVGWriteAttributes |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int AdjustingStyleCalculate
A JGoLink has a number of standard appearances, as determined by calculateStroke():
public static final int AdjustingStyleScale
This style, implemented by the rescalePoints method, does not maintain the horizontal and vertical line segments of an orthogonal link. Orthogonal links with this adjusting style will instead recalculate the standard stroke path, as if the adjusting style were AdjustingStyleCalculate.
public static final int AdjustingStyleStretch
This style, implemented by the stretchPoints method, does not maintain the horizontal and vertical line segments of an orthogonal link. Orthogonal links with this adjusting style will instead only modify the end points of the existing path, as if the adjusting style were AdjustingStyleEnd.
public static final int AdjustingStyleEnd
This style maintains orthogonality for orthogonal links.
public static final int RelinkableFromHandle
public static final int RelinkableToHandle
public static final int ChangedFromPort
public static final int ChangedToPort
public static final int ChangedOrthogonal
public static final int ChangedRelinkable
public static final int ChangedJumpsOver
public static final int ChangedAvoidsNodes
public static final int ChangedCurviness
public static final int ChangedAdjustingStyle
public static final int ChangedUserObject
public static final int ChangedPartID
public static final int ChangedRoundedCorners
Constructor Detail |
public JGoLink()
public JGoLink(JGoPort from, JGoPort to)
Because links are automatically redrawn when either port moves, they are by default not Draggable. However, they are by default Selectable and Resizable and Relinkable, allowing users to reconnect an end of the link.
If both ports belong to documents, they must belong to the same document. Creating a link does not automatically add it to any document. You will need to add the link to the desired document layer before the link can appear in any view.
from
- the starting port.to
- the ending port.Method Detail |
public JGoObject copyObject(JGoCopyEnvironment env)
copyObject
in class JGoStroke
env
- the environment for the copy operation - keeps track of copied objects.public void copyObjectDelayed(JGoCopyEnvironment env, JGoObject newobj)
If both new ports corresponding to this link's existing ports cannot be found, this link is removed from the document.
copyObjectDelayed
in class JGoObject
env
- a JGoCopyEnvironment that remembers the mapping of original
objects to copied onesnewobj
- the newly copied instance of this objectpublic void unlink()
This removes the link from both ports, and then removes the link from the containing document or view.
protected void gainedSelection(JGoSelection selection)
The default behavior creates resize handles at each of the link's stroke points.
gainedSelection
in class JGoStroke
selection
- the selection to which this object was addedpublic org.eclipse.swt.graphics.Rectangle handleResize(Graphics2D g, JGoView view, org.eclipse.swt.graphics.Rectangle prevRect, org.eclipse.swt.graphics.Point newPoint, int whichHandle, int event, int minWidth, int minHeight)
By default resizing a link (i.e., dragging a resize handle on a link), if the handle is either the first or last one, disconnects the selected link at one end and starts connecting that end to a possibly different port. If the handle being dragged is one not at either end, then the default behavior is to just move the stroke's point. However, if isOrthogonal() is true, the default behavior is to constrain such movement in a horizontal or vertical fashion, as seems appropriate based on the coordinates of the middle segment's points.
handleResize
in class JGoStroke
g
- the graphics context to draw onview
- the view we're being resizing inprevRect
- the previous bounding rectangle (unused)newPoint
- the location of the new pointwhichHandle
- the handle number of the point being movedevent
- the eventminWidth
- the minimum width of the object (unused)minHeight
- the minimim height of the object (unused)
protected void ownerChange(JGoObjectCollection oldOwner, JGoObjectCollection newOwner, JGoObject mainObject)
ownerChange
in class JGoObject
oldOwner
- the previous owner objectnewOwner
- the new owner objectmainObject
- the object being inserted or removed from the document or viewpublic void portChange(JGoPort port, int hint, int prevInt, java.lang.Object prevVal)
By default this will recalculate the points in the link's stroke, unless the change hint indicates a change in the port's Style or PortObject, or unless the port's link point appears not to have moved.
The parameters are the same as for a port's call to update, with the addition of a JGoPort argument that indicates which port had changed.
public int getFirstPickPoint()
getFirstPickPoint
in class JGoStroke
public int getLastPickPoint()
getLastPickPoint
in class JGoStroke
public JGoPort getFromPort()
public JGoPort getToPort()
public void setFromPort(JGoPort from)
from
- the source port of this link.public void setToPort(JGoPort to)
to
- the destination port of this link.public JGoPort getOtherPort(JGoPort p)
public boolean isCubic()
isCubic
in class JGoStroke
public boolean isSelfLoop()
public int getCurviness()
public void setCurviness(int c)
c
- a zero value will produce a straight line;
negative values cause the link to curve counterclockwisepublic void calculateStroke()
protected boolean adjustPoints(int startIndex, int nFx, int nFy, int endIndex, int nTx, int nTy)
This is primarily useful to help maintain intermediate inflection points in a link when one or both ports moves. By default this just calls rescalePoints, stretchPoints, or modifyEndPoints. This method is not called when there are no existing points to be adjusted or when getAdjustingStyle is AdjustingStyleCalculate. When this link is Orthogonal, an AdjustingStyle of AdjustingStyleScale will just return false to result in the standard orthogonal path. An AdjustingStyle of AdjustingStyleStretch for an orthogonal link is treated as if it were AdjustingStyleEnd.
startIndex
- the zero-based index of the first point to be changed, to be (nFx,nFy)nFx
- X document coordinate of the new From pointnFy
- Y document coordinate of the new From pointendIndex
- the zero-based index of the last point to be changed, to be (nTx,nTy)nTx
- X document coordinate of the new To pointnTy
- Y document coordinate of the new To point
protected boolean rescalePoints(int startIndex, int nFx, int nFy, int endIndex, int nTx, int nTy)
The startIndex point should be set to the new From point (nFx,nFy) and the endIndex point should be set to the new To point (nTx,nTy). All the intermediate points should be scaled and rotated accordingly to maintain the same shape as the original set of points from startIndex to endIndex, inclusive. The method adjustPoints calls this method when getAdjustingStyle returns AdjustingStyleScale. This method should not be used when Orthogonal is true.
startIndex
- the zero-based index of the first point to be changed, to be (nFx,nFy)nFx
- X document coordinate of the new From pointnFy
- Y document coordinate of the new From pointendIndex
- the zero-based index of the last point to be changed, to be (nTx,nTy)nTx
- X document coordinate of the new To pointnTy
- Y document coordinate of the new To point
protected boolean stretchPoints(int startIndex, int nFx, int nFy, int endIndex, int nTx, int nTy)
The startIndex point should be set to (nFx,nFy), the endIndex point should be set to (nTx,nTy), and all the intermediate points should be interpolated linearly to stretch or compress the original set of points from startIndex to endIndex, inclusive, along each of the X and Y dimensions. The method adjustPoints calls this method when getAdjustingStyle is AdjustingStyleStretch. This method should not be used when Orthogonal is true.
startIndex
- the zero-based index of the first point to be changed, to be (nFx,nFy)nFx
- X document coordinate of the new From pointnFy
- Y document coordinate of the new From pointendIndex
- the zero-based index of the last point to be changed, to be (nTx,nTy)nTx
- X document coordinate of the new To pointnTy
- Y document coordinate of the new To point
protected boolean modifyEndPoints(int startIndex, int nFx, int nFy, int endIndex, int nTx, int nTy)
The startIndex point should be set to (nFx,nFy), and the endIndex point should be set to (nTx,nTy), and the intermediate points should be not be changed unless needed to maintain orthogonality when Orthogonal is true.
startIndex
- the zero-based index of the first point to be changed, to be (nFx,nFy)nFx
- X document coordinate of the new From pointnFy
- Y document coordinate of the new From pointendIndex
- the zero-based index of the last point to be changed, to be (nTx,nTy)nTx
- X document coordinate of the new To pointnTy
- Y document coordinate of the new To point
protected void addOrthoPoints(int startFromX, int startFromY, double fromDir, int endToX, int endToY, double toDir)
The default implementation only adds points if both end segment directions are horizontal or vertical.
startFromX
- position of inner endpoint of first segmentstartFromY
- position of inner endpoint of first segmentfromDir
- the direction of the first segment coming out of the from portendToX
- position of inner endpoint of last segmentendToY
- position of inner endpoint of last segmenttoDir
- the direction of the last segment going into the to portprotected int getMidOrthoPosition(int from, int to, boolean vertical)
By default this is just the mid-point between the from and to positions. You may want to override this in order to move the middle segment to one side or the other, either to make room for other objects or to avoid overlapping the middle segments of links coming from other ports on the same node.
from
- position of the inner end of the first segmentto
- position of the inner end of the last segmentvertical
- Whether the mid-position is along the vertical axis or horizontalpublic boolean isOrthogonal()
public void setOrthogonal(boolean bOrtho)
With the default implementation setting this property to true is only effective if both ports have vertical or horizontal end segments (i.e. JGoPort.getFromLinkDir() and JGoPort.getToLinkDir() both returned a vertical or horizontal direction).
bOrtho
- true if the link should be drawn with vertical and
horizontal segmentspublic void setJumpsOver(boolean bFlag)
bFlag
- true if this link displays "jump over"spublic boolean isJumpsOver()
By default this is false.
public void setRoundedCorners(boolean bFlag)
bFlag
- true if this link's path is drawn with circular corners,
with a radius determined by getCurviness()public boolean isRoundedCorners()
By default this is false.
public void setAvoidsNodes(boolean bFlag)
bFlag
- true if this link is routed by calculateStroke() to avoid any JGoAreas.public boolean isAvoidsNodes()
By default this is false.
public void setAdjustingStyle(int adj)
adj
- one of AdjustingStyleCalculate, AdjustingStyleScale, AdjustingStyleStretch, AdjustingStyleEndpublic int getAdjustingStyle()
By default this is AdjustingStyleCalculate.
public void setRelinkable(boolean bFlag)
bFlag
- true if the user can reconnect this linkpublic boolean isRelinkable()
By default this is true.
public void paint(Graphics2D g, JGoView view)
JGoStroke
paint
in class JGoStroke
g
- the graphics context on which to draw.view
- the view we're drawing inpublic int getPartID()
JGoIdentifiablePart
getPartID
in interface JGoIdentifiablePart
public void setPartID(int id)
JGoIdentifiablePart
setPartID
in interface JGoIdentifiablePart
public java.lang.Object getUserObject()
public void setUserObject(java.lang.Object obj)
public 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 JGoStroke
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 JGoStroke
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 JGoStroke
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 JGoStroke
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 JGoStroke
public static void setDefaultResizingRelinks(boolean reuse)
reuse
- if true, user relinking keeps the existing link and
just sets one of the link's portspublic static boolean isDefaultResizingRelinks()
The initial value is true.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |