27 |
private static void p(String s) { if (dbg) pa(s); } |
private static void p(String s) { if (dbg) pa(s); } |
28 |
private static void pa(String s) { System.out.println("PPCanvasCursor::"+s); } |
private static void pa(String s) { System.out.println("PPCanvasCursor::"+s); } |
29 |
|
|
|
// Geometry |
|
|
|
|
|
/** The width of the main view. |
|
|
*/ |
|
|
public float mainWidth = 600; |
|
|
|
|
|
/** The width of the left edge panel. |
|
|
*/ |
|
|
public float leftPanelWidth = 100; |
|
|
|
|
|
/** The height of the entries in the left edge panel. |
|
|
*/ |
|
|
public float leftPanelObjectHeight = 100; |
|
|
|
|
|
/** The "over-size" of the entries in the left panel |
|
|
*/ |
|
|
public float leftPanelRealHeight = 170, |
|
|
leftPanelRealWidth = 230; |
|
|
|
|
|
/** The zoom in the left panel |
|
|
*/ |
|
|
public float leftPanelZoom = .8f; |
|
|
|
|
|
/** The height of the main view. |
|
|
*/ |
|
|
public float mainHeight = 600; |
|
|
|
|
|
/** The Y position of the main view. |
|
|
*/ |
|
|
public float mainY = 100; |
|
|
|
|
|
/** Buoy floater settings. |
|
|
*/ |
|
|
public float buoyCenterY = 400, buoyRadius = 400; |
|
|
|
|
|
/** Buoy viewport geometry. |
|
|
*/ |
|
|
public float buoyVPWidth = 400, buoyVPHeight = 400; |
|
|
|
|
|
/** Link buoy viewport geometry. |
|
|
*/ |
|
|
public float linkbuoyVPWidth = 200, linkbuoyVPHeight = 100; |
|
|
|
|
|
/** The zoom to be used for the buoys. |
|
|
*/ |
|
|
public float buoyZoom = 1; |
|
|
|
|
|
/** The zoom to be used for the link creation buoys. |
|
|
*/ |
|
|
public float linkbuoyZoom = .5f; |
|
|
|
|
|
|
|
|
// Current state |
|
30 |
|
|
31 |
/** The current zoom. |
/** The current zoom. |
32 |
* Pixels for 1 paper coordinate unit. |
* Pixels for 1 paper coordinate unit. |
110 |
pt[1]+size[1]/2, |
pt[1]+size[1]/2, |
111 |
size[0]/10, |
size[0]/10, |
112 |
size[1]/10); |
size[1]/10); |
113 |
vs.put(new LineVob(0,0,0,1, java.awt.Color.white), cursor); |
vs.put(new LineVob(0,0,0,1, java.awt.Color.yellow), cursor); |
114 |
p("Cursor"); |
p("Cursor"); |
115 |
} |
} |
116 |
|
|
117 |
if (GraphicsAPI.getInstance() instanceof GLAPI) { |
// Create the coordinate systems for the viewport. |
118 |
|
// c2fCS = Canvas to frame, i.e. |
119 |
// Create the coordinate systems for the viewport. |
// the transformation from canvas coordinates |
120 |
// c2fCS = Canvas to frame, i.e. |
// to frame coordinates. Used for panning and zooming. |
121 |
// the transformation from canvas coordinates |
// |
122 |
// to frame coordinates. Used for panning and zooming. |
// The parameters for coordinate systems are set in setZoomPan: |
123 |
// |
// the numbers "42" below are placeholders which get replaced |
124 |
// The parameters for coordinate systems are set in setZoomPan: |
// by the setOrthoParams code in setZoomPan |
125 |
// the numbers "42" below are placeholders which get replaced |
// |
126 |
// by the setOrthoParams code in setZoomPan |
// Now, it is important that it is |
127 |
// |
// 1) transformation-descended from 0, since it is |
128 |
// Now, it is important that it is |
// just the pan-zoom part |
129 |
// 1) transformation-descended from 0, since it is |
c2fCS = vs.coords.ortho(0, 42, 42, 42, 42, 42); |
130 |
// just the pan-zoom part |
// 2) Child of "into", for correct interpolation. |
131 |
c2fCS = vs.coords.ortho(0, 42, 42, 42, 42, 42); |
// The canvas-to-frame coordinate system should |
132 |
// 2) Child of "into", for correct interpolation. |
// only be interpolated to another canvas-to-frame |
133 |
// The canvas-to-frame coordinate system should |
// cs IF their frames are interpolated into each other, |
134 |
// only be interpolated to another canvas-to-frame |
// which is what this does. |
135 |
// cs IF their frames are interpolated into each other, |
vs.matcher.add(into, c2fCS, "C2F"); |
136 |
// which is what this does. |
|
137 |
vs.matcher.add(into, c2fCS, "C2F"); |
// The inverse of the previous transform; same |
138 |
|
// rules apply. |
139 |
// The inverse of the previous transform; same |
int c2fCSInv = vs.coords.ortho(0, 42, 42, 42, 42, 42); |
140 |
// rules apply. |
vs.matcher.add(into, c2fCSInv, "C2FINV"); |
141 |
int c2fCSInv = vs.coords.ortho(0, 42, 42, 42, 42, 42); |
|
142 |
vs.matcher.add(into, c2fCSInv, "C2FINV"); |
setZoomPan(vs, into); |
143 |
|
SinglePaper.i().render(node,vs, into, c2fCS, c2fCSInv, hook); |
|
setZoomPan(vs, into); |
|
|
SinglePaper.i(fen, node, window, nodeview) |
|
|
.render(vs, into, c2fCS, c2fCSInv, hook); |
|
|
|
|
|
} else { |
|
|
int zo = (int)(zoom * 100000); |
|
|
int geometry = vs.orthoBoxCS(into, "FocusGeometry",0, zo,0, 1,1, -panx, -pany); |
|
|
|
|
|
vs.map.put(new UniquePaperVob(paper.toString()), into, geometry); |
|
|
(new SpatialPlane(PP.Note, PP.contains)).renderAWT(vs, into, geometry, |
|
|
node, nodeview, fen ,hook); |
|
|
} |
|
144 |
} |
} |
145 |
|
|
146 |
public void keystroke(String s) |
public void keystroke(String s) |
186 |
zoom = m_state_zoom * (float) |
zoom = m_state_zoom * (float) |
187 |
Math.exp((m_state[1] - e.getY())/150.0); |
Math.exp((m_state[1] - e.getY())/150.0); |
188 |
AbstractUpdateManager.setNoAnimation(); |
AbstractUpdateManager.setNoAnimation(); |
189 |
if (GraphicsAPI.getInstance() instanceof GLAPI) { |
setZoomPan(oldVobScene, focusFrame); |
190 |
setZoomPan(oldVobScene, focusFrame); |
return true; |
|
return true; |
|
|
} else { |
|
|
AbstractUpdateManager.chg(); |
|
|
return false; |
|
|
} |
|
191 |
} |
} |
192 |
|
|
193 |
// Move by dragging with button 1 |
// Move by dragging with button 1 |
195 |
panx = pan[0] + (m_state[0] - e.getX())/zoom; |
panx = pan[0] + (m_state[0] - e.getX())/zoom; |
196 |
pany = pan[1] + (m_state[1] - e.getY())/zoom; |
pany = pan[1] + (m_state[1] - e.getY())/zoom; |
197 |
|
|
198 |
if (GraphicsAPI.getInstance() instanceof GLAPI) { |
setZoomPan(oldVobScene, focusFrame); |
199 |
setZoomPan(oldVobScene, focusFrame); |
return true; |
|
return true; |
|
|
} else { |
|
|
AbstractUpdateManager.chg(); |
|
|
return false; |
|
|
} |
|
200 |
} |
} |
201 |
|
|
202 |
// Move around by clicking |
// Move around by clicking |
204 |
|
|
205 |
float[] pt = new float[] { e.getX(), e.getY(), 0 }; |
float[] pt = new float[] { e.getX(), e.getY(), 0 }; |
206 |
|
|
207 |
if (GraphicsAPI.getInstance() instanceof GLAPI) { |
// We must transform into Frame, and then the C2F coordinate system |
208 |
|
int mainctrCS = ((DefaultVobMatcher)oldVobScene.matcher).getCS(0, "FocusCenter"); |
209 |
// We must transform into Frame, and then the C2F coordinate system |
//pa("mainctr"+ mainctrCS); |
|
int mainctrCS = ((DefaultVobMatcher)oldVobScene.matcher).getCS(0, "FocusCenter"); |
|
|
//pa("mainctr"+ mainctrCS); |
|
210 |
|
|
211 |
int frame = ((DefaultVobMatcher)oldVobScene.matcher).getCS(mainctrCS, "FocusFrame"); |
int frame = ((DefaultVobMatcher)oldVobScene.matcher).getCS(mainctrCS, "FocusFrame"); |
212 |
//int frame = focusFrame; |
//int frame = focusFrame; |
213 |
int c2f = ((DefaultVobMatcher)oldVobScene.matcher).getCS(frame, "C2F"); |
int c2f = ((DefaultVobMatcher)oldVobScene.matcher).getCS(frame, "C2F"); |
214 |
if (c2f < 0) c2f = c2fCS; |
if (c2f < 0) c2f = c2fCS; |
215 |
if(frame < 0 || c2f < 0) |
if(frame < 0 || c2f < 0) |
216 |
throw new Error("No cs point!"+frame+" "+c2f); |
throw new Error("No cs point!"+frame+" "+c2f); |
217 |
|
|
218 |
// XXX vp, not frame! |
// XXX vp, not frame! |
219 |
oldVobScene.coords.inverseTransformPoints3(mainctrCS, pt, pt); |
oldVobScene.coords.inverseTransformPoints3(mainctrCS, pt, pt); |
220 |
//oldVobScene.coords.inverseTransformPoints3(frame, pt, pt); |
//oldVobScene.coords.inverseTransformPoints3(frame, pt, pt); |
221 |
oldVobScene.coords.inverseTransformPoints3(c2f, pt, pt); |
oldVobScene.coords.inverseTransformPoints3(c2f, pt, pt); |
222 |
panx = pt[0]; pany = pt[1]; |
panx = pt[0]; pany = pt[1]; |
223 |
|
|
224 |
// XXX current = current.h(d.contains); |
// XXX current = current.h(d.contains); |
225 |
//setZoomPan(oldVobScene, focusFrame); |
//setZoomPan(oldVobScene, focusFrame); |
226 |
return false; |
AbstractUpdateManager.chg(); |
227 |
} else { |
return false; |
|
int focusFrame = oldVobScene.matcher.getCS("FocusFrame"); |
|
|
float box[] = new float[3]; |
|
|
box = oldVobScene.coords.transformPoints3(focusFrame, box, null); |
|
|
float size[] = new float[2]; |
|
|
oldVobScene.coords.getSqSize(focusFrame, size); |
|
|
panx += ((pt[0] - box[0]) - size[0]/2)/ zoom; |
|
|
pany += ((pt[1] - box[1]) - size[1]/2)/ zoom; |
|
|
|
|
|
// XXX current = current.h(d.contains); |
|
|
} |
|
228 |
} |
} |
229 |
AbstractUpdateManager.chg(); |
|
230 |
|
p("nothing!"); |
231 |
return false; |
return false; |
232 |
} |
} |
233 |
|
|