Search
Standard Item Types

Diagram elements in JDiagram are represented by ShapeNode, TableNode, ContainerNode and DiagramLink instances. Combined and linked together, they can form complex data structures such as process or entity-relationship diagrams, class hierarchies, networks and graphs. Each of their rich features can be customized through numerous methods and properties. JDiagram also offers intuitive user interface for drawing and editing diagram items interactively.

Shape Nodes

Shape nodes can represent geometric shapes, flowchart elements, icons in network diagrams, and so on. They can hold both graphics and text in different fonts, sizes and colors. There are more than 100 predefined shapes and apart from them, JDiagram offers an easy way to define custom shapes. Shape nodes can be rotated, either interactively using the round selection handle drawn above them, or programmatically using the setRotationAngle method. The ShapeNode appearance can be customized further using several types of custom painting. The first type gives you full control over the painting. With the second one your painting code is performed additionally to the basic painting. The third one performs standard drawing of shape nodes and custom drawing of their shadows. Shape nodes can display background images and graphics. The file formats supported are GIF, JPEG and PNG.

SVG Nodes

The SvgNode class represents nodes that can display SVG drawings in addition to the rendering provided by its base ShapeNode class. SVG elements are rendered after the associated bitmap Image and just before the drawNode event is raised for Additional custom drawing. SVG elements are parsed and associated with the node through a com.mindfusion.svg.SvgContent object, which should be initialized and then assigned to the Content property.

Table Nodes

Table nodes can be used to represent table schemas in database diagrams or classes in class-hierarchies. A table contains cells arranged in a grid, and every cell can display text and/or image. Cells can span several rows and columns as set through the setRowSpan and setColumnSpan methods. Cells, columns and rows can be customized in various ways - there are appropriate methods available for setting their extents (setCaptionHeight, setRowHeight, setColumnWidth), frame style (setCellFrameStyle), image (setImageAlign, Cell.setImageAlign) and text format and alignment(Cell.setTextFormat, setCaptionFormat, setEnableStyledText). Tables' dimensions can be programmatically changed. Inserting (insertRow, insertColumn), appending (addRow, addColumn) or deleting rows and columns (deleteColumn, deleteRow) can be done in a very comprehensive, intuitive way whenever you might need it. Tables can also display background images and graphics. The file formats supported are GIF, JPEG and PNG.

Free-form Nodes

A FreeFormNode collects all points from users' mouse or touch input and displays them as node's outline. To let users draw free-form nodes interactively, set Behavior to DrawFreeForms. Use the Points property of FreeFormNode to get or set outline points programmatically. If the Closed property is set, the node is drawn as a closed shape and its interior filled, or otherwise the node is drawn as a poly-line. If the distance between first and last points drawn by user is shorter than AutoCloseDistance, the node gets closed automatically.

Control Hosts

A ControlNode can host any Java Swing control - instance of a java.awt.Component -derived class. The hosted control might be any of the standard component types such as JTable or JButton; custom controls are also supported. A ControlNode can be connected with links to any other nodes - control hosts, shapes or tables.

Container Nodes

A ContainerNode can contain other diagram nodes. When a container is moved, its child nodes move too. Containers can be folded to hide the contained nodes, and unfolded back to show them again. Nodes inside a container can be linked to nodes both inside and outside of it. When a container is folded, the links connected to contained nodes point to the container outlines. Containers can be nested within each other to unlimited depth.

TreeView Nodes

The TreeViewNode class represents nodes that can display hierarchical data. The root items displayed in the node can be accessed through the getRootItems method. New items can be added to and removed from the returned collection. The root items can have child items on their own and so on. For more information, refer to the TreeViewItem class.

Links

DiagramLinks represent various types of connections and relations in diagrams. JDiagram  offers three basic link types:

  • polyline links composed of straight-line segments (choose Polyline link style)
  • curved links composed of Bezier-spline segments
  • links composed of horizontal and vertical segments, alternating their orientation so that every segment is orthogonal to its neighbor

A link can be connected to a node at each of the link's ends. It is also possible to have unconnected links - having one or both of their ends not connected to nodes. Some customizable link's attributes are: arrowheads (setHeadShape, setHeadShapeSize, setHeadPen), shape (setShape, setCascadeOrientation), color (setTextBrush), text (setText, setTextStyle), pen width and style, modification behavior (setAllowMoveStart, setAutoRoute, setAllowMoveEnd, setDynamic) and number of segments (setSegmentCount).

See Also

Text Formatting
Custom Item Types