Package diva.graphx

The diva.graphx package provides extensible and interactive viewing of graph data structures.

See:
          Description

Interface Summary
AttributeAdapter An adapter to allow the Diva graph interaction code to operate on attributes of graph elements.
AttributeProxy An attribute proxy is an object that is used to allow finer-grained manipulation of attributes of graph elements.
EdgeAdapter An edge adapter is used by GraphModel to manipulate edge objects in the application's graph data structure.
NodeAdapter A node adapter is used by GraphModel to manipulate node objects in the application's graph data structure.
 

Class Summary
EdgeController A edge controller is the object responsible for managing all instances of a particular type of edge, and the corresponding Figures that are used to represent them on the canvas.
GraphController A graph controller manages graph elements, such as nodes and edges, and their visual representations on a canvas.
GraphModel The class that represents a graph.
GraphUtilities A set of utilities for traversing/manipulating/etc.
NodeController A node controller is the object responsible for managing all instances of a particular type of node, and the corresponding Figures that are used to represent them on the canvas.
 

Exception Summary
GraphException A graph package topological error.
 

Package diva.graphx Description

The diva.graphx package provides extensible and interactive viewing of graph data structures. The name stands for "graph extension," by which we mean that the package is designed to be used with your existing graph data structure to make it visible and editable. Your graph data structure does not have to be modified to be used this way.

To be able to read and manipulate your graph structure, the package requires that you implement two interfaces, NodeModel and EdgeModel. Each of these is an adapter (perhaps we should have named them that way) to nodes or edges of your graph. For example, EdgeModel has method such as

java.lang.Object getHead(java.lang.Object edge);
java.lang.Object getTail(java.lang.Object edge);
boolean isDirected(java.lang.Object edge);
By implementing this interface, you provide diva.graphx with enough access to your graph structure to read and manipulate it. You will notice that the argument types above are all Object, so we are losing some type-safety in trade for this flexibility.

To draw your graph in a canvas pane, diva.graphx needs you to also implement the interfaces NodeRenderer and EdgeRenderer. Each of these has a method that takes a node or edge object as argument, constructs a diva.canvas.Figure, and returns it. diva.graphx will add this figure to the canvas, and place or route it appropriately.

The key strength of diva.graphx is thus its ability to allow you to quickly construct an interactive, MVC-architecture, editing pane for your graphs. More complex editors can be built on top of this functionality if desired. For simple applications, diva.graphx provides a simple attributed graph data structure that can be used.

Graphs can also be constructed programmatically. Here is an example of instantiating a simple graph with two nodes connected by an edge ( A -> B ).

// Construct the widgets
Frame f = new Frame();
JGraph g = new JGraph();
f.add("Center", g);

// Construct the graph
BasicNode a = new BasicNode("a");
BasicNode b = new BasicNode("b");
BasicEdge e = new BasicEdge("e");
jg.getModel().addNode(a);
jg.getModel().addNode(b);
jg.getModel().connect(e, a, b);

// Display it all
f.setVisible(true);



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.