245 |
* 50, 1,1, 100,100) |
* 50, 1,1, 100,100) |
246 |
* self.windowAnimation.rerender() |
* self.windowAnimation.rerender() |
247 |
* </li><li> |
* </li><li> |
248 |
* Example: Quite a difficult example where we start to drag |
* Example: Quite a difficult example where we start to drag |
249 |
* red box around the scene that may end to be yellow one. |
* red box around the scene that may end to be yellow one. |
250 |
* Point of the example is to use both rerendering of one |
* Point of the example is to use both rerendering of one |
251 |
* scene and switching to scene. |
* scene and switching of scene. |
252 |
* |
* <p> |
253 |
|
* The main problem in example is that when handling mouse event you |
254 |
|
* don't know what is it in the current window: a yellow or red |
255 |
|
* box. We try to guess *the position of the moon* from previous |
256 |
|
* event if we even have a one. |
257 |
|
* |
258 |
* <pre> |
* <pre> |
259 |
* class Scene: |
* class Scene: |
260 |
* """ Example scene to drag the red or yellow box around. |
* """ Example scene to drag the red or yellow box around. |
261 |
* In left the box is red but in right it is yellow. |
* In left the box is red but in right it is yellow. |
262 |
* """ |
* """ |
263 |
* def __init__(self, windowAnimation): |
* def __init__(self, windowAnimation): |
264 |
* self.windowAnimation = windowAnimation |
* self.windowAnimation = windowAnimation |
265 |
* self.half = 300 |
* self.half = 300 |
266 |
* self.ev = None |
* self.ev = None |
267 |
* def scene(self, vs): |
* def scene(self, vs): |
268 |
* # this is an event grabbing example. |
* # this is an event grabbing example, really. |
269 |
* pass |
* self.evenrGrabberDraw(vs) |
270 |
* def mouse(self, ev): |
* def eventGrabberDraw(self, vs): |
271 |
* if self.ev = None: self.ev = ev |
* if self.ev != None: |
272 |
|
* cs = vs.orthoBoxCS(0, "Box", 0, |
273 |
|
* self.ev.getX(),self.ev.getY(), 1,1, 100,100) |
274 |
|
* else: |
275 |
|
* cs = vs.orthoBoxCS(0, "Box", 0,10,10, 1,1, 100,100) |
276 |
|
* if self.ev.getX() < self.half: |
277 |
|
* vs.put(vob.vobs.RectBgVob(java.awt.Color.red), cs) |
278 |
|
* else: |
279 |
|
* vs.put(vob.vobs.RectBgVob(java.awt.Color.yellow), cs) |
280 |
|
* def mouse(self, ev): |
281 |
|
* if self.ev == None: self.ev = ev |
282 |
* vs = self.windowAnimation.getCurrentVS() |
* vs = self.windowAnimation.getCurrentVS() |
|
* if vs.matcher.getCS(0, "Box") < 1: |
|
|
* cs = vs.orthoBoxCS(0, "Box", 0,ev.getX(),ev.getY(), |
|
|
* 1,1, 100,100) |
|
|
* if ev.getX() < self.half: |
|
|
* vs.put(vob.vobs.RectBgVob(java.awt.Color.red), cs) |
|
|
* else: |
|
|
* vs.put(vob.vobs.RectBgVob(java.awt.Color.yellow), cs) |
|
283 |
* cs = vs.matcher.getCS(0, "Box") |
* cs = vs.matcher.getCS(0, "Box") |
284 |
* if self.ev.getX() < self.half and ev.getX() < self.half: |
* if self.ev.getX() < self.half and ev.getX() < self.half: |
285 |
* vs.coords.setOrthoBoxParams(cs, 0,ev.getX(),ev.getY(), |
* vs.coords.setOrthoBoxParams(cs, 0,ev.getX(),ev.getY(), |
286 |
* 1,1, 100,100) |
* 1,1, 100,100) |
287 |
* if not self.windowAnimation.hasSceneReplacementPending(): |
* if not self.windowAnimation.hasSceneReplacementPending(): |
288 |
* self.windowAnimation.rerender() |
* self.windowAnimation.rerender() |
289 |
* elif self.ev.getX() > self.half and ev.getX() > self.half: |
* elif self.ev.getX() > self.half and ev.getX() > self.half: |
290 |
* vs.coords.setOrthoBoxParams(cs, 0,self.right, |
* vs.coords.setOrthoBoxParams(cs, 0,ev.getX(),ev.getY(), |
291 |
* 50, 1,1, 100,100) |
* 1,1, 100,100) |
292 |
* if not self.windowAnimation.hasSceneReplacementPending(): |
* if not self.windowAnimation.hasSceneReplacementPending(): |
293 |
* self.windowAnimation.rerender() |
* self.windowAnimation.rerender() |
294 |
* else: |
* else: |
295 |
* self.windowAnimation.switchVS() |
* self.windowAnimation.switchVS() |
296 |
* self.ev = ev |
* self.ev = ev |
297 |
* </li> </ol> |
* </li> </ol> |
298 |
*/ |
*/ |
299 |
public interface WindowAnimation { |
public interface WindowAnimation { |