01: package prefuse.data.tuple;
02:
03: import prefuse.data.Edge;
04: import prefuse.data.Graph;
05: import prefuse.data.Node;
06: import prefuse.data.Table;
07:
08: /**
09: * Edge implementation that reads Edge data from a backing edge table.
10: *
11: * @author <a href="http://jheer.org">jeffrey heer</a>
12: */
13: public class TableEdge extends TableTuple implements Edge {
14:
15: /**
16: * The backing graph.
17: */
18: protected Graph m_graph;
19:
20: /**
21: * Initialize a new Edge backed by an edge table. This method is used by
22: * the appropriate TupleManager instance, and should not be called
23: * directly by client code, unless by a client-supplied custom
24: * TupleManager.
25: * @param table the edge Table
26: * @param graph the backing Graph
27: * @param row the row in the edge table to which this Node instance
28: * corresponds.
29: */
30: protected void init(Table table, Graph graph, int row) {
31: m_table = table;
32: m_graph = graph;
33: m_row = m_table.isValidRow(row) ? row : -1;
34: }
35:
36: /**
37: * @see prefuse.data.Edge#getGraph()
38: */
39: public Graph getGraph() {
40: return m_graph;
41: }
42:
43: /**
44: * @see prefuse.data.Edge#isDirected()
45: */
46: public boolean isDirected() {
47: return m_graph.isDirected();
48: }
49:
50: /**
51: * @see prefuse.data.Edge#getSourceNode()
52: */
53: public Node getSourceNode() {
54: return m_graph.getSourceNode(this );
55: }
56:
57: /**
58: * @see prefuse.data.Edge#getTargetNode()
59: */
60: public Node getTargetNode() {
61: return m_graph.getTargetNode(this );
62: }
63:
64: /**
65: * @see prefuse.data.Edge#getAdjacentNode(prefuse.data.Node)
66: */
67: public Node getAdjacentNode(Node n) {
68: return m_graph.getAdjacentNode(this , n);
69: }
70:
71: } // end of class TableEdge
|