KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > viewer > tool > ITool


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * *
5  * This library is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or (at your option) any later version. *
9  * *
10  * This library is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13  * Lesser General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Lesser General Public *
16  * License along with this library; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin St, Fifth Floor, *
19  * Boston, MA 02110-1301 USA *
20  * *
21  * Or get it online : *
22  * http://www.gnu.org/copyleft/lesser.html *
23  * *
24  * *
25  ******************************************************************************/

26
27 package org.nightlabs.editor2d.viewer.tool;
28
29 import org.nightlabs.editor2d.viewer.IViewer;
30 import org.nightlabs.editor2d.viewer.event.MouseEvent;
31
32 public interface ITool
33 {
34     /**
35      * called when the Tool becomes the active Tool for the Viewer
36      * implementations can perform any necessary initialization here.
37      */

38     void activate();
39     
40     /**
41      * called when the Tool is deactivated
42      * implementations can perform cleanup for free resources
43      */

44     void deactivate();
45     
46     /**
47      *
48      * @param viewer the Viewer for the Tool
49      */

50     void setViewer(IViewer viewer);
51     
52     /**
53      *
54      * @return the Viewer for the Tool
55      */

56     IViewer getViewer();
57     
58     /**
59      * called when the Mouse is moved
60      * @param me the MouseEvent
61      */

62     void mouseMoved(MouseEvent me);
63     
64     /**
65      * called when the mouse is pressed
66      * @param me the MouseEvent
67      */

68     void mousePressed(MouseEvent me);
69     
70     /**
71      * called when the mouse is released
72      * @param me the MouseEvent
73      */

74     void mouseReleased(MouseEvent me);
75     
76     /**
77      *
78      * @param x the X-Coordinate to convert to relative (zoom + scrollOffset)
79      * @return the converted relative X-Coordinate
80      */

81     int getRelativeX(int x);
82     
83     /**
84      *
85      * @param y the Y-Coordinate to convert to relative (zoom + scrollOffset)
86      * @return the converted relative Y-Coordinate
87      */

88     int getRelativeY(int y);
89     
90 // /**
91
// *
92
// * @param relative the relative Point in the Viewer
93
// * @param absolute the absolute Point in the Viewer
94
// */
95
// void mouseChanged(Point relative, Point absolute);
96

97     /**
98      *
99      * @param id the id of the Tool
100      */

101     void setID(int id);
102     
103     /**
104      *
105      * @return the id of the Tool
106      */

107     int getID();
108 }
109
Popular Tags