29 |
import org.fenfire.*; |
import org.fenfire.*; |
30 |
import org.fenfire.view.*; |
import org.fenfire.view.*; |
31 |
import org.fenfire.view.buoy.*; |
import org.fenfire.view.buoy.*; |
32 |
|
import org.fenfire.view.lava.FastView; |
33 |
import org.fenfire.vocab.*; |
import org.fenfire.vocab.*; |
34 |
import org.fenfire.swamp.*; |
import org.fenfire.swamp.*; |
35 |
import org.fenfire.util.*; |
import org.fenfire.util.*; |
41 |
import org.nongnu.libvob.lava.placeable.Placeable; |
import org.nongnu.libvob.lava.placeable.Placeable; |
42 |
import org.nongnu.alph.*; |
import org.nongnu.alph.*; |
43 |
|
|
44 |
import java.util.Iterator; |
import java.util.*; |
45 |
|
|
46 |
/** A View2D of a CANVAS2D, with a given node function. |
/** A View2D of a CANVAS2D, with a given node function. |
47 |
*/ |
*/ |
48 |
public class CanvasView2D extends View2D implements NodedView2D{ |
public class CanvasView2D extends View2D implements NodedView2D, FastView { |
49 |
public static final String rcsid = "$Id$"; |
public static final String rcsid = "$Id$"; |
50 |
public static boolean dbg = false; |
public static boolean dbg = false; |
51 |
private static void pa(String s) { System.out.println("CanvasView2D::"+s); } |
private static void pa(String s) { System.out.println("CanvasView2D::"+s); } |
69 |
lineconn.glteardown = GLCache.getCallList("PopAttrib"); |
lineconn.glteardown = GLCache.getCallList("PopAttrib"); |
70 |
} |
} |
71 |
|
|
72 |
|
private Object container; |
73 |
|
private int paper2screen = -1; |
74 |
|
private ArrayList nodes = new ArrayList(); |
75 |
|
|
76 |
public void render(VobScene vs, Object container, |
public void render(VobScene vs, Object container, |
77 |
int matchingParent, int box2screen, int box2plane) |
int matchingParent, int box2screen, int box2plane) |
78 |
{ |
{ |
|
|
|
79 |
if (!RDFUtil.isNodeType(fen.graph, container, CANVAS2D.Canvas)) |
if (!RDFUtil.isNodeType(fen.graph, container, CANVAS2D.Canvas)) |
80 |
throw new Error("plane is NOT a container!"); |
throw new Error("plane is NOT a container!"); |
81 |
|
|
82 |
|
this.container = container; |
83 |
int paper2box = vs.invertCS(box2plane, "canvasview_INv"); |
int paper2box = vs.invertCS(box2plane, "canvasview_INv"); |
84 |
int paper2screen = vs.concatCS(box2screen, "canvasview_conc", |
paper2screen = vs.concatCS(box2screen, "canvasview_conc", |
85 |
paper2box); |
paper2box); |
|
|
|
86 |
Iterator iter = fen.constgraph.findN_11X_Iter(container, |
Iterator iter = fen.constgraph.findN_11X_Iter(container, |
87 |
CANVAS2D.contains); |
CANVAS2D.contains); |
88 |
if (dbg) pa("Canvas begin"); |
if (dbg) pa("Canvas begin"); |
89 |
|
nodes.clear(); |
90 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
91 |
Object n = iter.next(); |
Object n = iter.next(); |
|
|
|
|
// get coords |
|
|
int x = RDFUtil.getInt(fen.graph, n, CANVAS2D.x); |
|
|
int y = RDFUtil.getInt(fen.graph, n, CANVAS2D.y); |
|
|
|
|
92 |
Placeable p = (Placeable)nodeView.f(fen.constgraph, n); |
Placeable p = (Placeable)nodeView.f(fen.constgraph, n); |
|
|
|
93 |
Pair matchKey = new Pair(container, n); |
Pair matchKey = new Pair(container, n); |
|
// int cs = vs.coords.translate(paper2screen, x, y); |
|
|
if(dbg) pa("CANVAS: "+p.getWidth()+" "+p.getHeight()); |
|
94 |
|
|
95 |
int cs = vs.coords.orthoBox(paper2screen, 0, |
int cs = vs.coords.orthoBox(paper2screen, 0,1,2,3,4,5,6); |
96 |
x, y, 1, 1, |
nodes.add(""+cs); |
97 |
p.getWidth(), p.getHeight()); |
chgFast(vs); |
98 |
|
|
99 |
vs.matcher.add(matchingParent, cs, matchKey); |
vs.matcher.add(matchingParent, cs, matchKey); |
100 |
vs.activate(cs); |
vs.activate(cs); |
101 |
if(cull) { |
if(cull) { |
102 |
cs = vs.cullCS(cs, "CULL", box2screen); |
cs = vs.cullCS(cs, "CULL", box2screen); |
103 |
} |
} |
104 |
p.place(vs, cs); |
p.place(vs, cs); |
105 |
} |
} |
106 |
|
|
107 |
// show connections |
// show connections |
108 |
Iterator iter1 = fen.constgraph.findN_11X_Iter(container, |
Iterator iter1 = fen.constgraph.findN_11X_Iter(container, |
124 |
|
|
125 |
vs.map.put(lineconn, cs1, cs2); |
vs.map.put(lineconn, cs1, cs2); |
126 |
} |
} |
127 |
} |
} |
128 |
|
} |
129 |
|
|
130 |
|
public void chgFast(VobScene oldVS) { |
131 |
|
|
132 |
|
Iterator iter = fen.constgraph.findN_11X_Iter(container, |
133 |
|
CANVAS2D.contains); |
134 |
|
for (int i=0; i<nodes.size(); i++) { |
135 |
|
Object n = iter.next(); |
136 |
|
int x = RDFUtil.getInt(fen.graph, n, CANVAS2D.x); |
137 |
|
int y = RDFUtil.getInt(fen.graph, n, CANVAS2D.y); |
138 |
|
|
139 |
if (dbg) pa("Canvas DONE"); |
Placeable p = (Placeable)nodeView.f(fen.constgraph, n); |
140 |
|
|
141 |
|
// int cs = vs.coords.translate(paper2screen, x, y); |
142 |
|
if(dbg) pa("CANVAS: "+p.getWidth()+" "+p.getHeight()); |
143 |
|
|
144 |
|
int cs = Integer.parseInt((String)nodes.get(i)); |
145 |
|
oldVS.coords.setOrthoBoxParams(cs, 0, |
146 |
|
x, y, 1, 1, |
147 |
|
p.getWidth(), p.getHeight()); |
148 |
|
} |
149 |
} |
} |
150 |
|
|
151 |
public Object getNode(VobScene oldvs, |
public Object getNode(VobScene oldvs, |