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