Revision 18571 trunk/libraries/libAnimation/src/com/iver/cit/gvsig/animation/AnimationPlayer.java
AnimationPlayer.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
private AnimationContainer animationContainer; |
34 | 34 |
|
35 |
private int frameRate; |
|
35 |
private int frameRate = 30;
|
|
36 | 36 |
|
37 | 37 |
private int animationPlayerState; //initial, play, pause, stop. |
38 | 38 |
|
... | ... | |
78 | 78 |
if (AT.isAlive() == false){ |
79 | 79 |
AT = new AnimationTimer(); |
80 | 80 |
AT.addCallBackObject(this); |
81 |
AT.start(animationFrequency);
|
|
81 |
AT.start(frameRate);
|
|
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
//Initial time control, backward animation: initial time = end time, forward animation: initial time = 0. |
... | ... | |
138 | 138 |
} |
139 | 139 |
} |
140 | 140 |
|
141 |
/** |
|
142 |
* Set of our player frequency. |
|
143 |
* |
|
144 |
* @param animationFrequency |
|
145 |
*/ |
|
146 |
|
|
141 | 147 |
public void setFrameRate(int frameRate) { |
142 | 148 |
this.frameRate = frameRate; |
143 | 149 |
} |
... | ... | |
226 | 232 |
|
227 | 233 |
//Play once or loop animation selected. |
228 | 234 |
if ((this.getAnimationMode() == PLAY_ONCE)||(this.getAnimationMode() == LOOP)) { |
229 |
if ((delay > animationFrequency) && (!pauseFlag))
|
|
235 |
if ((delay > frameRate) && (!pauseFlag))
|
|
230 | 236 |
{ |
231 | 237 |
if(time != 0) |
232 | 238 |
time += delay; |
233 | 239 |
else |
234 |
time += animationFrequency;
|
|
240 |
time += frameRate;
|
|
235 | 241 |
} |
236 | 242 |
else{ |
237 |
time += animationFrequency;
|
|
243 |
time += frameRate;
|
|
238 | 244 |
//Play once animation. |
239 | 245 |
} |
240 | 246 |
if (this.getAnimationMode() == PLAY_ONCE) { |
... | ... | |
247 | 253 |
}//if loop. |
248 | 254 |
//Backward animation. |
249 | 255 |
if (this.getAnimationMode() == PLAY_ONCE_BACKWARDS) { |
250 |
if ((delay > animationFrequency) && (!pauseFlag)){
|
|
256 |
if ((delay > frameRate) && (!pauseFlag)){
|
|
251 | 257 |
if((time < this.getGlobalTime())) |
252 | 258 |
time -= delay; |
253 | 259 |
else |
254 |
time -= animationFrequency;
|
|
260 |
time -= frameRate;
|
|
255 | 261 |
} |
256 | 262 |
else |
257 |
time -= animationFrequency;
|
|
263 |
time -= frameRate;
|
|
258 | 264 |
if(time <= 0){ |
259 | 265 |
AnimationPlayer.occupied = false; |
260 | 266 |
pauseFlag = false; |
... | ... | |
264 | 270 |
//Ping pong animation. |
265 | 271 |
if(this.getAnimationMode() == PING_PONG_LOOP){ |
266 | 272 |
if(direcction == 1){// 0..globalTime |
267 |
if ((delay > animationFrequency) && (!pauseFlag)){
|
|
273 |
if ((delay > frameRate) && (!pauseFlag)){
|
|
268 | 274 |
if((time < this.getGlobalTime())){ |
269 | 275 |
time += delay; |
270 | 276 |
} |
271 | 277 |
else |
272 |
time += animationFrequency;
|
|
278 |
time += frameRate;
|
|
273 | 279 |
} |
274 | 280 |
else |
275 |
time += animationFrequency;
|
|
281 |
time += frameRate;
|
|
276 | 282 |
} |
277 | 283 |
else{ |
278 |
if ((delay > animationFrequency) && (!pauseFlag)){
|
|
284 |
if ((delay > frameRate) && (!pauseFlag)){
|
|
279 | 285 |
if((time < this.getGlobalTime())){ |
280 | 286 |
time -= delay; |
281 | 287 |
} |
282 | 288 |
else |
283 |
time -= animationFrequency;
|
|
289 |
time -= frameRate;
|
|
284 | 290 |
} |
285 | 291 |
else |
286 |
time -= animationFrequency;
|
|
292 |
time -= frameRate;
|
|
287 | 293 |
} |
288 | 294 |
if(time > this.getGlobalTime()){ |
289 | 295 |
time = this.getGlobalTime(); |
... | ... | |
356 | 362 |
} |
357 | 363 |
|
358 | 364 |
|
359 |
/** |
|
360 |
* This function returns the actual default frequency of player. |
|
361 |
* |
|
362 |
* @return frequency. |
|
363 |
*/ |
|
364 |
public long getAnimationFrequency() { |
|
365 |
return animationFrequency; |
|
366 |
} |
|
367 |
|
|
368 |
|
|
369 |
/** |
|
370 |
* Set of our player frequency. |
|
371 |
* |
|
372 |
* @param animationFrequency |
|
373 |
*/ |
|
374 |
public void setAnimationFrequency(long animationFrequency) { |
|
375 |
this.animationFrequency = animationFrequency; |
|
376 |
} |
|
377 |
|
|
378 |
|
|
379 | 365 |
/* |
380 | 366 |
* IPersistence get method. |
381 | 367 |
* @see com.iver.utiles.IPersistence#getXMLEntity() |
... | ... | |
387 | 373 |
xml.putProperty("animationMode", this.animationMode); |
388 | 374 |
//xml.putProperty("animationPlayerState", animationPlayerState); |
389 | 375 |
xml.putProperty("length",this.globalTime); |
390 |
xml.putProperty("framerate",this.animationFrequency); |
|
376 |
// xml.putProperty("framerate",this.animationFrequency);
|
|
391 | 377 |
|
392 | 378 |
return xml; |
393 | 379 |
} |
... | ... | |
408 | 394 |
if (xml.contains("length")){ |
409 | 395 |
this.globalTime = xml.getDoubleProperty("length"); |
410 | 396 |
} |
411 |
if (xml.contains("framerate")) |
|
412 |
this.animationFrequency = xml.getIntProperty("framerate"); |
|
397 |
// if (xml.contains("framerate"))
|
|
398 |
// this.animationFrequency = xml.getIntProperty("framerate");
|
|
413 | 399 |
|
414 | 400 |
|
415 | 401 |
} |
Also available in: Unified diff