Source code: com/xerox/VTM/engine/GTranslationPRR.java
1 /* FILE: GTranslationPRR.java
2 * DATE OF CREATION: Mar 28 2002
3 * AUTHOR : Emmanuel Pietriga (emmanuel.pietriga@xrce.xerox.com)
4 * MODIF: Mon Oct 07 15:43:44 2002 by Emmanuel Pietriga
5 * Copyright (c) Xerox Corporation, XRCE/Contextual Computing, 2002. All Rights Reserved
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * For full terms see the file COPYING.
18 */
19
20 package com.xerox.VTM.engine;
21
22 import java.util.Vector;
23 import java.util.Enumeration;
24 import java.util.Date;
25 import java.awt.Point;
26 import com.xerox.VTM.glyphs.*;
27
28 /**glyph animation: translation (X,Y) (parameterable refresh rate)
29 * @author Emmanuel Pietriga
30 */
31
32 class GTranslationPRR extends GTranslation {
33 int rate;
34 int count;
35
36 /**
37 *@param g glyph to be animated
38 *@param mgr Animation Manager
39 *@param d duration in ms
40 *@param r refresh rate
41 */
42 GTranslationPRR(Glyph g,AnimManager mgr,long d,int r){
43 super(g,mgr,d);
44 rate=r;
45 count=1;
46 }
47
48 boolean animate() {//the returned boolean says will be used to know if anything happened here, i.e. if iot is necessary to repaint
49 if (started){
50 now=new Date();
51 progression=(double)((now.getTime()-startTime)/(double)duration);
52 step=(int)Math.round(steps.length*progression);
53 if (step<steps.length) {
54 if (count==rate){
55 target.moveTo(steps[step].x,steps[step].y);
56 count=1;
57 return true;
58 }
59 else {count++;return false;}
60 }
61 else {
62 target.moveTo(steps[steps.length-1].x,steps[steps.length-1].y);
63 parent.killGAnim(this,type);
64 return true;
65 }
66 }
67 else return false;
68 }
69 }