Source code: com/xerox/VTM/engine/CTranslation.java
1 /* FILE: CTranslation.java
2 * DATE OF CREATION: Jul 17 2000
3 * AUTHOR : Emmanuel Pietriga (emmanuel.pietriga@xrce.xerox.com)
4 * MODIF: Tue Mar 26 09:51:09 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.engine.*;
27
28 /**camera animation: translation
29 * @author Emmanuel Pietriga
30 */
31
32 class CTranslation extends CAnimation{
33
34 /** step values for translation (x,y)*/
35 LongPoint[] steps;
36
37 /**
38 *@param c camera to be animated
39 *@param mgr Animation Manager
40 *@param d duration in ms
41 */
42 CTranslation(Camera c,AnimManager mgr,long d){
43 started=false;
44 target=c;
45 parent=mgr;
46 duration=d;
47 type=AnimManager.CA_TRANS;
48 }
49
50 void start(){
51 now=new Date();
52 startTime=now.getTime();
53 started=true;
54 }
55
56 void animate() {
57 if (started){
58 //System.out.print("("+iterator+","+steps.length+")");
59 now=new Date();
60 //System.out.println(now.getTime()+" "+startTime+" "+duration);
61 progression=(double)((now.getTime()-startTime)/(double)duration);
62 step=(int)Math.round(steps.length*progression);
63 //System.out.println(progression+" "+step);
64 if (step<steps.length) {
65 target.posx=steps[step].x;
66 target.posy=steps[step].y;
67 }
68 else {
69 target.posx=steps[steps.length-1].x;
70 target.posy=steps[steps.length-1].y;
71 //System.out.println("kill "+target.posx+","+target.posy);
72 parent.killCAnim(this,type);
73 }
74 }
75 }
76
77 protected void conclude(){
78 target.posx=steps[steps.length-1].x;
79 target.posy=steps[steps.length-1].y;
80 }
81
82 }