Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/xerox/VTM/engine/GTranslation.java


1   /*   FILE: GTranslation.java
2    *   DATE OF CREATION:   Jul 12 2000
3    *   AUTHOR :            Emmanuel Pietriga (emmanuel.pietriga@xrce.xerox.com)
4    *   MODIF:              Mon Oct 07 15:42:39 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)
29   * @author Emmanuel Pietriga
30   */
31  
32  class GTranslation extends GAnimation{
33      /** step values for (x,y) coords */
34      LongPoint[] steps;
35  
36      /** 
37       *@param g glyph to be animated
38       *@param mgr Animation Manager
39       *@param d duration in ms
40       */
41      GTranslation(Glyph g,AnimManager mgr,long d){
42    started=false;
43    target=g;  
44    parent=mgr;  
45    duration=d;
46    type=AnimManager.GL_TRANS;
47      }
48  
49      void start(){    
50    now=new Date();
51    startTime=now.getTime();
52    started=true;
53      }
54  
55      boolean animate() {//the returned boolean says will be used to know if anything happened here, i.e. if iot is necessary to repaint
56    if (started){
57        now=new Date();
58        progression=(double)((now.getTime()-startTime)/(double)duration);
59        step=(int)Math.round(steps.length*progression);
60        if (step<steps.length) {
61      target.moveTo(steps[step].x,steps[step].y);
62        }
63        else {
64      target.moveTo(steps[steps.length-1].x,steps[steps.length-1].y);
65      parent.killGAnim(this,type);
66        }
67        return true;
68    }
69    else return false;
70      }
71  
72      protected void conclude(){
73    target.moveTo(steps[steps.length-1].x,steps[steps.length-1].y);
74      }
75  
76  }