26 |
|
|
27 |
package org.fenfire.view; |
package org.fenfire.view; |
28 |
import org.nongnu.libvob.*; |
import org.nongnu.libvob.*; |
29 |
|
import org.nongnu.libvob.impl.*; |
30 |
import org.nongnu.libvob.gl.*; |
import org.nongnu.libvob.gl.*; |
31 |
|
|
32 |
import java.util.*; |
import java.util.*; |
33 |
|
|
34 |
/** View2D to draw the selecting area |
/** View2D to draw the selecting area |
35 |
*/ |
*/ |
36 |
public class AreaSelectingView2D extends View2D |
public class AreaSelectingView2D extends View2D { |
|
implements org.fenfire.view.lava.FastView { |
|
37 |
public static boolean dbg = false; |
public static boolean dbg = false; |
38 |
private static void p(String s) { System.out.println("AreaSelectingView2D:: "+s); } |
private static void p(String s) { System.out.println("AreaSelectingView2D:: "+s); } |
39 |
|
|
42 |
private TextSelectionPainter text = new TextSelectionPainter(); |
private TextSelectionPainter text = new TextSelectionPainter(); |
43 |
private SelectionPainter currentPainter = rect; |
private SelectionPainter currentPainter = rect; |
44 |
|
|
45 |
private interface SelectionPainter extends org.fenfire.view.lava.FastView { |
|
46 |
|
/** An interface for selection shape painter. |
47 |
|
*/ |
48 |
|
private interface SelectionPainter { |
49 |
|
|
50 |
|
/** Render the selection into VobScene. |
51 |
|
* @param plane The object of View2D plane where |
52 |
|
* this selection is rendered. |
53 |
|
*/ |
54 |
void render(VobScene vs, int into); |
void render(VobScene vs, int into); |
55 |
|
|
56 |
|
/** Set coordinate system parameters for the selection. |
57 |
|
* @param plane The plane where this selection is rendered. |
58 |
|
* @param currentPlane |
59 |
|
* The current accursed plane object. |
60 |
|
* Selection should be shown if currentPlane |
61 |
|
* is same as the plane object. |
62 |
|
*/ |
63 |
|
void chgFast(VobScene old, int into, Object plane, |
64 |
|
Object currentPlane); |
65 |
|
|
66 |
|
/** Clears the selection. |
67 |
|
*/ |
68 |
void clear(); |
void clear(); |
69 |
} |
} |
70 |
|
|
83 |
for (int i=0; i<pts.length; i++) |
for (int i=0; i<pts.length; i++) |
84 |
renderImpl(vs, into, i); |
renderImpl(vs, into, i); |
85 |
} |
} |
86 |
private int renderImpl(VobScene vs, int into, int index) { |
private int renderImpl(VobScene vs, int into, int index) |
87 |
|
{ |
88 |
int cs = -1; |
int cs = -1; |
89 |
switch(index) { |
switch(index) { |
90 |
case 0: cs = vs.orthoCS(into, SELECT_BEGIN, 0, 1,2,3,4); break; |
case 0: cs = vs.orthoCS(into, SELECT_BEGIN, 0, 1,2,3,4); break; |
97 |
return cs; |
return cs; |
98 |
} |
} |
99 |
|
|
100 |
public void chgFast(VobScene oldVS, int concatCs) { |
public void chgFast(VobScene oldVS, int concatCs, |
101 |
|
Object plane, Object current) { |
102 |
int [] cs = new int[3]; |
int [] cs = new int[3]; |
103 |
cs[0] = oldVS.matcher.getCS(concatCs, SELECT_BEGIN); |
cs[0] = oldVS.matcher.getCS(concatCs, SELECT_BEGIN); |
104 |
cs[1] = oldVS.matcher.getCS(concatCs, SELECT_OTHER); |
cs[1] = oldVS.matcher.getCS(concatCs, SELECT_OTHER); |
110 |
cs[i] = renderImpl(oldVS, concatCs, i); |
cs[i] = renderImpl(oldVS, concatCs, i); |
111 |
} |
} |
112 |
|
|
113 |
for(int i=0; i<pts.length; i++) |
for(int i=0; i<pts.length; i++) { |
114 |
oldVS.coords.setOrthoParams(cs[i], 0, pts[i][0], pts[i][1], pts[i][2]-pts[i][0], pts[i][3]-pts[i][1]); |
if (plane == current) |
115 |
|
oldVS.coords.setOrthoParams(cs[i], 0, pts[i][0], pts[i][1], pts[i][2]-pts[i][0], pts[i][3]-pts[i][1]); |
116 |
|
else |
117 |
|
oldVS.coords.setOrthoParams(cs[i], 0, 0,0,0,0); |
118 |
|
} |
119 |
} |
} |
120 |
|
|
121 |
public void clear() { |
public void clear() { |
172 |
setArea(0,0,0,0); |
setArea(0,0,0,0); |
173 |
} |
} |
174 |
|
|
175 |
public void chgFast(VobScene oldVS, int concatCs) { |
public void chgFast(VobScene oldVS, int concatCs, |
176 |
|
Object plane, Object current) { |
177 |
int cs = oldVS.matcher.getCS(concatCs, SELECT); |
int cs = oldVS.matcher.getCS(concatCs, SELECT); |
178 |
if (cs < 1) throw new Error(cs+" is not possible!"); |
if (cs < 1) throw new Error(cs+" is not possible!"); |
179 |
oldVS.coords.setOrthoParams(cs, 0, x0, y0, x1-x0, y1-y0); |
|
180 |
|
if (plane == current) |
181 |
|
oldVS.coords.setOrthoParams(cs, 0, x0, y0, x1-x0, y1-y0); |
182 |
|
else |
183 |
|
oldVS.coords.setOrthoParams(cs, 0, 0,0,0,0); |
184 |
} |
} |
185 |
|
|
186 |
private float x0,y0,x1,y1; |
private float x0,y0,x1,y1; |
203 |
float ex, float eyTop, float eyBot, |
float ex, float eyTop, float eyBot, |
204 |
float edgeL, float edgeR) { |
float edgeL, float edgeR) { |
205 |
currentPainter = text; |
currentPainter = text; |
206 |
|
rect.clear(); |
207 |
text.set(bx,byTop, byBot, ex,eyTop,eyBot,edgeL, edgeR); |
text.set(bx,byTop, byBot, ex,eyTop,eyBot,edgeL, edgeR); |
208 |
} |
} |
209 |
public void setArea(float x0, float y0, float x1, float y1) { |
public void setArea(float x0, float y0, float x1, float y1) { |
210 |
currentPainter = rect; |
currentPainter = rect; |
211 |
|
text.clear(); |
212 |
rect.setArea(x0,y0,x1,y1); |
rect.setArea(x0,y0,x1,y1); |
213 |
} |
} |
214 |
|
|
245 |
paper2box); |
paper2box); |
246 |
|
|
247 |
currentPainter.render(vs, paper2screen); |
currentPainter.render(vs, paper2screen); |
248 |
if (current != plane) currentPainter.clear(); |
chgFast(vs, plane, matchingParent, box2screen, box2paper); |
|
chgFast(vs, box2screen); |
|
249 |
} |
} |
250 |
|
|
251 |
public void chgFast(VobScene oldVS, int parent) { |
public void clear() { |
252 |
if (dbg) p("NEW: parent: "+parent+" to make chgFast: "+oldVS.matcher.getKey(parent) |
text.clear(); |
253 |
+ " foo: "+ oldVS.matcher.getCS(oldVS.matcher.getKey(parent))); |
rect.clear(); |
254 |
|
} |
255 |
|
|
256 |
if (dbg) p("parent cs: "+parent); |
public void chgFast(VobScene oldVS, Object plane, |
257 |
int concatCs = oldVS.matcher.getCS(parent, CONCAT); |
int matchingParent, int box2screen, int box2plane) { |
258 |
|
if (dbg) p("box2screen: "+box2screen); |
259 |
|
int concatCs = oldVS.matcher.getCS(box2screen, CONCAT); |
260 |
if (dbg) p("conc: "+concatCs); |
if (dbg) p("conc: "+concatCs); |
261 |
currentPainter.chgFast(oldVS, concatCs); |
text.chgFast(oldVS, concatCs, plane, current); |
262 |
|
currentPainter.chgFast(oldVS, concatCs, plane, current); |
263 |
} |
} |
264 |
|
|
265 |
public Object getSelectedObject(Object plane, float x, float y, float w, float h) { |
public Object getSelectedObject(Object plane, float x, float y, float w, float h) { |