The list below describes past changes and additions to JDiagram:
The NodeLabel class allows multiple captions to be displayed for a single DiagramNode of any type. Node labels provide a set of properties allowing full customization of their display and positioning. Label position is defined by specifying a pin point and offset from it, set through setCornerPosition, setEdgePosition, setCenterPosition methods. In addition, the HorizontalAlign and VerticalAlign properties of NodeLabel specify on which side of pin point to draw the label's caption.
For example, following code adds extra labels to top-left and bottom-right corners of a ShapeNode:
Java
![]() |
---|
ShapeNode node = diagram.getFactory().createShapeNode(10, 50, 40, 30); |
Fixed exception when serializing LinkLabel in JSON format.
Set the Scrollable property of ContainerNode to let users scroll the container's contents. The node then displays scrollbars at right and bottom edges that can be used to scroll interactively. The ScrollX and ScrollY properties let you determine current scroll position or change it programmatically. Note that in order to let container's content overflow and become scrollable, you must either disable AutoGrow, or allow users reduce container size by changing HandlesStyle and EnabledHandles properties from their default MoveOnly / Move values.
The control now supports several ways to zoom using lasso tool:
The ModifierKeyActions property of DiagramView lets you bind modifier keys to diagram actions defined in ModifierKeyAction enum to execute when dragging with left mouse button with respective key pressed:
RightButtonActions and MiddleButtonActions properties of DiagramView let you map mouse buttons to members of the MouseButtonAction enum (Pan, Cancel, Select, Draw, Magnify, Zoom) specifying how mouse click or drag operations affect the diagram.
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. The Factory class contains createSvgNode overloaded methods for creating nodes from SVG files or from already loaded SvgContent instances.
Diagrams can now be serialized in JSON format. This can be used for interoperability with MindFusion JavaScript diagramming library, or for general storage in JSON files or databases. To serialize a Diagram to a JSON string, call its saveToJson method. To deserialize a diagram back from its JSON representation, call the loadFromJson method. Custom item classes can implement JSON serialization for their additional properties by overriding the saveToJson and loadFromJson methods of DiagramItem. Such classes must be registered for serialization by calling the registerItemClass method and providing a string identifier for the clientClass parameter.
Component classes that support user interaction can now be used as part of CompositeNode templates:
FlowchartLayout can now arrange more types of graphs, no longer requiring them to represent strictly-nested source code structures.
The ExcelExporter class from com.mindfusion.diagramming.export package exports diagrams to Excel Open XML format (XSLX). Diagrams are exported as Excel AutoShapes drawings. The export overload that takes a DiagramDocument parameter creates a sheet for each DiagramPage in the document. The export(Diagram) overload creates a single Excel sheet.
Java
![]() |
---|
ExcelExporter ex = new ExcelExporter(); |
Improved back-buffer allocation code. The memory footprint of the diagram should now be much lower and drawing should be slightly faster.
The shape of a ShapeNode can be flipped horizontally or vertically. Enable the AllowFlip property and the shape flips when an edge is dragged over its opposite edge. You can get or set current flip state using FlipX and FlipY properties.
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
![]() |
---|
diagram.getNodes().add( |
Old-style enumeration classes with static finals have been replaced by enum types, improving type checking and auto-completion support. This change will not affect your code if only passing enum members to methods from the API. If storing them in fields on the other hand, you must change the field type from int to respective enum type.
The types changed to enum are - Action, Align, Anchoring, AttachToLink, AttachToNode, AutoResize, Behavior, CellFrameStyle, ColumnStyle, CustomDraw, DelKeyAction, DirectionConstraint, EffectPhase, ExpandButtonAction, ExpandButtonPosition, GlassEffectType, Granularity, GraphicsUnit, GridStyle, GroupRotation, HandlesStyle, HatchStyle, HitTestPriority, HyperLinkStyle, ImageAlign, LayeredLayoutLinkType, LinkCrossings, LinkShape, LinkTextStyle, MarkStyle, ModificationStart, MouseInputMode, MultipleGraphsPlacement, NodeHandleType, Orientation, Relationship, RelativeToLink, RerouteLinks, RestrictToBounds, SaveToStringFormat, SelectionStyle, ShadowsStyle, ShowAnchors, SimpleShape, SnapToAnchor, TableConnectionStyle, TickPosition, TreeLayoutBalance, TreeLayoutDirection, TreeLayoutLinkType, TreeLayoutType, TreeViewConnectionStyle.
Type of EnabledHandles and TriggerRerouting properties has been changed to EnumSet.
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 or LinkFreeForms. 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's Closed property is automatically set to true. AutoCloseDistance default value is Float.MAX_VALUE, so free-form nodes are always closed.
Additional drawing modes, convenient for touch input, convert FreeFormNode objects drawn by user to ShapeNode objects with matching shapes. To enable them, set Behavior to DrawFreeShapes or LinkFreeShapes. The shapes against which the user's input is matched are set via diagram's FreeFormTargets property. By default it contains Rectangle, Decision and Ellipse shapes.
Adjustment handles are no longer identified by integer values but by instances of AdjustmentHandle and derived classes. This changes the signatures of DiagramItem.hitTestHandle methods and the InteractionState constructor. Standard handle classes included are NodeAdjustmentHandle for changing a node's position and size, LinkAdjustmentHandle for changing link control point positions, and FreeFormHandle for changing the position of a FreeFormNode outline point.
Columns and rows of a TableNode can now be resized interactively if its AllowResizeColumns or AllowResizeRows properties are enabled. In order to resize, move the mouse pointer to the border line on column's right side or row's bottom side until it shows resize cursor and start dragging. The control raises tableColumnResizing and tableRowResizing events to let you validate new size or prevent resizing some elements. The tableColumnResized and tableRowResized events are raised after the operation completes.
There is no separate trial build of the control's JAR archive provided anymore. Instead, call the setLicenseKey method of DiagramView to disable the component's evaluation mode and stop displaying trial messages. setLicenseKey is static and you can call it just once before creating any views. License key strings are now listed on the Keys & Downloads page at MindFusion's customer portal.
Tree maps represent hierarchies by nesting child nodes within their parents, where the areas of leaf nodes are proportional to their Weight values. Unlike other layout algorithms, TreeMapLayout expects hierarchies to be defined via grouping or containment (see attachTo method and ContainerNode class), and will ignore any links in the diagram. The diagram area covered by the topmost nodes in a hierarchy is specified via the LayoutArea property. By default, the layout tries to keep the ratio of node sides as close as possible to one. However this could make it hard to distinguish separate levels of the hierarchy. To alleviate that, set Squarify to false, and child nodes will be arranged either as a row or a column inside their parent node, alternating directions for each level. The drawback is that when Weight ratios differ greatly or nodes contain many children, some nodes could end up with very narrow rectangles.
DecisionLayout arranges simple flowcharts consisting of decision boxes with up to three outgoing links per node and activity boxes with a single outgoing link per node. The nodes are arranged in columns and rows, whose distance depends on the HorizontalPadding and VerticalPadding property values. When links share the same row or column, they are placed at a distance specified via LinkPadding. The layout arranges nodes recursively starting from StartNode. If StartNode is not specified, the algorithm selects the root of the deepest branch of the graph's spanning tree as start node.
The CompositeNode class implements nodes whose appearance can be defined via composition of components and layout containers. The content of a composite node can be loaded from XML files similar to .NET Xaml templates and Android XML layouts. This initial release includes layout containers such as StackPanel and GridPanel, and read-only components like ImageComponent, TextComponent, ShapeComponent, BorderComponent. Future versions will add interactive components like buttons and text editors.
The VisioExporter class can export the content of Diagram and DiagramDocument objects to Visio 2013 VSDX files. In order to use it, import the com.mindfusion.diagramming.export namespace. VisioExporter relies on a template file, called Visio2013.vxt, containing some boilerplate Visio XML code. The template must be either located in same folder as the application, or its path must be specified via the TemplatePath property. At this time the exporter supports shapes from Visio basic stencil. Support for more shapes will be added upon request.
Now it is possible to resize multiple selected nodes simultaneously. To enable that, set the AllowMultipleResize property to true. When enabled, dragging a corner or side adjustment handle of any node resizes all nodes in the selection. The operation will be cancelled for all nodes if any of them does not accept its new size, e.g. if it's smaller than minimum allowed node size.
The VisioImporter class can import .vsdx files created by Visio 2013. In order to use it, you must import the com.mindfusion.diagramming.importers namespace. Various overloads of the import method can be used to import the file into a DiagramDocument whose pages correspond to the Visio drawing pages, or into a single Diagram whose content is merged from all imported pages. At this time VisioImporter supports the basic flowchart and data flow Visio stencils. For each node shape from the .vsdx file, the importer creates a ShapeNode object whose Shape, Text, Brush and Pen properties are set to values corresponding to the imported Visio shape. For each connector shape, the importer creates a DiagramLink object whose Origin and Destination are set to the corresponding imported nodes, and whose ControlPoints reflect the geometry of the connector.
The DrawImporter class can import .odg files, created by the OpenOffice Draw vector graphics editor. In order to use it, you must import the com.mindfusion.diagramming.importers namespace. DrawImporter supports shapes from the General and Flowchart shape palettes in Draw. Various overloads of the import method can be used to import the OpenOffice drawing into a DiagramDocument whose pages correspond to the Draw pages, or into a single Diagram whose content is merged from all imported pages. For each node shape from the .odg file, the importer creates a ShapeNode object whose Shape, Text, Brush and Pen properties are set to values corresponding to the imported OpenOffice shape. For each connector shape, the importer creates a DiagramLink object whose Origin and Destination are set to the corresponding imported nodes, and whose ControlPoints reflect the geometry of the connector.
The ZoomControl class lets users change interactively the current zoom level and scroll position of a DiagramView. To set it up, add a ZoomControl to the frame, place it anywhere over a DiagramView, and set the control's View property to that view. Set the ZoomStep and ScrollStep properties to specify the amount added to view's zoom level or scroll position by ZoomControl's buttons. You can customize the control's appearance by setting properties such as Fill, BorderColor, CornerRadius and TickPosition.
The HatchBrush class allows filling shapes with a pattern. Supported patterns are exposed as members of the HatchStyle class. Points or lines from the patterns are painted using the brush' ForegroundColor property, while the space between points or lines is filled using BackgroundColor.
For source code compatibility with Android version of the control, and eventual multi-touch support in future Java Swing versions, these members has been renamed to follow the W3C pointer events specification:
The Balance property of TreeLayout can be set to Preserve to keep the original geometric order of child nodes when arranging them under their parent. This can be used to arrange tree branches in a specific order by first placing them in increasing horizontal or vertical positions. Another possibility is to apply TreeLayout from nodeModified handler to let users rearrange the tree branches by dragging and dropping a node.
PathFinder now supports undirected mode. Its methods have been changed from static to instance, and its constructor takes an ignoreDirection parameter. If ignoreDirection is enabled, the underlying graph is treated as undirected and link direction is not considered when looking for paths.
The appearance of the items in a diagram can now be modified using styles. The style represents a set of properties, which can be applied to an individual diagram item (by assigning it to the DiagramItem.Style property) or to all items of a specific type (by using a Theme). The styles can be easily expanded to include the properties in derived item classes.
The theme represents a collection of styles. Each style in the theme is associated with the diagram items of a specific type and affects all items of this type. Themes can be loaded from XML files. New themes can be created using the Theme Editor tool. Several pre-defined theme files are installed under the Themes subfolder of the control's root installation folder.
For more information about this new feature, check Styles and Themes.
Two visual effects, represented by GlassEffect and AeroEffect classes, can be applied to nodes. To apply an effect, create an instance of the respective class, set up its properties, then add the instance to the Effects collection of a node (or to Diagram.NodeEffects collection to apply it to all nodes). Effects can be added, removed or modified at any time and this will immediately reflect on the diagram. Effects of different types can be applied simultaneously. It is also possible to apply more than one effect of the same type.
The DiagramDocument class represents a collection of diagram pages or sheets, represented by DiagramPage objects. DiagramPage is derived from Diagram and only adds a Title property, so any current code that processes Diagram objects will work with DiagramPage objects too. New pages can be added to the document and existing pages can be removed and reordered via the Pages collection. The diagram document provides higher level of events for the pages contained inside it. The document supports the notion of an active page.
A DocumentView object placed inside a TabbedScrollPane can be used to display DiagramDocument objects. The view displays tabs for the individual pages in the document. The active page can be changed interactively by activating its associated tab. New pages can be added and removed to/from the document through buttons in the tab tray and the pages can be rearranged by dragging their associated tabs with the mouse.
The OneWayLayout class ensures that links enter into nodes from the same general direction and exit them from the opposite side. If the graph contains cycles, some links bend around the nodes to keep the enter/exit direction consistent. The algorithm aims to minimize the number of such links.
The NodeListView is a JList control that can host any type of DiagramNode objects. Nodes from to the NodeListView control can be drag-and-dropped onto a Diagram, which creates a clone of the dragged node at the drop position.
Items can now be assigned to layers, and layers can be hidden, locked or moved up/down in the Z order as a group. Call the setLayerIndex method of items to associate them with layers in the Diagram.Layers collection. The Layer objects provide Visible, Locked and ZIndex properties, which will affect all items in the respective layer. Layers also expose a Title property shown in the LayerListView control. Newly drawn items are added to the layer specified via Diagram.setActiveLayer.
For additional information about layers, refer to Layers.
The LayerListView control provides user interface for working with Layer objects. The control displays a list of all layers in a specified Diagram with a title and an overview area, and also allows editing of layer's Title, Visible and Locked properties and choosing the Diagram's currently active layer. New layers can be added to the Diagram by clicking the '+' button. The selected layer can be deleted by clicking the '-' button.
The new magnifier tool allows users to interactively zoom in (or out) portions of the diagram by holding down a modifier key or pressing a mouse button. The magnifier's zoom factor and appearance can be customized. Additional information can be found in the corresponding section of Scrolling and Zooming.
The ruler units can now be specified more precisely through instances of the new MeasureUnit class. The MeasureUnit class provides several built-in units as well as the opportunity to create custom units of measure. As a result, the RulerUnit enumeration has been removed and the type of the Unit property has been changed. The InchDivisions property of the Ruler class has been removed as well - the division information is now built into the MeasureUnit type and no longer needs to be specified explicitly. Custom divisions can still be specified for any unit by creating a custom MeasureUnit instance and providing the appropriate value in the standardDivisons constructor parameter.
ControlNode is an adapter class that allows using any java.awt.Component -derived object as a diagram node. Such nodes can be used to implement advanced entity viewers or editors using the Java Swing framework. A Component instance can be assigned to the Control property of the host node. It could be a standard Java Swing component such as a JTable or your own custom control. If the Behavior property of DiagramView is set to DrawControls or LinkControls, then users are allowed to draw control host nodes interactively. Such host nodes will have their Control initialized to an instance of the type specified via DefaultControlType.
Recent Java and browser versions do not work very well when more than one applets are loaded on the page (e.g. IE crashes when reloading such pages, in some browsers Java objects cannot be passed between two applets). Hence the DiagramApplet, used to host a DiagramView control, has been modified to also show the miscellaneous UI controls such as Overview, ShapeListBox and Ruler. The applet parameters used to create and customize these controls are listed in the Diagram Applet topic.
If AutoAlignNodes is enabled, the node currently being drawn or resized is aligned to another node so that a pair of their vertical or horizontal sides become collinear. To specify the maximal distance at which nodes are aligned, set the AutoAlignDistance property. The pair of aligned nodes is indicated visually by drawing an alignment guide using the pen assigned to AlignmentGuidePen.
FractalLayout is a tree layout algorithm that places child nodes symmetrically around their parent node. Nodes at the lowest level are arranged directly in a circle around their parent. At the upper level, the already arranged nodes form branches that are arranged in a circle around the new parent node. The algorithm is recursively repeated till the highest level is reached. If nodes in the tree have uniform number of children, the end result has fractal-like appearance (subsets of the graph look like scaled-down copies of the whole graph). You can choose which node should be displayed at the center of the topmost circle by setting the Root property. If it is not specified, the algorithm automatically selects a root that leads to more balanced distribution of nodes.
The query method of DiagramItem can be used to find items that can be reached from the current one by following a path described in the query expression specified as argument. The expression includes selectors separated by a / character, where each selector returns the items from the result set of the previous step. The expressions can also include boolean predicates that filter the results using boolean and arithmetic expressions.
The swimlane grid lets you emphasize the relationship between a group of diagram items by displaying them in a distinct lane or cell within the grid. To display the lane grid, set the EnableLanes property of the Diagram class to true. In order to customize the grid, set the various attributes exposed by the LaneGrid property, which lets you specify the number of rows and columns, add headers, customize the cell appearance, etc. The new Lanes sample project uses the lane grid to let users draw Gantt charts.
SwimlaneLayout can be used to arrange process diagrams in which nodes representing activities are placed in swimlanes representing resources. The index of the resource allocated to an activity should be assigned to the corresponding node's LayoutTraits via the SwimlaneLayoutTraits.Lane key.
By default, the algorithm works with the diagram's LaneGrid, but its SwimlaneGrid property can be set to any class that implements the SwimlaneGrid interface. This allows applying the layout to a custom-drawn grid rendered through the drawBackground event, or one composed of locked background nodes.
CascadeLayout places nodes on a virtual grid and arranges links orthogonally, such that if the source graph is planar all links are guaranteed to have no more than two bends and will not intersect. By default the layout method arranges nodes in rows and link segments in columns; this can be changed by setting the Orientation property.
TriangularLayout places nodes on a virtual grid, such that if the source graph is planar, all links are guaranteed to have a single segment and not intersect. If the graph is not planar, its intersecting links can be optionally segmented and bended in order to improve readability. The layout method places the nodes from the external face on a triangle and recursively adds the rest of the nodes as vertices of internal triangles. As a result, it is very effective for near maximal-planar (a.k.a. triangular) graphs.
HierarchicalLayout places nodes on user-defined levels, such that if the source graph is level-planar, all links are guaranteed to have a single segment and will not intersect. A graph is considered level-planar if it is possible to draw it without link intersections when its nodes are positioned on predefined levels. The layout method requires that for each node LayoutTraits contains a HierarchicalLayoutTraits.Level entry specifying the level, and no two connected nodes must be on the same level.
The type of the HeadShape, BaseShape and IntermediateShape properties of DiagramLink has been changed from enum ArrowHead to class Shape, which is also used to define ShapeNode shapes. The ArrowHeads class now exposes Shape definitions that correspond to the ArrowHead enumeration members from previous versions. It is also possible to set any other predefined or custom shape accessible through the fromId method as an arrowhead. When used for arrowheads, position (50, 0) in the shape definition corresponds to the arrowhead's tip point.
If the underlying graph if acyclic, TopologicalLayout arranges the nodes linearly in such a way that each node comes before all destination nodes of its outgoing links. The links are drawn as curves above the chain of nodes, with their height proportional to the distance between the nodes. If the graph is not acyclic, the layout algorithm finds an ordering with a minimal number of back links, and draws the back links below the chain of 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.
The Ruler control provides horizontal and vertical scales that helps users measure and align diagram items. In order to set the Ruler as a parent of a DiagramView, call its setDiagramView method. The control also implements support for scrolling and can be used instead of a JScrollPane.
The SvgExporter class creates a Scalable Vector Graphics (SVG) drawing from the content of a Diagram. Custom-drawn elements are exported too through an SVG implementation of the Graphics2D interface provided by JDiagram.
A much faster link routing algorithm has been implemented. It can arrange a thousand links for just a few seconds, while older versions would require several minutes. Now it is also possible to create custom routing classes to be used when a link must be routed by implementing the LinkRouter interface. An instance of such class can be set through the LinkRouter property of the Diagram class. JDiagram provides two classes that implement LinkRouter - GridRouter and QuickRouter. By default LinkRouter is set to a QuickRouter instance.
FlowchartLayout recognizes program code-like patterns in the graph, such as loops, sequences and if/switch branchings, and arranges them recursively. FlowchartLayout could be used to arrange other types of graphs as well, though with some restrictions. For example it treats all back links as loops in the code, and expects that they are nested - loop links starting closer to the stop node should end closer to the start node. Another similar restriction is that there shouldn't be any cross-links that connect different branches of a decision sub-graph.
The ActiveItemHandlesColor, SelectedItemHandlesColor and DisabledHandlesColor properties have been replaced by ActiveItemHandlesStyle, SelectedItemHandlesStyle and DisabledHandlesStyle. The HandlesVisualStyle objects returned by them provide sub-properties for greater control over the appearance of selection handles. The adjustment handles can now be painted not only in solid color but with arbitrary brushes, such as GradientBrush and TextureBrush objects.
serializeTag and deserializeTag handlers should call the setHandled method in order for the control to use the custom tag xml.
The PdfExporter class lets you exports diagrams to Adobe Portable Document Format (PDF) files. In order to do that, create a PdfExporter instance and call its export method. If you need to set the page size and orientation, call the setPageSize, and setPageOrientation methods.
The OrthogonalLayout class implements an orthogonal graph layout algorithm. Each link is drawn as a chain of alternating horizontal and vertical segments. Nodes are placed in a way that facilitates few links bends and crossings. This algorithm was designed for planar graphs where the nodes have at most four incident links, and produces best results with such graphs as input. It can arrange any arbitrary graph as well, by adding some dummy nodes and links to planarize the graph and reduce its vertex degree, and removing them after the layout.
CircularLayout distributes nodes evenly on the circumference of a circle at positions that result in as few link crossing as possible. Set its Radius attribute to specify the size of the layout circle. Call setSiftingRounds to specify the number of fine-tuning crossing-reduction iterations.
The OrthogonalLayout class from previous JDiagram versions has been renamed to OrthogonalRouter.
JDiagram implements the Model-View-Controller (MVC) architectural pattern in its new version 2. The MVC design pattern as applied to JDiagram separates the diagram data (model) from its representation to the user (view) and controlling it by the user (controller). According to the MVC design pattern, JDiagram Version 2 provides two new classes instead of the FlowChart class, namely Diagram and DiagramView.
The JDiagram API has been redesigned to allow for seamless integration of custom node and link types. You can define a custom item type by deriving from DiagramLink or DiagramNode. You can also derive from more specific node types such as ShapeNode or ContainerNode. New items can be added to a diagram by instantiating them and adding them to the Nodes or Links collections. To improve support for custom types, many type-specific methods have been replaced with more generic versions, for example, findNode instead of findBox and findTable. For more information on the API changes, take a look at the Moving to JDiagram 2 section of the help file.
The ContainerNode class implements diagram nodes that can function as containers for other nodes. Containers can be folded to hide their content, and unfolded to show it again. Containers can be nested one within another, without limitation on the depth of nesting. The containerChildAdded and containerChildRemoved methods are called when nodes are added to or removed from containers.
OrthogonalRouter is a secondary layout algorithm that can be used to arrange links after an initial node arrangement has already been applied. The orthogonal layout is useful when there are much more links than nodes in a graph. The algorithm strives to achieve the following criteria, while preserving as much of the initial node configuration as possible: links must not overlap; only vertical and horizontal routing lines are used; graph routing is performed with respect to the specified main layout direction; links crossings are minimized; bends are minimized.
Now, it is possible to place the unconnected subgraphs in such a way that the diagram covers a minimal area. To enable that, choose MinimalArea for the MultipleGraphsPlacement object.
A single diagram item or a selection of items can be copied or cut to the system clipboard. This is done programmatically using the copyToClipboard and cutToClipboard methods. To paste the clipboard contents into the current diagram call pasteFromClipboard.
For more information on the API changes, take a look at the Moving to JDiagram 2 section of the help file.