Search
Items Placement

Measure Unit

The setMeasureUnit method lets you specify the unit of measure for all location and size -related values assigned to JDiagram object attributes by passing as arguments to their methods.

Location and Size of Nodes

Use the setBounds or getBounds methods to change or get the location and size of a node. To move a node without changing its size, call the move method. To change only the size of a node, invoke the resize method. The ShapeNode's resizeToFitImage and TableNode's resizeToFitImage methods set nodes' sizes to fit that of their pictures.

Links Control Points

Links have two or more control points, depending on their style and segment count. You can get access to the control points by using the DiagramLink.getControlPoints method. You must call updateFromPoints after moving control points of a link in order to repaint the link and update its internal state variables. The smallest rectangle that bounds all link points can be obtained by calling the DiagramLink.getBounds method.

Link Dynamics

Use the Dynamic property of a link to enable it to automatically recalculate its end point positions if the nodes connected to the link are moved or resized; the end points are moved in such a way that the link points to the centers of the linked nodes. A related property is AutoSnapToNode, which can be enabled to make the link end points align to the border of their origin or destination nodes while a user move the link ends.

The setRetainForm and getRetainForm methods are useful for links that have more than two control points. If the nodes connected by a link are moved around, usually only the segments at the ends of that link are updated, so that they stay linked to their respective nodes. In that case all intermediate control points stay where they are. However, if setRetainForm is enabled, all control points will move simultaneously in a way they preserve their relative position to each other, and thus preserving the overall form of the link.

To enable or disable automatic routing of a link, use the setAutoRoute and getAutoRoute methods. Routed links avoid nodes by finding the shortest path between their origin and destination that does not cross any other nodes. The link routing algorithm can be tuned through the attributes accessed by getRoutingOptions. The getRouteLinks method gets whether newly created links will automatically find their way between nodes. To set links to find their route automatically, call setRouteLinks.

Interactive Moving or Resizing

End-users of your application can move around or resize diagram objects. They do this by selecting an item and dragging any of its adjustment handles, a point inside its interior, any of it sides or a selection frame. The way diagram nodes can be interacted with can be controlled by using the setHandlesStyle and getHandlesStyle methods. The handle style also defines the visual representation of selected items on screen. setEnabledHandles and getEnabledHandles allow disabling specific manipulations to perform on a node, for example resizing the item horizontally or moving it. If a node is modified interactively, the nodeModified event is fired. When the user moves any control point of a link, the linkModified event is raised.

Controlling the Z-order

The Z-order defines how items are ordered on the Z-axis so that one looks above or below another. Members of the DiagramItem class give you full control over the Z-order. To move an item one level up or down, invoke the zLevelUp or zLevelDown methods. To move an item to the bottom of the Z-order, call its zBottom method. To move the item in front of all others, call its zTop method. You can use the setZIndex or getZIndex method to get or set the index of an item in the Z-order array.