DroidDiagram Programmer's Guide
Diagram Class
Remarks See Also
 






The Diagram class represents a flow diagram.

Namespace: com.mindfusion.diagramming
Package: com.mindfusion.diagramming

 Syntax

Java  Copy Code

public class Diagram extends DiagramBase implements IItemFactory, ImageObserver

 Remarks

The diagram document contains connected nodes and links. Nodes are instances of the ShapeNode, TableNode, or ContainerNode classes. The nodes can be accessed through getNodes. Links in DroidDiagram are instances of the DiagramLink class and can be accessed through the getLinks method. Diagram items can be grouped in hierarchical structures and the so formed groups can be accessed by getGroups.

Managing items: Use the createShapeNode, createTableNode, createDiagramLink or createContainerNode methods of the Factory class to create new diagram items. Optionally, items can be created using the new operator and added to the diagram with the add method. Items are deleted using the remove method of the list returned by the getItems method.

The createGroup method creates a new hierarchical Group of items. The subordinated items in a group always follow the movement of their master item. Use the destroyGroup method to destroy a group.

Searching for a particular kind of items is done with the findLink, findNode and findGroup methods, which look for an item that has a particular Tag. To get whatever object is placed at a certain location, use the getItemAt, getNodeAt and getLinkAt methods.

Serialization: Binary serialization of diagrams is provided by the saveTo and loadFrom methods which serialize diagrams to / from Java streams or files. Use the saveToXml and loadFromXml methods to serialize a diagram into/from XML documents.

Controlling users actions: Users actions can be validated by handling some events declared in DiagramListener, fired while items are being created or modified. In addition, the Diagram class provides some methods that control user interaction. The setBehavior method specifies how user interaction is interpreted by creating nodes, links, selection, and so on. The order in which items are hit-tested when clicking on them depends on the value assigned through setHitTestPriority.

The following attribute setters let you control what kind of links users can create: setAllowLinksRepeat, setAllowSelfLoops, setAllowUnanchoredLinks, setAllowUnconnectedLinks. To specify whether users are allowed to edit the text of nodes by double-clicking, use setAllowInplaceEdit.

 Inheritance Hierarchy

java.lang.Object
    com.mindfusion.diagramming.DiagramBase
        com.mindfusion.diagramming.Diagram
            com.mindfusion.diagramming.DiagramPage

 See Also

Diagram Members
com.mindfusion.diagramming Namespace