1 |
// (c) Tuomas J. Lukka |
// (c) Tuomas J. Lukka |
2 |
|
|
3 |
package org.fenfire.view.buoy; |
package org.fenfire.view.buoy; |
4 |
|
import java.util.Iterator; |
5 |
import org.fenfire.*; |
import org.fenfire.*; |
6 |
import org.fenfire.swamp.*; |
import org.fenfire.swamp.*; |
7 |
import org.fenfire.view.*; |
import org.fenfire.view.*; |
15 |
import org.nongnu.alph.*; |
import org.nongnu.alph.*; |
16 |
|
|
17 |
/** A Buoy connector for TreeTime. |
/** A Buoy connector for TreeTime. |
18 |
|
* XXX Generalize to general page / block relation! |
19 |
|
* Note that this connector gives a null anchor. |
20 |
*/ |
*/ |
21 |
public class TTConnector implements BuoyViewConnector { |
public class TTConnector implements BuoyViewConnector { |
22 |
public static boolean dbg = false; |
public static boolean dbg = false; |
23 |
private static void p(String s) { System.out.println("TTConnector:: "+s); } |
private static void p(String s) { System.out.println("TTConnector:: "+s); } |
24 |
|
|
25 |
|
private Fen fen; |
26 |
|
private Object relation; |
27 |
|
|
28 |
|
public AbstractNodeType2D pageImageScrollNodeType; |
29 |
|
public AbstractNodeType2D normalNodeNodeType; |
30 |
|
|
31 |
|
public TTConnector(Fen fen, Object relation) { |
32 |
|
this.fen = fen; |
33 |
|
this.relation = relation; |
34 |
|
} |
35 |
|
|
36 |
|
private void addBuoy(VobScene vs, Object node, int direction, |
37 |
|
BuoyLinkListener l) { |
38 |
|
String s = Nodes.toString(node); |
39 |
|
if(s.startsWith("urn:x-storm:1.0:application/pdf") || |
40 |
|
s.startsWith("urn:x-storm:1.0:application/postscript")) { |
41 |
|
if(dbg) p("Got "+s+" was pagescroll " + direction); |
42 |
|
} else { |
43 |
|
if(dbg) p("Got "+s+" was plane " + direction); |
44 |
|
} |
45 |
|
} |
46 |
|
|
47 |
public void addBuoys(VobScene vs, int parentCs, |
public void addBuoys(VobScene vs, int parentCs, |
48 |
BuoyViewMainNode mainNode0, |
BuoyViewMainNode mainNode0, |
49 |
BuoyLinkListener l) { |
BuoyLinkListener l) { |
55 |
// 1) a PageScrollBlock, or |
// 1) a PageScrollBlock, or |
56 |
// 2) a canvas. |
// 2) a canvas. |
57 |
|
|
58 |
|
Object node; |
59 |
|
|
60 |
if(plane instanceof PageScrollBlock) { |
if(plane instanceof PageScrollBlock) { |
61 |
PageScrollBlock sb = (PageScrollBlock)plane; |
PageScrollBlock sb = (PageScrollBlock)plane; |
62 |
if(dbg) p("Scrollblock: "+sb.getID()); |
if(dbg) p("Scrollblock: "+sb.getID()); |
63 |
|
node = Nodes.get(sb.getID()); |
64 |
} else { |
} else { |
65 |
if(dbg) p("Plane: "+plane); |
if(dbg) p("Plane: "+plane); |
66 |
|
node = plane; |
67 |
|
} |
68 |
|
|
69 |
|
for( |
70 |
|
Iterator ileft = fen.constgraph.findN_11X_Iter(node, relation); |
71 |
|
ileft.hasNext();) { |
72 |
|
Object linknode = ileft.next(); |
73 |
|
addBuoy(vs, linknode, -1, l); |
74 |
} |
} |
75 |
|
|
76 |
|
|
77 |
|
for( |
78 |
|
Iterator iright = fen.constgraph.findN_X11_Iter(relation, node); |
79 |
|
iright.hasNext();) { |
80 |
|
Object linknode = iright.next(); |
81 |
|
addBuoy(vs, linknode, 1, l); |
82 |
|
} |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
} |
} |
87 |
} |
} |