KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > swing > gvt > AbstractResetTransformInteractor


1 /*
2
3    Copyright 2001 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.swing.gvt;
19
20 import java.awt.event.InputEvent JavaDoc;
21 import java.awt.event.KeyEvent JavaDoc;
22 import java.awt.event.MouseEvent JavaDoc;
23
24 /**
25  * This class represents an interactor which reset the rendering transform
26  * of the associated document.
27  *
28  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
29  * @version $Id: AbstractResetTransformInteractor.java,v 1.3 2004/08/18 07:15:32 vhardy Exp $
30  */

31 public abstract class AbstractResetTransformInteractor implements Interactor {
32     
33     /**
34      * Whether the interactor has finished.
35      */

36     protected boolean finished = true;
37
38     /**
39      * Tells whether the interaction has finished.
40      */

41     public boolean endInteraction() {
42         return finished;
43     }
44
45     // KeyListener //////////////////////////////////////////////////////////
46

47     /**
48      * Invoked when a key has been typed.
49      * This event occurs when a key press is followed by a key release.
50      */

51     public void keyTyped(KeyEvent JavaDoc e) {
52         resetTransform(e);
53     }
54         
55     /**
56      * Invoked when a key has been pressed.
57      */

58     public void keyPressed(KeyEvent JavaDoc e) {
59         resetTransform(e);
60     }
61
62     /**
63      * Invoked when a key has been released.
64      */

65     public void keyReleased(KeyEvent JavaDoc e) {
66         resetTransform(e);
67     }
68
69     // MouseListener ///////////////////////////////////////////////////////
70

71     /**
72      * Invoked when the mouse has been clicked on a component.
73      */

74     public void mouseClicked(MouseEvent JavaDoc e) {
75         resetTransform(e);
76     }
77
78     /**
79      * Invoked when a mouse button has been pressed on a component.
80      */

81     public void mousePressed(MouseEvent JavaDoc e) {
82         resetTransform(e);
83     }
84
85     /**
86      * Invoked when a mouse button has been released on a component.
87      */

88     public void mouseReleased(MouseEvent JavaDoc e) {
89         resetTransform(e);
90     }
91
92     /**
93      * Invoked when the mouse enters a component.
94      */

95     public void mouseEntered(MouseEvent JavaDoc e) {
96         resetTransform(e);
97     }
98
99     /**
100      * Invoked when the mouse exits a component.
101      */

102     public void mouseExited(MouseEvent JavaDoc e) {
103         resetTransform(e);
104     }
105
106     // MouseMotionListener /////////////////////////////////////////////////
107

108     /**
109      * Invoked when a mouse button is pressed on a component and then
110      * dragged. Mouse drag events will continue to be delivered to
111      * the component where the first originated until the mouse button is
112      * released (regardless of whether the mouse position is within the
113      * bounds of the component).
114      */

115     public void mouseDragged(MouseEvent JavaDoc e) {
116         resetTransform(e);
117     }
118
119     /**
120      * Invoked when the mouse button has been moved on a component
121      * (with no buttons no down).
122      */

123     public void mouseMoved(MouseEvent JavaDoc e) {
124         resetTransform(e);
125     }
126
127     /**
128      * Resets the associated component's transform.
129      */

130     protected void resetTransform(InputEvent JavaDoc e) {
131         JGVTComponent c = (JGVTComponent)e.getSource();
132         c.resetRenderingTransform();
133         finished = true;
134     }
135 }
136
Popular Tags