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

Quick Search    Search Deep

Source code: com/xerox/VTM/svg/EventHandlerTest.java


1   /*   FILE: EventHandlerTest.java
2    *   DATE OF CREATION:   Jan 04 2002
3    *   AUTHOR :            Emmanuel Pietriga (emmanuel.pietriga@xrce.xerox.com)
4    *   MODIF:              Thu Jan 24 10:15:23 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.svg;
21  
22  import java.util.Vector;
23  import java.awt.Point;
24  import com.xerox.VTM.engine.*;
25  import com.xerox.VTM.glyphs.*;
26  
27  class EventHandlerTest extends AppEventHandler{
28  
29      SVGTest application;
30  
31      long lastX,lastY,lastJPX,lastJPY;    //remember last mouse coords to compute translation  (dragging)
32  
33      EventHandlerTest(SVGTest appli){
34    application=appli;
35      }
36  
37      long x1,x2,y1,y2;
38  
39      public void press1(ViewPanel v,int mod,int jpx,int jpy){
40  
41    try {application.vsm.stickToMouse(v.lastGlyphEntered());}
42    catch (NullPointerException e){System.err.println("EventHandlerTest:press1");}
43      }
44  
45      public void release1(ViewPanel v,int mod,int jpx,int jpy){
46  //   v.setDrawRect(false);
47  //   x2=v.getMouse().vx;
48  //   y2=v.getMouse().vy;
49    //application.vsm.centerOnRegion(application.vsm.getActiveCamera(),application.vsm.getActiveView(),500,x1,y1,x2,y2);
50     application.vsm.unstickFromMouse();
51      }
52  
53      public void click1(ViewPanel v,int mod,int jpx,int jpy,int clickNumber){
54      }
55      public void press2(ViewPanel v,int mod,int jpx,int jpy){}
56      public void release2(ViewPanel v,int mod,int jpx,int jpy){  }
57      public void click2(ViewPanel v,int mod,int jpx,int jpy,int clickNumber){
58  
59      }
60  
61      public void press3(ViewPanel v,int mod,int jpx,int jpy){
62    //application.vsm.setSync(false);
63    lastJPX=jpx;
64    lastJPY=jpy;
65    //application.vsm.animator.setActiveCam(v.cams[0]);
66    v.setDrawDrag(true);
67    application.vsm.activeView.mouse.setSensitivity(false);  //because we would not be consistent  (when dragging the mouse, we computeMouseOverList, but if there is an anim triggered by {X,Y,A}speed, and if the mouse is not moving, this list is not computed - so here we choose to disable this computation when dragging the mouse with button 3 pressed)
68      }
69  
70      public void release3(ViewPanel v,int mod,int jpx,int jpy){
71    application.vsm.animator.Xspeed=0;
72    application.vsm.animator.Yspeed=0;
73    application.vsm.animator.Aspeed=0;
74    v.setDrawDrag(false);
75    application.vsm.activeView.mouse.setSensitivity(true);
76    /*Camera c=v.cams[0];
77      application.vsm.animator.createCameraAnimation(500,2,new LongPoint(lastX-application.vsm.mouse.vx,lastY-application.vsm.mouse.vy),c.getID());*/
78      }
79  
80      public void click3(ViewPanel v,int mod,int jpx,int jpy,int clickNumber){}
81  
82      public void mouseMoved(ViewPanel v,int jpx,int jpy){}
83  
84      public void mouseDragged(ViewPanel v,int mod,int buttonNumber,int jpx,int jpy){
85    if (buttonNumber==3){
86        Camera c=application.vsm.getActiveCamera();
87        if (mod==1) {
88      application.vsm.animator.Xspeed=0;
89      application.vsm.animator.Yspeed=0;
90      application.vsm.animator.Aspeed=(lastJPY-jpy)*(long)((c.focal+c.altitude)/c.focal)/50;  //50 is just a speed factor (too fast otherwise)
91        }
92        else {
93      application.vsm.animator.Aspeed=0;
94      application.vsm.animator.Xspeed=(jpx-lastJPX)*(long)((c.focal+c.altitude)/c.focal)/50;
95      application.vsm.animator.Yspeed=(lastJPY-jpy)*(long)((c.focal+c.altitude)/c.focal)/50;  
96        }
97    }
98      }
99  
100     public void enterGlyph(Glyph g){super.enterGlyph(g);}
101     public void exitGlyph(Glyph g){
102   super.exitGlyph(g);
103     }
104 
105     public void Ktype(ViewPanel v,char c,int code,int mod){
106   if (c=='c'){application.vsm.getGlobalView(application.vsm.getVirtualSpace("src").getCamera(0),500);}
107   else {
108       application.export();
109   }
110     }
111     public void Kpress(ViewPanel v,char c,int code,int mod){
112     }
113     public void Krelease(ViewPanel v,char c,int code,int mod){
114 
115     }
116 
117     public void viewActivated(View v){}
118     
119     public void viewDeactivated(View v){}
120 
121     public void viewIconified(View v){}
122 
123     public void viewDeiconified(View v){}
124 
125     public void viewClosing(View v){System.exit(0);}
126 
127 }