44 |
*/ |
*/ |
45 |
public class SimpleView implements View { |
public class SimpleView implements View { |
46 |
|
|
|
/** The comparator used to order the nodes in the graph. |
|
|
* The vertical order of nodes is determined by this Comparator. |
|
|
*/ |
|
|
protected Comparator cmp; |
|
|
|
|
47 |
/** The view used to show the individual nodes. |
/** The view used to show the individual nodes. |
48 |
*/ |
*/ |
49 |
protected NodeView nodeView; |
protected NodeView nodeView; |
50 |
|
|
51 |
public SimpleView(Comparator cmp, NodeView nodeView) { |
public SimpleView(NodeView nodeView) { |
|
this.cmp = cmp; |
|
52 |
this.nodeView = nodeView; |
this.nodeView = nodeView; |
53 |
} |
} |
54 |
|
|
55 |
public void render(VobScene sc, int into, Cursor c) { |
public void render(VobScene sc, int into, Cursor c) { |
56 |
try { |
int midx = sc.size.width/2, midy = sc.size.height/2; |
57 |
int midx = sc.size.width/2, midy = sc.size.height/2; |
int cs = sc.boxCS(into, c.focus, midx-25, midy-10, 50, 20); |
58 |
int cs = sc.boxCS(into, c.focus, midx-25, midy-10, 50, 20); |
nodeView.render(sc, cs, c.focus); |
59 |
nodeView.render(sc, cs, c.focus); |
|
60 |
|
SortedSet nodes = c.getPoswardConnections(); |
61 |
SortedSet nodes = new TreeSet(cmp); |
int before = nodes.headSet(c.rotation).size(); |
62 |
StmtIterator i=c.focus.listProperties(); |
|
63 |
for(; i.hasNext();) nodes.add(i.next().getObject()); |
int x = midx + 75, y = midy-10-before*50; |
64 |
i.close(); |
|
65 |
|
for(Iterator j=nodes.iterator(); j.hasNext();) { |
66 |
int before = nodes.headSet(c.rotation).size(); |
RDFNode node = (RDFNode)j.next(); |
67 |
|
cs = sc.boxCS(into, node, x, y, 50, 20); |
68 |
int x = midx + 75, y = midy-10-before*50; |
nodeView.render(sc, cs, node); |
69 |
|
y += 50; |
|
for(Iterator j=nodes.iterator(); j.hasNext();) { |
|
|
RDFNode node = (RDFNode)j.next(); |
|
|
cs = sc.boxCS(into, node, x, y, 50, 20); |
|
|
nodeView.render(sc, cs, node); |
|
|
y += 50; |
|
|
} |
|
|
} catch(RDFException e) { |
|
|
throw new Error("RDFException: "+e); |
|
70 |
} |
} |
71 |
} |
} |
72 |
} |
} |