root / trunk / extensions / extRasterTools-SE / src / org / gvsig / fmap / raster / layers / GeorefPanListenerImpl.java @ 15765
History | View | Annotate | Download (3.44 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 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.fmap.raster.layers; |
20 |
|
21 |
import java.awt.Cursor; |
22 |
import java.awt.Image; |
23 |
import java.awt.Point; |
24 |
import java.awt.Toolkit; |
25 |
import java.awt.geom.Point2D; |
26 |
import java.awt.geom.Rectangle2D; |
27 |
|
28 |
import javax.swing.ImageIcon; |
29 |
|
30 |
import com.iver.andami.PluginServices; |
31 |
import com.iver.cit.gvsig.fmap.MapControl; |
32 |
import com.iver.cit.gvsig.fmap.ViewPort; |
33 |
import com.iver.cit.gvsig.fmap.tools.Events.MoveEvent; |
34 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PanListener; |
35 |
|
36 |
|
37 |
/**
|
38 |
* Implementaci?n de la interfaz PanListener como herramienta para realizar el
|
39 |
* Pan.
|
40 |
*
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
42 |
*/
|
43 |
public class GeorefPanListenerImpl implements PanListener { |
44 |
// private final Image ipan = new ImageIcon(MapControl.class.getResource(
|
45 |
// "images/CruxCursor.png")).getImage();
|
46 |
private final Image ipan = PluginServices.getIconTheme().get("crux-cursor").getImage(); |
47 |
private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(ipan, |
48 |
new Point(16, 16), ""); |
49 |
private MapControl mapControl;
|
50 |
private FLyrRasterSE lyrRaster = null; |
51 |
private String pathToFile = null; |
52 |
|
53 |
|
54 |
/**
|
55 |
* Crea un nuevo RectangleListenerImpl.
|
56 |
*
|
57 |
* @param mapControl MapControl.
|
58 |
*/
|
59 |
public GeorefPanListenerImpl(MapControl mapControl) {
|
60 |
this.mapControl = mapControl;
|
61 |
} |
62 |
|
63 |
/**
|
64 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PanListener#move(java.awt.geom.Point2D,
|
65 |
* java.awt.geom.Point2D)
|
66 |
*/
|
67 |
public void move(MoveEvent event) { |
68 |
ViewPort vp = mapControl.getMapContext().getViewPort(); |
69 |
|
70 |
Point2D from = vp.toMapPoint(event.getFrom());
|
71 |
Point2D to = vp.toMapPoint(event.getTo());
|
72 |
|
73 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
74 |
Rectangle2D extent = vp.getExtent();
|
75 |
r.x = extent.getX() - (to.getX() - from.getX()); |
76 |
r.y = extent.getY() - (to.getY() - from.getY()); |
77 |
r.width = extent.getWidth(); |
78 |
r.height = extent.getHeight(); |
79 |
vp.setExtent(r); |
80 |
|
81 |
|
82 |
// mapControl.drawMap();
|
83 |
} |
84 |
|
85 |
/**
|
86 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
|
87 |
*/
|
88 |
public Cursor getCursor() { |
89 |
return cur;
|
90 |
} |
91 |
|
92 |
/**
|
93 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
|
94 |
*/
|
95 |
public boolean cancelDrawing() { |
96 |
return true; |
97 |
} |
98 |
|
99 |
/**
|
100 |
* @return Returns the lyrRaster.
|
101 |
*/
|
102 |
public FLyrRasterSE getLyrRaster() {
|
103 |
return lyrRaster;
|
104 |
} |
105 |
|
106 |
/**
|
107 |
* @param lyrRaster The lyrRaster to set.
|
108 |
*/
|
109 |
public void setLyrRaster(FLyrRasterSE lyrRaster) { |
110 |
this.lyrRaster = lyrRaster;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* @return Returns the pathToFile.
|
115 |
*/
|
116 |
public String getPathToFile() { |
117 |
return pathToFile;
|
118 |
} |
119 |
|
120 |
/**
|
121 |
* @param pathToFile The pathToFile to set.
|
122 |
*/
|
123 |
public void setPathToFile(String pathToFile) { |
124 |
this.pathToFile = pathToFile;
|
125 |
} |
126 |
} |