com.mindfusion.diagramming
Class TreeViewNode

java.lang.Object
  extended by com.mindfusion.diagramming.DiagramItem
      extended by com.mindfusion.diagramming.DiagramNode
          extended by com.mindfusion.diagramming.TreeViewNode
All Implemented Interfaces:
InplaceEditable, java.io.Externalizable, java.io.Serializable

public class TreeViewNode
extends DiagramNode
implements InplaceEditable

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.mindfusion.diagramming.DiagramNode
allowIncomingLinks, allowOutgoingLinks, anchorPattern, AV_Cancel, AV_EndModIncoming, AV_EndModOutgoing, AV_StartModIncoming, AV_StartModOutgoing, AV_UpdateIncoming, AV_UpdateOutgoing, AV_UpdIntscIncoming, AV_UpdIntscOutgoing, AV_UpdPosIncoming, AV_UpdPosOutgoing, bounds, enabledHandles, handlesStyle, incomingLinks, masterGroup, obstacle, outgoingLinks, savedBounds
 
Fields inherited from class com.mindfusion.diagramming.DiagramItem
brush, cycleDetected, cycleProtect, modifyDX, modifyDY, modifyHandle, modifying, pen, ptEnd, ptMdfLast, ptOrg, ptSavedEnd, ptSavedOrg, subordinateGroup
 
Constructor Summary
TreeViewNode()
          Initializes a new instance of the TreeViewNode class.
TreeViewNode(Diagram diagram)
          Initializes a new instance of the TreeViewNode class.
TreeViewNode(TreeViewNode prototype)
          Initializes a new instance of the TreeViewNode class using the specified node as a prototype.
 
Method Summary
 ConnectionPoint createConnectionPoint(DiagramLink link, java.awt.geom.Point2D pt, boolean incoming)
          DiagramNode.createConnectionPoint(DiagramLink, Point2D, boolean) override.
protected  DiagramItemProperties createProperties()
          Creates an item property set corresponding to the type of this diagram item.
protected  void drawLocal(java.awt.Graphics2D g, RenderOptions options)
          Draws the tree node on the specified Graphics2D surface.
protected  void getAllIncomingLinks(DiagramLinkList links)
          DiagramNode.getAllIncomingLinks(DiagramLinkList) override.
protected  void getAllOutgoingLinks(DiagramLinkList links)
          DiagramNode.getAllOutgoingLinks(DiagramLinkList); override.
 java.lang.String getCaption()
          Gets the text displayed as caption of the node.
 float getCaptionHeight()
          Gets the height of the node's caption area.
 java.awt.Image getCaptionImage()
          Gets the image that is displayed in the caption.
 int getConnectionStyle()
          Gets a value indicating whether drawing a link from/to this node should connect an item or the whole node as an integral entity.
 java.awt.geom.Rectangle2D getEditRect(java.awt.geom.Point2D mousePosition)
           
 boolean getEnableStyledText()
          Gets a value indicating whether styled text rendering is enabled.
 java.awt.Font getFont()
          Gets or the font used to render the node's caption.
 java.awt.geom.Rectangle2D.Float getItemRect(TreeViewItem treeItem)
          Gets the location and size of the specified TreeViewItem.
 java.awt.geom.Rectangle2D getRepaintRect(boolean includeConnected)
          DiagramNode.getRepaintRect(boolean) override.
 TreeItemList getRootItems()
          Gets a list of the root TreeViewItem objects displayed in this node.
 float getScrollPosition()
          Gets the current scroll position.
 int getShape()
          Gets the shape of this node.
 TextFormat getTextFormat()
           
 java.lang.String getTextToEdit()
           
 TreeViewItem itemFromPoint(java.awt.geom.Point2D point)
          Returns the item at the specified location.
protected  void loadFromXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
          Loads the item content from an XML element.
protected  void onChangeTextPadding()
           
protected  void onClick(int mouseButton, java.awt.geom.Point2D mousePosition)
          DiagramItem.onClick(int, Point2D) override.
protected  void onLoad(Diagram diagram)
          DiagramItem.onLoad(com.mindfusion.diagramming.Diagram) override.
protected  void onMeasureUnitChanged()
          Called when the Diagram's MeasureUnit changes.
protected  void onUpdateBounds()
          DiagramNode.onUpdateBounds(); override.
protected  void onZoomChanged()
          Called when the Diagram's ZoomFactor changes.
 void readExternal(java.io.ObjectInput in)
          Implements Externalizable.
 void removeItem(TreeViewItem item)
          Removes the specified item from the node.
 void renderText(java.lang.String text, java.awt.geom.Rectangle2D dest, com.mindfusion.diagramming.DrawTextHint hint)
           
 void resizeToFitText()
          Resizes the tree view so that it is large enough to fit the text of its items.
 void resizeToFitText(boolean ignoreCaption)
          Resizes the tree view so that it is large enough to fit the text of its items.
protected  void restoreProperties(DiagramItemProperties props)
          DiagramNode.restoreProperties(DiagramItemProperties) override.
protected  void saveProperties(DiagramItemProperties props)
          DiagramNode.saveProperties(DiagramItemProperties) override.
protected  void saveToXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
          Saves the item content into an XML element.
 void setCaption(java.lang.String caption)
          Sets the text displayed as caption of the node.
 void setCaptionHeight(float value)
          Gets the height of the node's caption area.
 void setCaptionImage(java.awt.Image image)
          Gets the image that is displayed in the caption.
 void setConnectionStyle(int value)
          Sets a value indicating whether drawing a link from/to this node should connect an item or the whole node as an integral entity.
 void setEditedText(java.lang.String newText)
           
 void setEnableStyledText(boolean value)
          Sets a value indicating whether styled text rendering is enabled.
 void setFont(java.awt.Font value)
          Sets or the font used to render the node's caption.
protected  void setReflexive(DiagramLink link)
          Invoked to let a node set the shape of a reflexive link connected to it.
 void setScrollPosition(float value)
          Sets the current scroll position.
 void setShape(int value)
          Sets the shape of this node.
 void setTextFormat(TextFormat value)
           
 void writeExternal(java.io.ObjectOutput out)
          Implements Externalizable.
 
Methods inherited from class com.mindfusion.diagramming.DiagramNode
allowCreate, allowModify, attachTo, attachTo, attachTo, cancelModify, completeCreate, completeModify, constraintsInfringed, containsPoint, containsPoint, createState, detach, draw, drawShadow, drawShadowLocal, getAllIncomingLinks, getAllLinks, getAllOutgoingLinks, getAllowIncomingLinks, getAllowOutgoingLinks, getAnchorPattern, getBounds, getCenter, getConstraints, getEffects, getEnabledHandles, getExpandable, getExpanded, getHandlesStyle, getIncomingLinks, getLocalBounds, getLocalBoundsD, getMasterGroup, getObstacle, getOutgoingLinks, getRotatedBounds, getRotationAngle, groupContains, move, moveTo, nodesIntersect, onDragOut, onDragOver, onDropOver, onRemove, onRotationAngleChanged, putExpandable, rectFromPoints, resize, resizeToFitImage, restoreState, saveState, setAllowIncomingLinks, setAllowOutgoingLinks, setAnchorPattern, setBounds, setBounds, setBoundsDirect, setConstraints, setEnabledHandles, setExpandable, setExpanded, setExpandedFlag, setHandlesStyle, setObstacle, setRotationAngle, shouldRenderAnchors, startCreate, startModify, updateCreate, updateLinkPositions, updateModify
 
Methods inherited from class com.mindfusion.diagramming.DiagramItem
clone, getBrush, getEffectiveBrush, getEffectiveFont, getEffectivePen, getEffectiveShadowBrush, getEffectiveTextBrush, getHyperLink, getId, getIgnoreLayout, getLayerIndex, getLayoutTraits, getLocked, getMeasureUnit, getParent, getPen, getPrintable, getRuntimeIndex, getSelected, getShadowBrush, getShadowOffsetX, getShadowOffsetY, getStyle, getSubordinateGroup, getTag, getTextBrush, getTextPadding, getToolTip, getValue, getVisible, getWeight, getZIndex, hasSubordinates, onAdd, onChangeFont, onChildModified, onDoubleClick, onModify, onStyleChanged, putSelected, query, repaint, repaint, repaint, setBrush, setDiagramDirty, setHyperLink, setId, setIgnoreLayout, setLayerIndex, setLocked, setPen, setPrintable, setSelected, setShadowBrush, setShadowOffsetX, setShadowOffsetY, setStyle, setTag, setTextBrush, setTextPadding, setToolTip, setVisible, setWeight, setZIndex, shouldRender, zBottom, zLevelDown, zLevelUp, zTop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeViewNode

public TreeViewNode()
Initializes a new instance of the TreeViewNode class.


TreeViewNode

public TreeViewNode(Diagram diagram)
Initializes a new instance of the TreeViewNode class.

This constructor initializes the TreeViewNode properties with the values specified in the respective default-value properties of the Diagram object.

Parameters:
diagram - The Diagram from which to obtain default values for the node properties.

TreeViewNode

public TreeViewNode(TreeViewNode prototype)
Initializes a new instance of the TreeViewNode class using the specified node as a prototype.

Method Detail

drawLocal

protected void drawLocal(java.awt.Graphics2D g,
                         RenderOptions options)
Draws the tree node on the specified Graphics2D surface.

Overrides:
drawLocal in class DiagramNode
Parameters:
g - An Graphics2D object where the link should be rendered.
options - A RenderOptions object specifying options for the drawing operation.

getEditRect

public java.awt.geom.Rectangle2D getEditRect(java.awt.geom.Point2D mousePosition)
Specified by:
getEditRect in interface InplaceEditable

getTextToEdit

public java.lang.String getTextToEdit()
Specified by:
getTextToEdit in interface InplaceEditable

setEditedText

public void setEditedText(java.lang.String newText)
Specified by:
setEditedText in interface InplaceEditable

itemFromPoint

public TreeViewItem itemFromPoint(java.awt.geom.Point2D point)
Returns the item at the specified location.

Parameters:
point - The point to check.
Returns:
The TreeViewItem instance that contains the specified point.

onClick

protected void onClick(int mouseButton,
                       java.awt.geom.Point2D mousePosition)
DiagramItem.onClick(int, Point2D) override.

Overrides:
onClick in class DiagramItem
Parameters:
mouseButton - Specifies the mouse button used to click the item.
mousePosition - Specifies the mouse position.

getItemRect

public java.awt.geom.Rectangle2D.Float getItemRect(TreeViewItem treeItem)
Gets the location and size of the specified TreeViewItem.

Parameters:
treeItem - A TreeViewItem instance.
Returns:
A RectangleF specifying the item's position and size.

getCaption

public java.lang.String getCaption()
Gets the text displayed as caption of the node.

Returns:
A string specifying the caption text.

getFont

public java.awt.Font getFont()
Gets or the font used to render the node's caption.

Overrides:
getFont in class DiagramItem
Returns:
A Font instance specifying the font attributes.

setFont

public void setFont(java.awt.Font value)
Sets or the font used to render the node's caption.

Overrides:
setFont in class DiagramItem
Parameters:
value - A Font instance specifying the font attributes.

setCaption

public void setCaption(java.lang.String caption)
Sets the text displayed as caption of the node.

Parameters:
caption - A string specifying the caption text.

getShape

public int getShape()
Gets the shape of this node.

Returns:
One of the SimpleShape constants.

setShape

public void setShape(int value)
Sets the shape of this node.

Parameters:
value - One of the SimpleShape constants.

getCaptionImage

public java.awt.Image getCaptionImage()
Gets the image that is displayed in the caption.

Returns:
An instance of the java.awt.Image class.

setCaptionImage

public void setCaptionImage(java.awt.Image image)
Gets the image that is displayed in the caption.

Parameters:
image - An instance of the java.awt.Image class.

getCaptionHeight

public float getCaptionHeight()
Gets the height of the node's caption area.

Returns:
A float value specifying the caption area height. The default value is 8.

setCaptionHeight

public void setCaptionHeight(float value)
Gets the height of the node's caption area.

Parameters:
value - A float value specifying the caption area height. The default value is 8.

setScrollPosition

public void setScrollPosition(float value)
Sets the current scroll position.

Parameters:
value - A float value specifying the scroll position.

getScrollPosition

public float getScrollPosition()
Gets the current scroll position.

Returns:
A float value specifying the scroll position.

getRootItems

public TreeItemList getRootItems()
Gets a list of the root TreeViewItem objects displayed in this node.


getConnectionStyle

public int getConnectionStyle()
Gets a value indicating whether drawing a link from/to this node should connect an item or the whole node as an integral entity.


setConnectionStyle

public void setConnectionStyle(int value)
Sets a value indicating whether drawing a link from/to this node should connect an item or the whole node as an integral entity.


onUpdateBounds

protected void onUpdateBounds()
DiagramNode.onUpdateBounds(); override.

Overrides:
onUpdateBounds in class DiagramNode

setReflexive

protected void setReflexive(DiagramLink link)
Invoked to let a node set the shape of a reflexive link connected to it.

Overrides:
setReflexive in class DiagramNode
Parameters:
link - Reference to the link.

getRepaintRect

public java.awt.geom.Rectangle2D getRepaintRect(boolean includeConnected)
DiagramNode.getRepaintRect(boolean) override.

Overrides:
getRepaintRect in class DiagramNode
Parameters:
includeConnected - true is related items should be considered too; otherwise, false.
Returns:
A rectangular region that should be repainted when this node is modified.

renderText

public void renderText(java.lang.String text,
                       java.awt.geom.Rectangle2D dest,
                       com.mindfusion.diagramming.DrawTextHint hint)

getTextFormat

public TextFormat getTextFormat()

setTextFormat

public void setTextFormat(TextFormat value)

getAllOutgoingLinks

protected void getAllOutgoingLinks(DiagramLinkList links)
DiagramNode.getAllOutgoingLinks(DiagramLinkList); override.

Parameters:
links - A DiagramLinkList the links should be added to.

getAllIncomingLinks

protected void getAllIncomingLinks(DiagramLinkList links)
DiagramNode.getAllIncomingLinks(DiagramLinkList) override.

Parameters:
links - A DiagramLinkList the links should be added to.

createConnectionPoint

public ConnectionPoint createConnectionPoint(DiagramLink link,
                                             java.awt.geom.Point2D pt,
                                             boolean incoming)
DiagramNode.createConnectionPoint(DiagramLink, Point2D, boolean) override.

Overrides:
createConnectionPoint in class DiagramNode
Parameters:
link - A DiagramLink that should be connected to this node.
pt - The point at which the link should be connected.
incoming - true if link is an incoming link; otherwise, false.
Returns:
A TreeViewConnectionPoint instance representing the connection.

onLoad

protected void onLoad(Diagram diagram)
DiagramItem.onLoad(com.mindfusion.diagramming.Diagram) override.

Overrides:
onLoad in class DiagramItem

loadFromXml

protected void loadFromXml(org.w3c.dom.Element xmlElement,
                           XmlPersistContext context)
                    throws javax.xml.transform.TransformerException,
                           XmlException
Loads the item content from an XML element.

Overrides:
loadFromXml in class DiagramNode
Parameters:
xmlElement - An XmlElement containing the item's data.
context - An XmlPersistContext object providing contextual information about the serialization process and some helper serialization methods.
Throws:
javax.xml.transform.TransformerException
XmlException

saveToXml

protected void saveToXml(org.w3c.dom.Element xmlElement,
                         XmlPersistContext context)
Saves the item content into an XML element.

Overrides:
saveToXml in class DiagramNode
Parameters:
xmlElement - An XmlElement the item's data should be stored into.
context - An XmlPersistContext object providing contextual information about the serialization process and some helper serialization methods.

onChangeTextPadding

protected void onChangeTextPadding()
Overrides:
onChangeTextPadding in class DiagramItem

getEnableStyledText

public boolean getEnableStyledText()
Gets a value indicating whether styled text rendering is enabled.

Returns:
true to parse the text of the node's caption and items in order to find formatting tags; otherwise false. Initialized with the value of Diagram.getEnableStyledText().

setEnableStyledText

public void setEnableStyledText(boolean value)
Sets a value indicating whether styled text rendering is enabled.

Parameters:
value - true to parse the text of the node's caption and items in order to find formatting tags; otherwise false.

onMeasureUnitChanged

protected void onMeasureUnitChanged()
Called when the Diagram's MeasureUnit changes.


onZoomChanged

protected void onZoomChanged()
Called when the Diagram's ZoomFactor changes.


restoreProperties

protected void restoreProperties(DiagramItemProperties props)
DiagramNode.restoreProperties(DiagramItemProperties) override.

Overrides:
restoreProperties in class DiagramNode
Parameters:
props - A DiagramItemProperties-derived object containing a snapshot of the item's properties.

saveProperties

protected void saveProperties(DiagramItemProperties props)
DiagramNode.saveProperties(DiagramItemProperties) override.

Overrides:
saveProperties in class DiagramNode
Parameters:
props - A DiagramItemProperties-derived object where the item's properties should be saved.

createProperties

protected DiagramItemProperties createProperties()
Creates an item property set corresponding to the type of this diagram item. This method is invoked by the undo/redo subsystem when creating a ChangeItemCmd instance.

Overrides:
createProperties in class DiagramNode
Returns:
A DiagramItemProperties-derived object containing a snapshot of the item's properties.

removeItem

public void removeItem(TreeViewItem item)
Removes the specified item from the node.

Parameters:
item - The TreeViewItem to remove.

resizeToFitText

public void resizeToFitText()
Resizes the tree view so that it is large enough to fit the text of its items.


resizeToFitText

public void resizeToFitText(boolean ignoreCaption)
Resizes the tree view so that it is large enough to fit the text of its items.

Parameters:
ignoreCaption -

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Implements Externalizable.

Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class DiagramNode
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Implements Externalizable.

Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class DiagramNode
Throws:
java.io.IOException
java.lang.ClassNotFoundException