4 |
import gzz.modules.pp.vob.*; |
import gzz.modules.pp.vob.*; |
5 |
import gzz.gfx.gl.*; |
import gzz.gfx.gl.*; |
6 |
import gzz.vob.*; |
import gzz.vob.*; |
7 |
|
import gzz.vob.impl.*; |
8 |
|
import gzz.vob.buoy.*; |
9 |
import gzz.view.*; |
import gzz.view.*; |
10 |
import gzz.*; |
import gzz.*; |
11 |
import java.awt.Dimension; |
import java.awt.Dimension; |
12 |
import gzz.client.GraphicsAPI; |
import gzz.client.GraphicsAPI; |
13 |
|
import gzz.util.Pair; |
14 |
|
|
15 |
public class PPView2 implements View { |
public class PPView2 implements View { |
16 |
|
|
17 |
|
// Geometry |
18 |
|
|
19 |
|
/** The width of the main view. |
20 |
|
*/ |
21 |
|
public float mainWidth = 600; |
22 |
|
|
23 |
|
/** The width of the left edge panel. |
24 |
|
*/ |
25 |
|
public float leftPanelWidth = 100; |
26 |
|
|
27 |
|
/** The height of the main view. |
28 |
|
*/ |
29 |
|
public float mainHeight = 600; |
30 |
|
|
31 |
|
/** The Y position of the main view. |
32 |
|
*/ |
33 |
|
public float mainY = 100; |
34 |
|
|
35 |
|
/** Buoy floater settings. |
36 |
|
*/ |
37 |
|
public float buoyCenterY = 400, buoyRadius = 400; |
38 |
|
|
39 |
|
/** Buoy viewport geometry. |
40 |
|
*/ |
41 |
|
public float buoyVPWidth = 400, buoyVPHeight = 400; |
42 |
|
|
43 |
|
/** The center of the visible area. |
44 |
|
*/ |
45 |
|
float centerX(VobScene vs) { return (vs.size.width-leftPanelWidth)/2; } |
46 |
|
|
47 |
|
// Current state |
48 |
|
|
49 |
/** The current zoom. |
/** The current zoom. |
50 |
* Pixels for 1 paper coordinate unit. |
* Pixels for 1 paper coordinate unit. |
51 |
*/ |
*/ |
55 |
*/ |
*/ |
56 |
public float panx=0, pany=0; |
public float panx=0, pany=0; |
57 |
|
|
58 |
|
/** The zoom to be used for the buoys. |
59 |
|
*/ |
60 |
|
public float buoyZoom = 1; |
61 |
|
|
62 |
/** The scale of the background. |
/** The scale of the background. |
63 |
* bgscale in paper coordinates = 1 in background coords. |
* bgscale in paper coordinates = 1 in background coords. |
64 |
*/ |
*/ |
83 |
|
|
84 |
CoordinatePlaneView coordinatePlaneView; |
CoordinatePlaneView coordinatePlaneView; |
85 |
|
|
86 |
|
AbstractViewContext buoy_vc = new AbstractViewContext(); |
87 |
|
SinglePlane buoy_singlePlane; |
88 |
|
|
89 |
GraphicsAPI.Window window; |
GraphicsAPI.Window window; |
90 |
|
|
91 |
/** A single PP plane, with given view context. |
/** A single PP plane, with given view context. |
168 |
} |
} |
169 |
} |
} |
170 |
|
|
171 |
|
|
172 |
|
class BFloater implements Cell1DBuoyHook.Floater { |
173 |
|
int dir; |
174 |
|
VobScene vs; |
175 |
|
Buoy4Floater floater; |
176 |
|
BFloater(int dir, VobScene vs) { |
177 |
|
this.dir = dir; |
178 |
|
this.vs = vs; |
179 |
|
floater = new CircleFloater4(vs, 0, |
180 |
|
centerX(vs), buoyCenterY, buoyRadius, |
181 |
|
centerX(vs) - dir * buoyRadius, buoyCenterY); |
182 |
|
} |
183 |
|
public void buoy(int anchor, Cell c, Cell connectedFrom) { |
184 |
|
Object key ; |
185 |
|
if(dir > 0) |
186 |
|
key = new Pair(connectedFrom, c); |
187 |
|
else |
188 |
|
key = new Pair(c, connectedFrom); |
189 |
|
int actr = vs.translateCS(vs.unitSqCS(anchor, "AUSQ"), "TR12", |
190 |
|
.5f, .5f); |
191 |
|
int buoycs = floater.buoyCoordsys(actr, key); |
192 |
|
|
193 |
|
int frameCS = vs.orthoBoxCS(buoycs, "frame", 0, |
194 |
|
-buoyVPWidth/2, -buoyVPHeight, 1, 1, |
195 |
|
buoyVPWidth, buoyVPHeight); |
196 |
|
// XXX Pan |
197 |
|
int c2fCS = vs.coords.ortho(0, 0, 0, 0, buoyZoom, buoyZoom); |
198 |
|
vs.matcher.addSub(buoycs, c2fCS, "C2F"); |
199 |
|
|
200 |
|
buoy_vc.setAccursed(c); |
201 |
|
buoy_singlePlane.render(vs, frameCS, c2fCS); |
202 |
|
} |
203 |
|
} |
204 |
|
|
205 |
public PPView2(Space space, GraphicsAPI.Window w) { |
public PPView2(Space space, GraphicsAPI.Window w) { |
206 |
this.space = space; |
this.space = space; |
207 |
this.d = new PPDims(space); |
this.d = new PPDims(space); |
210 |
} |
} |
211 |
|
|
212 |
public void render(VobScene vs, int intoCS, ViewContext context) { |
public void render(VobScene vs, int intoCS, ViewContext context) { |
|
AbstractViewContext vc = new AbstractViewContext(); |
|
|
vc.setAccursed(context.getAccursed()); |
|
213 |
TextStyle style = vs.gfxapi.getTextStyle("Sans", 0, 20); |
TextStyle style = vs.gfxapi.getTextStyle("Sans", 0, 20); |
214 |
vc.setCellView(new TextCellContentView(style)); |
CellInBox cellview = new TextCellContentView(style); |
215 |
|
|
216 |
|
buoy_vc.setCellView(cellview); |
217 |
|
|
218 |
|
buoy_singlePlane = new SinglePlane(); |
219 |
|
buoy_singlePlane.context = buoy_vc; |
220 |
|
|
221 |
|
BFloater leftFloater = new BFloater(-1, vs); |
222 |
|
BFloater rightFloater = new BFloater(1, vs); |
223 |
|
|
224 |
|
AbstractViewContext main_vc = new AbstractViewContext(); |
225 |
|
main_vc.setAccursed(context.getAccursed()); |
226 |
|
|
227 |
|
main_vc.setCellView( |
228 |
|
new CellInBoxPlugin(cellview, |
229 |
|
new Cell1DBuoyHook(leftFloater, rightFloater, |
230 |
|
d.clone, d.association))); |
231 |
|
|
232 |
Dimension size = vs.getSize(); |
Dimension size = vs.getSize(); |
233 |
|
|
234 |
SinglePlane pl = new SinglePlane(); |
SinglePlane pl = new SinglePlane(); |
235 |
pl.context = vc; |
pl.context = main_vc; |
236 |
|
|
237 |
int frameCS = vs.orthoBoxCS(0, "frame", 0, 100, 100, 1, 1, 400, 400); |
int mainctr = ((GLVobCoorder)vs.coords).affineCoordsys(0, 0, |
238 |
|
centerX(vs), mainY + mainHeight/2, |
239 |
|
1, 0, 0, 1); |
240 |
|
vs.matcher.add(mainctr, "MAINVP"); |
241 |
|
|
242 |
|
int frameCS = vs.orthoBoxCS(mainctr, "frame", 0, |
243 |
|
(-mainWidth)/2, -mainHeight/2, 1, 1, |
244 |
|
mainWidth, mainHeight); |
245 |
|
|
246 |
int c2fCS = vs.orthoCS(0, "C2F", 0, 0, 0, 10, 10); |
int c2fCS = vs.coords.ortho(0, 0, 0, 0, 10, 10); |
247 |
|
vs.matcher.addSub(mainctr, c2fCS, "C2F"); |
248 |
setZoomPan(vs); |
setZoomPan(vs); |
249 |
pl.render(vs, frameCS, c2fCS); |
pl.render(vs, frameCS, c2fCS); |
250 |
|
|
255 |
* This changes the parameters of the coordinate systems created by render(). |
* This changes the parameters of the coordinate systems created by render(). |
256 |
*/ |
*/ |
257 |
public void setZoomPan(VobScene vs) { |
public void setZoomPan(VobScene vs) { |
258 |
int cs = vs.matcher.getCS("C2F"); |
DefaultVobMatcher m = (DefaultVobMatcher)vs.matcher; |
259 |
|
int main = m.getCS("MAINVP"); |
260 |
|
int cs = m.getCS(main, "C2F"); |
261 |
vs.coords.setOrthoParams(cs, 0, -panx*zoom, -pany*zoom, zoom, zoom); |
vs.coords.setOrthoParams(cs, 0, -panx*zoom, -pany*zoom, zoom, zoom); |
262 |
} |
} |
263 |
} |
} |