The JGraph component supports extended display and editing options, but the semantic of the graph, that is, the meaning of the vertices and edges, is defined by the application. Therefore, JGraph is highly customizable, and the classes provide "hooks" for subclassers. In cases where these customizations are not sufficient, the component's source must be available to change the default implementation.
To summarize, the components for trees and lists are mostly used to display data structures, whereas this graph component is typically also used to modify a graph, and handle these modifications in an application-dependent way.
Because of JGraph's attributes the following should be kept in mind: Register a view with the model before using the insert
method, because otherwise the attributes that are passed to the method are ignored, resulting in cells that have the same size and position.
Due to the special setup inherited from JTree, JGraph's cells and cell views may not be used as components, and vice versa, components may not be added to JGraph. To use a cell view as a component, an instance of its renderer must be used instead, providing a dummy cell view that provides the data to be displayed. Vice versa, to place a component in a graph, the component should be used as a renderer for a specific cell view.
Using the GraphModel
interface, it is only possible to insert, remove or change the model, but it is not possible to create and execute composite changes, which do more than one of the above. To implement composite changes, a custom model must provide additional methods which either allow to create transactions out of other transactions, or access the model in a transaction-oriented way using begin,
commit
and rollback
methods.
In contrast to JTree's default model, which offers a flag that affects the way data is stored and cached, in JGraph, data is always cached by the cell views. Thus, the default graph model scales well, and must only be extended if the algorithm for spatial search or the storage data structure needs to be replaced with a more efficient algorithm.