Where to Find Up-to-date yFiles Information

This page is from the outdated yFiles for Java 2.13 documentation. You can find the most up-to-date documentation for all yFiles products on the yFiles documentation overview page.

Please see the following links for more information about the yFiles product family of diagramming programming libraries and corresponding yFiles products for modern web apps, for cross-platform Java(FX) applications, and for applications for the Microsoft .NET environment.

More about the yFiles product family Close X

View Implementations

Class HierarchyJTree

Class HierarchyJTree is an implementation of a view that displays the nodes of a grouped graph in a tree-like fashion. The presentation resembles a directory structure with normal nodes being leaves, group nodes being opened directories, and folder nodes being closed ones.

Note

HierarchyJTree is perfectly suited to display "flat" graphs also.

HierarchyJTree uses the first node label as the descriptive text to be displayed. Node labels that render HTML code result in rendered HTML in the tree-like view, too, since HierarchyJTree utilizes a DefaultTreeCellRenderer object for this task.

Figure 7.6, “Graph view provided by HierarchyJTree” shows a HierarchyJTree placed in the lower left corner inside an application's window.

Figure 7.6. Graph view provided by HierarchyJTree

Graph view provided by HierarchyJTree.

Class HierarchyJTree's presentation of the selection state indication is at any time synchronized with the selection state as present in the grouped graph.

The tutorial demo application HierarchyJTreeDemo.java shows how to use HierarchyJTree to display the hierarchical structure of a graph.

Related Classes

Class DefaultNodeChangePropagator

Using the services of class DefaultNodeChangePropagator HierarchyJTree also gets notified whenever a group node is changed to a folder node or vice-versa. Such modifications to the graph hierarchy result in a label change of the respective node in the tree-like view.

Class HierarchyTreeTransferHandler

Class HierarchyTreeTransferHandler can be used to add drag-and-drop functionality to a HierarchyJTree. It is a proper javax.swing.TransferHandler that enables changing the tree-like representation of a grouped graph by means of simple mouse drag gestures. Each such change is directly converted to an actual change of the graph hierarchy itself.

Example 7.4, “Enabling drag-and-drop for a HierarchyJTree” shows how to enable the drag-and-drop gesture on the content of the HierarchyJTree. The HierarchyManager that is associated with the grouped graph is given to HierarchyTreeTransferHandler at creation time.

Example 7.4. Enabling drag-and-drop for a HierarchyJTree

// 'hierarchyManager' is of type y.view.hierarchy.HierarchyManager.

HierarchyJTree tree = new HierarchyJTree(hierarchyManager);
tree.setDragEnabled(true);
// The given HierarchyManager is responsible for the grouped graph that is
// presented in the HierarchyJTree.
tree.setTransferHandler(new HierarchyTreeTransferHandler(hierarchyManager));