14 |
import java.util.*; |
import java.util.*; |
15 |
|
|
16 |
public class PPView2 implements View { |
public class PPView2 implements View { |
17 |
|
public static boolean dbg = true; |
18 |
|
private static void pa(String s) { System.err.println(s); } |
19 |
|
|
20 |
// Geometry |
// Geometry |
21 |
|
|
113 |
float[] sqs = new float[2]; |
float[] sqs = new float[2]; |
114 |
glc.getSqSize(frameCS, sqs); |
glc.getSqSize(frameCS, sqs); |
115 |
|
|
116 |
|
pa("Sqs frame: "+sqs[0]+" "+sqs[1]); |
117 |
|
|
118 |
// CS from center of frameCS to screen |
// CS from center of frameCS to screen |
119 |
int framecenterCS = vs.translateCS(frameCS, "FCTR", sqs[0]/2, sqs[1]/2); |
int framecenterCS = vs.translateCS(frameCS, "FCTR", sqs[0]/2, sqs[1]/2); |
120 |
|
|
181 |
*/ |
*/ |
182 |
List buoyqueue = new ArrayList(); // Try to pronounce *that* |
List buoyqueue = new ArrayList(); // Try to pronounce *that* |
183 |
|
|
184 |
|
private int[] getCoords(Cell c) { |
185 |
|
Cell firstCoord = c.s(d.pan); |
186 |
|
if(firstCoord == null) return null; |
187 |
|
return gzz.client.Params.getInts(firstCoord, d.pan, 2, null); |
188 |
|
} |
189 |
|
|
190 |
class BFloater implements Cell1DBuoyHook.Floater { |
class BFloater implements Cell1DBuoyHook.Floater { |
191 |
int dir; |
int dir; |
192 |
VobScene vs; |
VobScene vs; |
213 |
buoyVPWidth, buoyVPHeight); |
buoyVPWidth, buoyVPHeight); |
214 |
vs.activate(frameCS); |
vs.activate(frameCS); |
215 |
// XXX Pan |
// XXX Pan |
216 |
final int c2fCS = vs.coords.ortho(0, 0, 0, 0, buoyZoom, buoyZoom); |
int[] pan = getCoords(c); |
217 |
|
final int c2fCS = vs.coords.ortho(0, 0, |
218 |
|
-pan[0]*buoyZoom, -pan[1]*buoyZoom, buoyZoom, buoyZoom); |
219 |
vs.matcher.addSub(buoycs, c2fCS, "C2F"); |
vs.matcher.addSub(buoycs, c2fCS, "C2F"); |
220 |
|
|
221 |
buoyqueue.add(new Runnable() { |
buoyqueue.add(new Runnable() { |
271 |
|
|
272 |
int c2fCS = vs.coords.ortho(0, 0, 0, 0, 10, 10); |
int c2fCS = vs.coords.ortho(0, 0, 0, 0, 10, 10); |
273 |
vs.matcher.addSub(mainctr, c2fCS, "C2F"); |
vs.matcher.addSub(mainctr, c2fCS, "C2F"); |
274 |
|
|
275 |
|
int[] coords = getCoords(context.getAccursed()); |
276 |
|
if(coords != null) { |
277 |
|
panx = coords[0]; |
278 |
|
pany = coords[1]; |
279 |
|
} |
280 |
setZoomPan(vs); |
setZoomPan(vs); |
281 |
pl.render(vs, frameCS, c2fCS); |
pl.render(vs, frameCS, c2fCS); |
282 |
|
|
294 |
int cs = m.getCS(main, "C2F"); |
int cs = m.getCS(main, "C2F"); |
295 |
vs.coords.setOrthoParams(cs, 0, -panx*zoom, -pany*zoom, zoom, zoom); |
vs.coords.setOrthoParams(cs, 0, -panx*zoom, -pany*zoom, zoom, zoom); |
296 |
} |
} |
297 |
|
|
298 |
|
/** Set the cursor of the given view context to the clicked point. |
299 |
|
* @param context The viewcontext whose accursed cell should be changed. |
300 |
|
* @return A map, to be used for the next generated vobscene's |
301 |
|
* DefaultVobMatcher.setKeyMap() method. |
302 |
|
*/ |
303 |
|
public Map setCursorTo(VobScene vs, float x, float y, ViewContext context) { |
304 |
|
// First, get the frame that was hit. |
305 |
|
// This gives the "frame" coordsys. |
306 |
|
int cs = vs.coords.getCSAt(0, x, y, null); |
307 |
|
if(cs < 0) { |
308 |
|
pa("No hit "+x+" "+y); |
309 |
|
return null; |
310 |
|
} |
311 |
|
if(!"frame".equals(vs.matcher.getKey(cs))) { |
312 |
|
pa("WRONG KEY! "+vs.matcher.getKey(cs)); |
313 |
|
return null; |
314 |
|
} |
315 |
|
// Get its parent |
316 |
|
int vp = ((GLVobCoorder)vs.coords).getParent(cs); |
317 |
|
Object key = vs.matcher.getKey(vp); |
318 |
|
if("MAINVP".equals(key)) { |
319 |
|
pa("Main viewport - no reaction yet"); |
320 |
|
return null; |
321 |
|
} |
322 |
|
if(! (key instanceof Pair)) { |
323 |
|
pa("Key is not pair!!! HELP "+key); |
324 |
|
return null; |
325 |
|
} |
326 |
|
Pair p = (Pair)key; |
327 |
|
Map r = new HashMap(); |
328 |
|
r.put("MAINVP", p); |
329 |
|
r.put(p, "MAINVP"); |
330 |
|
// Now, we have almost all the data. |
331 |
|
// But we need to figure out WHICH one of the cells in the Pair |
332 |
|
// is the one we are moving to. To do this, we have to look at |
333 |
|
// the parent coordinate systems. |
334 |
|
|
335 |
|
int tr12 = ((GLVobCoorder)vs.coords).getBuoyOnCircleAnchor(vp); // XXX... reverse of BFloater |
336 |
|
pa("tr12: "+tr12); |
337 |
|
pa(" "+vs.matcher.getKey(tr12)); |
338 |
|
|
339 |
|
int ausq = ((GLVobCoorder)vs.coords).getParent(tr12); |
340 |
|
pa("ausq: "+ausq); |
341 |
|
pa(" "+vs.matcher.getKey(ausq)); |
342 |
|
|
343 |
|
int anchor = ((GLVobCoorder)vs.coords).getParent(ausq); |
344 |
|
pa("anch: "+anchor); |
345 |
|
pa(" "+vs.matcher.getKey(anchor)); |
346 |
|
Object cell = vs.matcher.getKey(anchor); |
347 |
|
|
348 |
|
Object n; |
349 |
|
if(cell.equals(p.first)) n = p.second; |
350 |
|
else n = p.first; |
351 |
|
pa("New: "+n); |
352 |
|
|
353 |
|
((AbstractViewContext)context).setAccursed((Cell)n); |
354 |
|
|
355 |
|
return r; |
356 |
|
} |
357 |
} |
} |