Associate Custom Data with Items
You can associate custom values from any data type with diagram elements by setting their
Tag and
Id properties. If the associated data is of a value type or of type that is serializable, then it is saved and loaded together with the diagram items when diagrams are saved or loaded. The
findNode,
findLink,
findNodeById and
findLinkById methods let you find diagram elements associated with a specific value.
Inspecting Items Geometry
- The intersects method of DiagramLink lets you test if links intersect other links or nodes.
- The getLength method of the DiagramLink class returns the total length of a link.
- The hitTest and containsPoint methods let you check if an item contains specified point.
Fluent API
Builder classes in com.mindfusion.diagramming.builders package add support for fluent programming style. Static with and instance init methods in DiagramItem, DiagramItemStyle and Layout -derived classes return a builder instance that can be used to set-up respective new or existing objects:
Java
Copy Code
|
---|
diagram.getNodes().add( ShapeNode.with() .brush(Color.LIGHT_GRAY) .font("Arial", 4) .enableStyledText(true) .text("Task <i>1</i>") .toolTip("This is the task") .create());
diagram.getFactory() .createShapeNode(20, 20, 20, 20).init() .brush(Color.LIGHT_GRAY) .font("Arial", 4) .enableStyledText(true) .text("Task <i>2</i>") .toolTip("This is the second task");
TreeLayout.with() .levelDistance(20) .nodeDistance(20) .linkStyle(TreeLayoutLinkType.Cascading3) .create() .arrange(diagram); |