Revision 19391

View differences:

trunk/libraries/libAnimation/src/com/iver/cit/gvsig/animation/AnimationPlayer.java
38 38
	
39 39
	private int animationMode = 0;//loop, ping pong, play once, play once backwards.
40 40

  
41
	private long animationFrequency = 30;// ms.
41
	private double animationFrequency = 1.0 / frameRate * 1000;// ms.
42 42

  
43 43
	private double preTime = 0.0;
44 44

  
......
71 71
	 * Logic actions when the play button is pressed.
72 72
	 */
73 73
	public void play() {
74
		double mia = ((double)1) / frameRate * 1000;
74 75
		if (animationPlayerState != AnimationPlayer.ANIMATION_PLAY){
75 76
				animationPlayerState = AnimationPlayer.ANIMATION_PLAY;
76 77
				
78
				System.out.println(mia);
77 79
				//AT = new AnimationTimer();
78 80
				if (AT.isAlive() == false){
79 81
					AT = new AnimationTimer();
80 82
					AT.addCallBackObject(this);
81
					AT.start(frameRate);
83
					AT.start(animationFrequency);
82 84
				}
83 85

  
84 86
			//Initial time control, backward animation: initial time = end time, forward animation: initial time = 0.
......
232 234
				
233 235
				//Play once or loop animation selected.
234 236
				if ((this.getAnimationMode() == PLAY_ONCE)||(this.getAnimationMode() == LOOP)) {
235
					if ((delay > frameRate) && (!pauseFlag))
237
					if ((delay > animationFrequency) && (!pauseFlag))
236 238
					{
237 239
						if(time != 0)
238 240
							time += delay;
239 241
						else 
240
							time += frameRate;
242
							time += animationFrequency;
241 243
					}
242 244
					else{
243
						time += frameRate;
245
						time += animationFrequency;
244 246
						//Play once animation.
245 247
					}
246 248
					if (this.getAnimationMode() == PLAY_ONCE) {
......
253 255
				}//if loop.
254 256
				//Backward animation.
255 257
				if (this.getAnimationMode() == PLAY_ONCE_BACKWARDS) {
256
					if ((delay > frameRate) && (!pauseFlag)){
258
					if ((delay > animationFrequency) && (!pauseFlag)){
257 259
						if((time < this.getGlobalTime()))
258 260
							time -= delay;
259 261
						else
260
							time -= frameRate;
262
							time -= animationFrequency;
261 263
					}
262 264
					else
263
						time -= frameRate;
265
						time -= animationFrequency;
264 266
					if(time <= 0){
265 267
						AnimationPlayer.occupied = false;
266 268
						pauseFlag = false;
......
270 272
				//Ping pong animation.
271 273
				if(this.getAnimationMode() == PING_PONG_LOOP){
272 274
						if(direcction == 1){// 0..globalTime
273
							if ((delay > frameRate) && (!pauseFlag)){
275
							if ((delay > animationFrequency) && (!pauseFlag)){
274 276
								if((time < this.getGlobalTime())){
275 277
									time += delay;
276 278
								}
277 279
								else
278
									time += frameRate;
280
									time += animationFrequency;
279 281
							}
280 282
							else
281
								time += frameRate;
283
								time += animationFrequency;
282 284
						}
283 285
						else{
284
							if ((delay > frameRate) && (!pauseFlag)){
286
							if ((delay > animationFrequency) && (!pauseFlag)){
285 287
								if((time < this.getGlobalTime())){
286 288
									time -= delay;
287 289
								}
288 290
								else
289
									time -= frameRate;
291
									time -= animationFrequency;
290 292
							}
291 293
							else
292
								time -= frameRate;
294
								time -= animationFrequency;
293 295
						}
294 296
						if(time > this.getGlobalTime()){
295 297
							time = this.getGlobalTime();
......
373 375
		xml.putProperty("animationMode", this.animationMode);
374 376
		//xml.putProperty("animationPlayerState", animationPlayerState);
375 377
		xml.putProperty("length",this.globalTime);
376
	//	xml.putProperty("framerate",this.animationFrequency);
378
	//	xml.putProperty("animationFrequency",this.animationFrequency);
377 379

  
378 380
		return xml;
379 381
	}
......
394 396
		if (xml.contains("length")){
395 397
			this.globalTime = xml.getDoubleProperty("length");
396 398
		}
397
//		if (xml.contains("framerate"))
398
//			this.animationFrequency = xml.getIntProperty("framerate");
399
//		if (xml.contains("animationFrequency"))
400
//			this.animationFrequency = xml.getIntProperty("animationFrequency");
399 401
		
400 402
		
401 403
	}

Also available in: Unified diff