Statistics
| Revision:

root / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / tools / GeorefPanListenerImpl.java @ 5217

History | View | Annotate | Download (4.12 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.georeferencing.tools;
42

    
43
import com.hardcode.driverManager.DriverLoadException;
44
import com.iver.andami.messages.NotificationManager;
45
import com.iver.cit.gvsig.fmap.MapControl;
46
import com.iver.cit.gvsig.fmap.ViewPort;
47
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
48
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
49
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
50
import com.iver.cit.gvsig.fmap.layers.RasterAdapter;
51
import com.iver.cit.gvsig.fmap.layers.RasterFileAdapter;
52
import com.iver.cit.gvsig.fmap.tools.Events.MoveEvent;
53
import com.iver.cit.gvsig.fmap.tools.Listeners.PanListener;
54

    
55
import java.awt.Cursor;
56
import java.awt.Image;
57
import java.awt.Point;
58
import java.awt.Toolkit;
59
import java.awt.geom.Point2D;
60
import java.awt.geom.Rectangle2D;
61
import java.io.File;
62

    
63
import javax.swing.ImageIcon;
64

    
65
import org.cresques.io.GeoRasterFile;
66
import org.cresques.px.Extent;
67

    
68

    
69
/**
70
 * Implementaci?n de la interfaz PanListener como herramienta para realizar el
71
 * Pan.
72
 *
73
 * @author Nacho Brodin (brodin_ign@gva.es)
74
 */
75
public class GeorefPanListenerImpl implements PanListener {
76
        private final Image ipan = new ImageIcon(MapControl.class.getResource(
77
                                "images/CruxCursor.png")).getImage();
78
        private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(ipan,
79
                        new Point(16, 16), "");
80
        private MapControl mapControl;
81
        private FLyrRaster lyrRaster = null;
82
        private String        pathToFile = null;
83
                
84

    
85
        /**
86
         * Crea un nuevo RectangleListenerImpl.
87
         *
88
         * @param mapControl MapControl.
89
         */
90
        public GeorefPanListenerImpl(MapControl mapControl) {
91
                this.mapControl = mapControl;
92
        }
93

    
94
        /**
95
         * @see com.iver.cit.gvsig.fmap.tools.Listeners.PanListener#move(java.awt.geom.Point2D,
96
         *                 java.awt.geom.Point2D)
97
         */
98
        public void move(MoveEvent event) {
99
                ViewPort vp = mapControl.getMapContext().getViewPort();
100

    
101
                Point2D from = vp.toMapPoint(event.getFrom());
102
                Point2D to = vp.toMapPoint(event.getTo());
103

    
104
                Rectangle2D.Double r = new Rectangle2D.Double();
105
                Rectangle2D extent = vp.getExtent();
106
                r.x = extent.getX() - (to.getX() - from.getX());
107
                r.y = extent.getY() - (to.getY() - from.getY());
108
                r.width = extent.getWidth();
109
                r.height = extent.getHeight();
110
                vp.setExtent(r);
111

    
112
                                
113
                // mapControl.drawMap();
114
        }
115

    
116
        /**
117
         * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
118
         */
119
        public Cursor getCursor() {
120
                return cur;
121
        }
122

    
123
        /**
124
         * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
125
         */
126
        public boolean cancelDrawing() {
127
                return true;
128
        }
129
        
130
        /**
131
         * @return Returns the lyrRaster.
132
         */
133
        public FLyrRaster getLyrRaster() {
134
                return lyrRaster;
135
        }
136

    
137
        /**
138
         * @param lyrRaster The lyrRaster to set.
139
         */
140
        public void setLyrRaster(FLyrRaster lyrRaster) {
141
                this.lyrRaster = lyrRaster;
142
        }
143

    
144
        /**
145
         * @return Returns the pathToFile.
146
         */
147
        public String getPathToFile() {
148
                return pathToFile;
149
        }
150

    
151
        /**
152
         * @param pathToFile The pathToFile to set.
153
         */
154
        public void setPathToFile(String pathToFile) {
155
                this.pathToFile = pathToFile;
156
        }
157
}