Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / georeferencing / ui / zoom / tools / SelectPointTool.java @ 18385

History | View | Annotate | Download (2.96 KB)

1 18346 nbrodin
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program 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
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.rastertools.georeferencing.ui.zoom.tools;
20
21
import java.awt.Graphics;
22
import java.awt.event.MouseEvent;
23
import java.awt.event.MouseListener;
24
import java.awt.event.MouseMotionListener;
25
import java.awt.geom.Point2D;
26
27
import org.gvsig.rastertools.georeferencing.ui.zoom.CanvasZone;
28
29
/**
30
 * Herramienta de selecci?n de puntos de control sobre la vista
31
 *
32
 * 17/01/2008
33
 * @author Nacho Brodin (nachobrodin@gmail.com)
34
 */
35 18385 nbrodin
public class SelectPointTool extends BaseViewTool implements MouseListener, MouseMotionListener {
36 18346 nbrodin
    private Point2D[]                 pointSelected = null;
37
38
        /**
39
         * Constructor. Asigna el canvas e inicializa los listeners.
40
         * @param canvas
41
         */
42
        public SelectPointTool(CanvasZone canvas, ToolListener listener) {
43
                super(canvas, listener);
44
                canvas.addMouseListener(this);
45
                canvas.addMouseMotionListener(this);
46
                pointSelected = new Point2D[2];
47
        }
48
49 18385 nbrodin
        /**
50
         * Asigna el flag que activa y desactiva la herramienta
51
         * @param active true para activarla y false para desactivarla
52
         */
53
        public void setActive(boolean active) {
54
                this.active = active;
55
                if(active)
56
                        onTool(new ToolEvent(this));
57
                else
58
                        offTool(new ToolEvent(this));
59
        }
60
61 18346 nbrodin
        /*
62
         * (non-Javadoc)
63
         * @see org.gvsig.rastertools.georeferencing.ui.zoom.IViewTool#draw(java.awt.image.BufferedImage, java.awt.geom.Rectangle2D)
64
         */
65
        public void draw(Graphics g) {
66
        }
67
68
        /*
69
         * (non-Javadoc)
70
         * @see org.gvsig.rastertools.georeferencing.ui.zoom.IViewTool#getResult()
71
         */
72
        public Object getResult() {
73
                return pointSelected;
74
        }
75
76
        /**
77
         * Selecciona el punto inicial del cuadro del que se quiere el zoom
78
         */
79
        public void mousePressed(MouseEvent e) {
80 18385 nbrodin
                if(!isActive())
81 18371 nbrodin
                        return;
82
                pointSelected[0] = e.getPoint();
83
                pointSelected[1] = canvas.viewCoordsToWorld(pointSelected[0]);
84
                for (int i = 0; i < listeners.size(); i++)
85
                        ((ToolListener)listeners.get(i)).endAction(new ToolEvent(this));
86 18346 nbrodin
        }
87
88
        public void mouseDragged(MouseEvent e) {
89
        }
90
91
        public void mouseReleased(MouseEvent e) {
92
        }
93
94
        public void mouseClicked(MouseEvent e) {
95
        }
96
97
        public void mouseEntered(MouseEvent e) {
98
        }
99
100
        public void mouseExited(MouseEvent e) {
101
        }
102
103
        public void mouseMoved(MouseEvent e) {
104
        }
105
}