|
||||||||||
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.JGoTextNode
A JGoTextNode is an Area containing a Text, a 3DRect, and four ports. The four ports are at the middle of each side, and they are normally hidden. If the text is changed, the JGoTextNode automatically changes size to "hold" the text. The text is not editable by default, but can be made so.
Field Summary | |
static int |
ChangedAutoResize
A JGoDocumentEvent.CHANGED subhint: modified the margin insets |
static int |
ChangedBackground
A JGoDocumentEvent.CHANGED subhint: replaced the Background |
static int |
ChangedBottomPort
A JGoDocumentEvent.CHANGED subhint: replaced the BottomPort |
static int |
ChangedInsets
A JGoDocumentEvent.CHANGED subhint: modified the margin insets |
static int |
ChangedLabel
A JGoDocumentEvent.CHANGED subhint: replaced the Label |
static int |
ChangedLeftPort
A JGoDocumentEvent.CHANGED subhint: replaced the LeftPort |
static int |
ChangedRightPort
A JGoDocumentEvent.CHANGED subhint: replaced the RightPort |
static int |
ChangedTopPort
A JGoDocumentEvent.CHANGED subhint: replaced the TopPort |
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 | |
JGoTextNode()
Create a JGoTextNode with no parts. |
|
JGoTextNode(java.lang.String s)
Create a JGoTextNode with a 3DRect background, four ports, and a label displaying the string S. |
Method Summary | |
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. |
protected void |
copyChildren(JGoArea newarea,
JGoCopyEnvironment env)
The default implementation for copying child objects is to just add a copy of each child to the new area. |
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 |
createBackground()
Create and initialize the background object. |
JGoText |
createLabel(java.lang.String s)
Create and initialize a text label displaying the given string. |
JGoPort |
createPort(int spot)
Create and initialize the node's port, which is normally small and not visible. |
JGoObject |
getBackground()
Return the JGoObject that serves as the background for this node. |
JGoPort |
getBottomPort()
Return the JGoPort object at the bottom of this node. |
JGoBrush |
getBrush()
Return the JGoBrush used by the Background, if it is a JGoDrawable. |
Insets |
getInsets()
Return the desired margins around the Label, used by layoutChildren to size the Background. |
JGoText |
getLabel()
Return the JGoText object that displays the text string. |
JGoPort |
getLeftPort()
Return the JGoPort object at the left side of this node. |
JGoPen |
getPen()
Return the JGoPen used by the Background, if it is a JGoDrawable. |
JGoPort |
getRightPort()
Return the JGoPort object at the right side of this node. |
java.lang.String |
getText()
Return the text string associated with this object. |
JGoPort |
getTopPort()
Return the JGoPort object at the top of this node. |
boolean |
isAutoResize()
Return whether text's bounding rectangle is recomputed whenever the text string or any of the other visual attributes is changed. |
void |
layoutChildren(JGoObject childchanged)
Position all the parts of the area relative to the text label. |
void |
onAutoResizeChanged(boolean old)
When the AutoResize property changes, make sure the label's Multiline, Wrapping and Clipping properties are true when isAutoResize() is false, and vice-versa. |
JGoObject |
removeObjectAtPos(JGoListPosition pos)
When an object is removed, make sure there are no more references from fields. |
void |
setAutoResize(boolean bFlag)
Control whether the bounding rectangle is changed whenever the text string or other visual attributes are changed. |
void |
setBackground(JGoObject back)
Change the background object for this node. |
void |
setBottomPort(JGoPort p)
Change the port at the bottom of this node. |
void |
setBrush(JGoBrush b)
If the Background is a JGoDrawable, change its JGoBrush. |
void |
setInsets(Insets x)
Change the margins used around the text. |
void |
setLabel(JGoText lab)
Change the label for this node. |
void |
setLeftPort(JGoPort p)
Change the port at the left side of this node. |
void |
setPen(JGoPen p)
If the Background is a JGoDrawable, change its JGoPen. |
void |
setRightPort(JGoPort p)
Change the port at the right side of this node. |
void |
setText(java.lang.String s)
Change the Label's text string. |
void |
setTopPort(JGoPort p)
Change the port at the top of this node. |
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. |
Methods inherited from class com.nwoods.jgo.JGoNode |
copyObject, findAll, getPartID, getToolTipText, getUserObject, setPartID, setToolTipText, setUserObject |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ChangedLabel
public static final int ChangedBackground
public static final int ChangedTopPort
public static final int ChangedRightPort
public static final int ChangedBottomPort
public static final int ChangedLeftPort
public static final int ChangedInsets
public static final int ChangedAutoResize
Constructor Detail |
public JGoTextNode()
You will need to initialize this object manually, by setting the Background, Label, and any Ports, with the results of createBackground, createLabel, and createPort.
public JGoTextNode(java.lang.String s)
Method Detail |
public JGoObject createBackground()
By default this creates and returns a JGo3DRect that is not Selectable.
public JGoText createLabel(java.lang.String s)
By default the JGoText object is not Selectable or Editable, but is Multiline.
s
- the initial text string to display; this must not be nullpublic JGoPort createPort(int spot)
The port has a FromSpot and ToSpot specified by the spot argument.
spot
- the spot at which the port will be placed:
one of TopCenter, CenterRight, BottomCenter, CenterLeftprotected void copyChildren(JGoArea newarea, JGoCopyEnvironment env)
JGoArea
You may wish to override this in order to keep track of the children
or do other bookkeeping. Remember that JGoObject.copyObject will
return null if the object has already been copied. We suggest
using JGoCopyEnvironment.copy instead:
newobj.myObjRef = env.copy(myObjRef);
Or call super.copyChildren first and just refer to the copied objects
that are remembered in the copy environment:
newobj.myObjRef = (JGoObject)env.get(myObjRef);
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 JGoObject removeObjectAtPos(JGoListPosition pos)
removeObjectAtPos
in interface JGoObjectCollection
removeObjectAtPos
in class JGoArea
public void layoutChildren(JGoObject childchanged)
layoutChildren
in class JGoArea
childchanged
- 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)
public JGoText getLabel()
getLabel
in interface JGoLabeledPart
getLabel
in class JGoNode
public void setLabel(JGoText lab)
You might want to override the createLabel method if you want to create a different kind of JGoText when constructing this kind of node.
setLabel
in class JGoNode
public JGoObject getBackground()
public void setBackground(JGoObject back)
You might want to override the createBackground method if you want to create a different kind of JGoObject when constructing this kind of node.
public JGoPort getTopPort()
public void setTopPort(JGoPort p)
You might want to override the createPort method if you want to create a different kind of JGoPort when constructing this kind of node.
public JGoPort getRightPort()
public void setRightPort(JGoPort p)
You might want to override the createPort method if you want to create a different kind of JGoPort when constructing this kind of node.
public JGoPort getBottomPort()
public void setBottomPort(JGoPort p)
You might want to override the createPort method if you want to create a different kind of JGoPort when constructing this kind of node.
public JGoPort getLeftPort()
public void setLeftPort(JGoPort p)
You might want to override the createPort method if you want to create a different kind of JGoPort when constructing this kind of node.
public Insets getInsets()
The default values are top: 3, left: 3, bottom: 2, right: 2.
public void setInsets(Insets x)
public void setAutoResize(boolean bFlag)
bFlag
- true if this should resize itself when the text changespublic boolean isAutoResize()
By default, this is true.
public void onAutoResizeChanged(boolean old)
old
- the old value of isAutoResize(), before it was changedpublic JGoPen getPen()
public void setPen(JGoPen p)
public JGoBrush getBrush()
public void setBrush(JGoBrush b)
public java.lang.String getText()
JGoLabeledPart
This property is normally implemented to return the Label's Text string. This would return null if there is no Label. You may wish to implement this differently if there is no Label but there is a string naturally associated with the object, or if the desired string might be different than the label's text string.
getText
in interface JGoLabeledPart
getText
in class JGoNode
public void setText(java.lang.String s)
JGoNode
This does nothing if getLabel() returns null.
setText
in class JGoNode
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 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 JGoNode
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 JGoNode
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |