Source code: com/xerox/VTM/engine/GCbCurveCtrl.java
1 /* FILE: GCbCurveCtrl.java
2 * DATE OF CREATION: Oct 05 2001
3 * AUTHOR : Emmanuel Pietriga (emmanuel.pietriga@xrce.xerox.com)
4 * MODIF: Tue Mar 26 09:46:20 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: control point of a cubic curve
29 * @author Emmanuel Pietriga
30 */
31
32 class GCbCurveCtrl extends GCurveCtrl{
33
34 /** step values for (r,theta) polar coords */
35 PolarCoords[] steps2;
36
37 VCbCurve trueTarget;
38
39 /**
40 *@param g glyph to be animated
41 *@param mgr Animation Manager
42 *@param d duration in ms
43 */
44 GCbCurveCtrl(VCbCurve g,AnimManager mgr,long d){
45 started=false;
46 target=g;
47 trueTarget=g;
48 parent=mgr;
49 duration=d;
50 type=AnimManager.GL_CTRL;
51 }
52
53 boolean animate() {//the returned boolean says will be used to know if anything happened here, i.e. if iot is necessary to repaint
54 if (started){
55 now=new Date();
56 progression=(double)((now.getTime()-startTime)/(double)duration);
57 step=(int)Math.round(steps.length*progression);
58 if (step<steps.length) {
59 if (steps!=null){trueTarget.setCtrlPoint1(steps[step].r,steps[step].theta);}
60 if (steps2!=null){trueTarget.setCtrlPoint2(steps2[step].r,steps2[step].theta);}
61 }
62 else {
63 if (steps!=null){trueTarget.setCtrlPoint1(steps[steps.length-1].r,steps[steps.length-1].theta);}
64 if (steps2!=null){trueTarget.setCtrlPoint2(steps2[steps.length-1].r,steps2[steps2.length-1].theta);}
65 parent.killCurveAnim(this);
66 }
67 return true;
68 }
69 else return false;
70 }
71
72 protected void conclude(){
73 if (steps!=null){trueTarget.setCtrlPoint1(steps[steps.length-1].r,steps[steps.length-1].theta);}
74 if (steps2!=null){trueTarget.setCtrlPoint2(steps2[steps.length-1].r,steps2[steps2.length-1].theta);}
75 }
76
77 }