Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / tools / Behavior / Behavior.java @ 20098

History | View | Annotate | Download (5.09 KB)

1
/*
2
 * Created on 28-oct-2004
3
 */
4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.cit.gvsig.fmap.tools.Behavior;
45

    
46
import java.awt.Cursor;
47
import java.awt.Graphics;
48
import java.awt.event.MouseEvent;
49
import java.awt.event.MouseWheelEvent;
50
import java.awt.image.BufferedImage;
51

    
52
import com.iver.cit.gvsig.fmap.MapControl;
53
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
54
import com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener;
55

    
56

    
57
/**
58
 * <p>When user is working with a tool on a {@link MapControl MapControl} instance, <code>Behavior</code> defines
59
 *  the basic ways of interacting: selecting a point, a circle, a rectangle, or ...</p>
60
 *
61
 * <p>All events generated will be <code>MouseEvent</code>, and will depend on the nature of the
62
 *  <i>behavior</i>, like the kind of tool for applying the changes.</p>
63
 * 
64
 * <p><code>Behavior</code> defines the common and basic functionality for all kinds of interacting ways
65
 *  with the <code>MapControl</code> object.</p>
66
 *
67
 * @see IBehavior
68
 *
69
 * @author Luis W. Sevilla
70
 */
71
public abstract class Behavior implements IBehavior {
72
        /**
73
         * Reference to the <code>MapControl</code> object that uses.
74
         * 
75
         * @see #getMapControl()
76
         * @see #setMapControl(MapControl)
77
         */
78
        private MapControl mapControl;
79

    
80
        /* 
81
         * (non-Javadoc)
82
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getListener()
83
         */
84
        public abstract ToolListener getListener();
85

    
86
        /*
87
         * <p>Draws as much of the associated <code>MapControl</code> image as is currently available. The image
88
         *  is drawn with its top-left corner at (0, 0) in this graphics context's coordinate space. Transparent
89
         *  pixels in the image do not affect whatever pixels are already there.</p>
90
         * 
91
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#paintComponent(java.awt.Graphics)
92
         */
93
        public void paintComponent(Graphics g) {
94
                BufferedImage img = getMapControl().getImage();
95

    
96
                if (img != null) {
97
                        g.drawImage(img, 0, 0, null);
98
                }
99
        }
100

    
101
        /* (non-Javadoc)
102
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#setMapControl(com.iver.cit.gvsig.fmap.MapControl)
103
         */
104
        public void setMapControl(MapControl mc) {
105
                mapControl = mc;
106
        }
107

    
108
        /* (non-Javadoc)
109
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getCursor()
110
         */
111
        public Cursor getCursor() {
112
                return getListener().getCursor();
113
        }
114

    
115
        /* (non-Javadoc)
116
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getMapControl()
117
         */
118
        public MapControl getMapControl() {
119
                return mapControl;
120
        }
121

    
122
        /* (non-Javadoc)
123
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseClicked(java.awt.event.MouseEvent)
124
         */
125
        public void mouseClicked(MouseEvent e) throws BehaviorException {
126
        }
127

    
128
        /* (non-Javadoc)
129
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseEntered(java.awt.event.MouseEvent)
130
         */
131
        public void mouseEntered(MouseEvent e) throws BehaviorException {
132
        }
133

    
134
        /* (non-Javadoc)
135
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseExited(java.awt.event.MouseEvent)
136
         */
137
        public void mouseExited(MouseEvent e) throws BehaviorException {
138
        }
139

    
140
        /* (non-Javadoc)
141
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mousePressed(java.awt.event.MouseEvent)
142
         */
143
        public void mousePressed(MouseEvent e) throws BehaviorException {
144
        }
145

    
146
        /* (non-Javadoc)
147
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseReleased(java.awt.event.MouseEvent)
148
         */
149
        public void mouseReleased(MouseEvent e) throws BehaviorException {
150
        }
151

    
152
        /* (non-Javadoc)
153
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseDragged(java.awt.event.MouseEvent)
154
         */
155
        public void mouseDragged(MouseEvent e) throws BehaviorException {
156
        }
157

    
158
        /* (non-Javadoc)
159
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseMoved(java.awt.event.MouseEvent)
160
         */
161
        public void mouseMoved(MouseEvent e) throws BehaviorException {
162
        }
163

    
164
        /* (non-Javadoc)
165
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseWheelMoved(java.awt.event.MouseWheelEvent)
166
         */
167
        public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException {
168
        }
169
}