root / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / fmap / tools / GeorefPanListenerImpl.java @ 2894
History | View | Annotate | Download (4.14 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 com.iver.cit.gvsig.fmap.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 MoveListener como herramienta para realizar el
|
71 |
* Pan.
|
72 |
*
|
73 |
* @author Vicente Caballero Navarro
|
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 |
// System.out.println(vp);
|
102 |
Point2D from = vp.toMapPoint(event.getFrom());
|
103 |
Point2D to = vp.toMapPoint(event.getTo());
|
104 |
|
105 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
106 |
Rectangle2D extent = vp.getExtent();
|
107 |
r.x = extent.getX() - (to.getX() - from.getX()); |
108 |
r.y = extent.getY() - (to.getY() - from.getY()); |
109 |
r.width = extent.getWidth(); |
110 |
r.height = extent.getHeight(); |
111 |
vp.setExtent(r); |
112 |
|
113 |
|
114 |
// mapControl.drawMap();
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
|
119 |
*/
|
120 |
public Cursor getCursor() { |
121 |
return cur;
|
122 |
} |
123 |
|
124 |
/**
|
125 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
|
126 |
*/
|
127 |
public boolean cancelDrawing() { |
128 |
return true; |
129 |
} |
130 |
|
131 |
/**
|
132 |
* @return Returns the lyrRaster.
|
133 |
*/
|
134 |
public FLyrRaster getLyrRaster() {
|
135 |
return lyrRaster;
|
136 |
} |
137 |
|
138 |
/**
|
139 |
* @param lyrRaster The lyrRaster to set.
|
140 |
*/
|
141 |
public void setLyrRaster(FLyrRaster lyrRaster) { |
142 |
this.lyrRaster = lyrRaster;
|
143 |
} |
144 |
|
145 |
/**
|
146 |
* @return Returns the pathToFile.
|
147 |
*/
|
148 |
public String getPathToFile() { |
149 |
return pathToFile;
|
150 |
} |
151 |
|
152 |
/**
|
153 |
* @param pathToFile The pathToFile to set.
|
154 |
*/
|
155 |
public void setPathToFile(String pathToFile) { |
156 |
this.pathToFile = pathToFile;
|
157 |
} |
158 |
} |