All Packages This Package Class Hierarchy Class Search Index
java.lang.Object | +----java.util.Observable | +----graphomat.util.ObservSerializable | +----graphomat.graph.Graph
Summary |
public class Graph extends graphomat.util.ObservSerializable implements java.util.Observer { // Fields 6 public static final Object EDGEADDED; public static final Object EDGEDELETED; public static final Object NODEADDED; public static final Object NODEDELETED; public static final Object NODEMOVED; public static final Object NODESTATECHANGE; // Constructors 1 public Graph(); // Methods 15 public void addNode(Node); public void deleteNode(Node); public Edge getEdge(Node, Node); public int getEdgeCount(); public Enumeration getEdgeEnum(); public Node getFirstNodeAt(double, double); public int getNodeCount(); public Enumeration getNodeEnum(); public SubGraph getSelection(); public boolean inGraph(Node); public void notifyObservers(Object); public String toString(); public void traversEdges(EdgeTraverser); public void traversNodes(NodeTraverser); public void update(Observable, Object); }
This class provides the possiblity to store nodes and their connections.
The edges and the nodelist can be traversed with the
Enumeration
given by getNodeEnum()
and
getEdgeEnum()
.There is a second posibility
with the TraversNodes()
and the equivalent
TraversEdges()
method.
Cross Reference |
Fields |
· NODEADDED | Summary | Top |
public static final Object NODEADDED
· NODEMOVED | Summary | Top |
public static final Object NODEMOVED
· NODEDELETED | Summary | Top |
public static final Object NODEDELETED
· NODESTATECHANGE | Summary | Top |
public static final Object NODESTATECHANGE
· EDGEADDED | Summary | Top |
public static final Object EDGEADDED
· EDGEDELETED | Summary | Top |
public static final Object EDGEDELETED
Constructors |
· Graph | Summary | Top |
public Graph()
Methods |
· addNode | Summary | Top |
public void addNode(Node n)
All nodes added to the Graph have to be initallized first with the
new
operator, as shown below:Uninitalized nodes will be ignored.Graph g = new Graph();
g.addNode(new Node(4,1));
· deleteNode | Summary | Top |
public void deleteNode(Node n)
Nodes deleted from the Graph will be disconnected first. Uninitalized nodes will be ignored.
Uninitalized nodes will be ignored.Graph g = new Graph();
Node n1 = new Node();
g.addNode(n1);
g.deleteNode(n1);
· inGraph | Summary | Top |
public boolean inGraph(Node n)
Checks if the graphs owns the requested node.
· getSelection | Summary | Top |
public SubGraph getSelection()
Returns the current Selection of the Graph. If nothing is selected the whole Graph will be returned as a
SubGraph
.
· getFirstNodeAt | Summary | Top |
public Node getFirstNodeAt(double x, double y)
Returns the node with a given location. Is usefull if u forgot the handle of a specific node. If there are several nodes at this location, the oldest will be returned. Warning:
getFirstNodeAt()
returns null if there was no Node at this location.Graph g = new Graph();
Node n;
g.addNode(new Node(4,1));
n = g.getFirstNodeAt(4,1));
· getEdge | Summary | Top |
public Edge getEdge(Node n1, Node n2)
Returns the Edges connecting the two Nodes.
· traversNodes | Summary | Top |
public void traversNodes(NodeTraverser t)
Traverses all nodes and processes it with the given
NodeTraverser
.There is also the possibility to define aclass MoveTraverser extends NodeTraverser {
public void processNode(Node n) {
n.move(-1,2);
}
}
Graph g = new Graph();
MoveTraverser trav = new MoveTraverser();
g.addNode(new Node(2,3));
g.addNode(new Node(1,0));
g.traversNodes(trav);NodeTraverser
on-the-fly with a anonymous class.Graph g = new Graph();
g.addNode(new Node(2,3));
g.addNode(new Node(1,0));
g.traversNodes(new NodeTraverser() {
public void processNode(Node n) {
n.move(-1,2);
}
});
· traversEdges | Summary | Top |
public void traversEdges(EdgeTraverser t)
Traverses all edges and processes it with the given
EdgeTraverser
.
See Also: traversNodes
· getNodeEnum | Summary | Top |
public Enumeration getNodeEnum()
Returns a
Enumeration
containing the nodes of the Graph.Graph g = new Graph();
Enumertaion enum;
g.addNode(new Node(2,3));
g.addNode(new Node(1,0));
enum = g.getEnum();
while(enum.hasMoreElements()) {
((Node)enum.nextElement()).move(-1,2);
}
· getEdgeEnum | Summary | Top |
public Enumeration getEdgeEnum()
Returns a
Enumeration
containing the edges of the Graph.
See Also: getNodeEnum
· getNodeCount | Summary | Top |
public int getNodeCount()
Returns the number of nodes in the Graph.
· getEdgeCount | Summary | Top |
public int getEdgeCount()
Returns the number of edges in the Graph.
· toString | Summary | Top |
public String toString()
Returns a String discribing the whole Graph.
- Overrides:
- toString in class Object
· notifyObservers | Summary | Top |
public void notifyObservers(Object arg)
- Overrides:
- notifyObservers in class Observable
· update | Summary | Top |
public void update(Observable n, Object arg)
- Implements:
- update in interface Observer
All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7