Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / tools / Behavior / Behavior.java @ 20100

History | View | Annotate | Download (5.18 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.geom.Point2D;
51
import java.awt.geom.Rectangle2D;
52
import java.awt.image.BufferedImage;
53

    
54
import com.iver.cit.gvsig.fmap.MapControl;
55
import com.iver.cit.gvsig.fmap.ViewPort;
56
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
57
import com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener;
58

    
59

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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