Revision 15473 import/ext3D/branches/ext3D_v1.1/libAnimation/src/com/iver/cit/gvsig/animation/AnimationPlayer.java
AnimationPlayer.java | ||
---|---|---|
20 | 20 |
public class AnimationPlayer extends TimerTask implements IUpdateCallBack, |
21 | 21 |
IPersistance { |
22 | 22 |
|
23 |
public AnimationPlayer() { |
|
24 |
|
|
25 |
} |
|
26 |
|
|
27 | 23 |
public static int ANIMATION_PLAY = 0; |
28 | 24 |
|
29 | 25 |
public static int ANIMATION_STOP = 1; |
... | ... | |
36 | 32 |
|
37 | 33 |
public static int LOOP_FORWARD = 1; |
38 | 34 |
|
35 |
public static int PLAY_ONCE = 2; |
|
36 |
|
|
39 | 37 |
private AnimationContainer animationContainer; |
40 | 38 |
|
41 | 39 |
private int mode; |
... | ... | |
50 | 48 |
|
51 | 49 |
private double preTime = 0.0; |
52 | 50 |
|
53 |
private double globalTime; |
|
54 |
|
|
51 |
private static double globalTime;
|
|
52 |
|
|
55 | 53 |
private double auxTime; |
56 | 54 |
|
57 |
private double time = 0.0; |
|
55 |
private static double time = 0.0;
|
|
58 | 56 |
|
59 | 57 |
private AnimationTimer AT; |
60 | 58 |
|
... | ... | |
71 | 69 |
|
72 | 70 |
private static Animation3D a3D; |
73 | 71 |
|
72 |
private int animationMode = PLAY_ONCE; |
|
73 |
|
|
74 |
private boolean first = true; |
|
75 |
|
|
76 |
public AnimationPlayer() { |
|
77 |
} |
|
78 |
|
|
74 | 79 |
public void play() { |
75 | 80 |
|
76 | 81 |
if (animationPlayerState != AnimationPlayer.ANIMATION_PLAY) { |
... | ... | |
117 | 122 |
} |
118 | 123 |
AT.end(); |
119 | 124 |
this.time = 0; |
125 |
AnimationPlayer.occupied = false; |
|
120 | 126 |
} |
121 | 127 |
|
122 | 128 |
public void pause() { |
... | ... | |
138 | 144 |
} |
139 | 145 |
AT.end(); |
140 | 146 |
pauseFlag = true; |
147 |
AnimationPlayer.occupied = false; |
|
141 | 148 |
} |
142 | 149 |
|
143 | 150 |
public void record() { |
... | ... | |
369 | 376 |
// if the delay could be hightest than the frequency, we have |
370 | 377 |
// had |
371 | 378 |
// increased the time with this delay |
372 |
if ((delay > animationFrequency) && (!pauseFlag)) |
|
373 |
time += delay; |
|
374 |
else |
|
375 |
time += animationFrequency; |
|
379 |
if ((this.getAnimationMode() == PLAY_ONCE) |
|
380 |
|| (this.getAnimationMode() == LOOP)) { |
|
381 |
if ((delay > animationFrequency) && (!pauseFlag)) |
|
382 |
time += delay; |
|
383 |
else |
|
384 |
time += animationFrequency; |
|
385 |
if (this.getAnimationMode() == PLAY_ONCE) { |
|
386 |
if (time == this.getGlobalTime()){ |
|
387 |
occupied = false; |
|
388 |
stop(); |
|
389 |
} |
|
390 |
} else |
|
391 |
time = (time > this.getGlobalTime()) ? 0 : time; |
|
392 |
|
|
393 |
} |
|
376 | 394 |
// time += (delay > animationFrequency) ? delay : |
377 | 395 |
// animationFrequency; |
378 | 396 |
|
379 |
// System.out.println("tiempo: " + time);
|
|
380 |
time = (time > this.getGlobalTime()) ? 0 : time; |
|
397 |
// System.out.println("tiempo: " + time);
|
|
398 |
// time = (time > this.getGlobalTime()) ? 0 : time;
|
|
381 | 399 |
|
382 | 400 |
// Apply and repaint all tracks. |
383 | 401 |
apply(time / this.getGlobalTime(), 0); |
... | ... | |
401 | 419 |
System.out.println("ocupado : " + occupied); |
402 | 420 |
} |
403 | 421 |
|
404 |
/* |
|
422 |
public static double getCurrentTime() { |
|
423 |
return time; |
|
424 |
} |
|
425 |
|
|
426 |
/* |
|
405 | 427 |
* IPersistance methods. |
406 | 428 |
*/ |
407 |
|
|
429 |
|
|
408 | 430 |
public String getClassName() { |
409 | 431 |
// TODO Auto-generated method stub |
410 | 432 |
return this.getClass().getName(); |
... | ... | |
419 | 441 |
xml.putProperty("framerate",frameRate); |
420 | 442 |
|
421 | 443 |
return xml; |
422 |
|
|
444 |
|
|
423 | 445 |
} |
424 | 446 |
|
425 | 447 |
public void setXMLEntity(XMLEntity xml) { |
... | ... | |
429 | 451 |
if (xml.contains("class_name")) |
430 | 452 |
className = xml.getStringProperty("class_name"); |
431 | 453 |
if (xml.contains("mode")) |
432 |
mode = xml.getIntProperty("mode");
|
|
454 |
mode = xml.getIntProperty("mode"); |
|
433 | 455 |
if (xml.contains("length")) |
434 | 456 |
globalTime = xml.getDoubleProperty("length"); |
435 | 457 |
if (xml.contains("framerate")) |
436 | 458 |
frameRate = xml.getIntProperty("framerate"); |
437 |
|
|
459 |
|
|
438 | 460 |
} |
461 |
|
|
462 |
public int getAnimationMode() { |
|
463 |
return animationMode; |
|
464 |
} |
|
465 |
|
|
466 |
public void setAnimationMode(int animationMode) { |
|
467 |
this.animationMode = animationMode; |
|
468 |
} |
|
469 |
|
|
470 |
public long getAnimationFrequency() { |
|
471 |
return animationFrequency; |
|
472 |
} |
|
473 |
|
|
474 |
public void setAnimationFrequency(long animationFrequency) { |
|
475 |
this.animationFrequency = animationFrequency; |
|
476 |
} |
|
439 | 477 |
} |
Also available in: Unified diff