Revision 18236
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/ViewRasterRequestManager.java | ||
---|---|---|
1 |
/* 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; |
|
20 |
|
|
21 |
import java.awt.Dimension; |
|
22 |
import java.awt.geom.AffineTransform; |
|
23 |
import java.awt.geom.Point2D; |
|
24 |
import java.awt.geom.Rectangle2D; |
|
25 |
import java.awt.image.BufferedImage; |
|
26 |
|
|
27 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
|
28 |
import org.gvsig.raster.dataset.IBuffer; |
|
29 |
import org.gvsig.raster.dataset.InvalidSetViewException; |
|
30 |
import org.gvsig.raster.dataset.io.RasterDriverException; |
|
31 |
import org.gvsig.raster.datastruct.Extent; |
|
32 |
import org.gvsig.raster.datastruct.ViewPortData; |
|
33 |
import org.gvsig.raster.util.RasterUtilities; |
|
34 |
import org.gvsig.rastertools.georeferencing.ui.zoom.IExtensionRequest; |
|
35 |
import org.gvsig.rastertools.georeferencing.view.ViewDialog; |
|
36 |
|
|
37 |
/** |
|
38 |
* Gestor de peticiones de zoom sobre el panel con el raster a georreferenciar. |
|
39 |
* Implementa el interfaz IExtensionRequest para que este comunique la peticiones |
|
40 |
* de zoom y ViewRasterRequestManager pueda hacer las peticiones de datos a la capa. |
|
41 |
* |
|
42 |
* 30/12/2007 |
|
43 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
44 |
*/ |
|
45 |
public class ViewRasterRequestManager implements IExtensionRequest { |
|
46 |
private FLyrRasterSE lyr = null; |
|
47 |
private ViewDialog view = null; |
|
48 |
|
|
49 |
/** |
|
50 |
* Asigna la capa a georreferenciar de donde se obtienen los datos. |
|
51 |
* @param lyr |
|
52 |
*/ |
|
53 |
public ViewRasterRequestManager(ViewDialog view, FLyrRasterSE lyr) { |
|
54 |
this.lyr = lyr; |
|
55 |
this.view = view; |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Calcula la extensi?n que contendr? la vista a partir del extent |
|
60 |
* m?ximo de la capa/s que contienen . Tienen en cuenta las distintan proporciones |
|
61 |
* entre vista y petici?n |
|
62 |
* @param Rectangle2D |
|
63 |
*/ |
|
64 |
public Rectangle2D initRequest(Rectangle2D extent) { |
|
65 |
double x, y, w, h; |
|
66 |
//Calculamos la extensi?n de la vista para el extent m?ximo que va a contener |
|
67 |
//teniendo en cuenta las proporciones de ambos. |
|
68 |
if(extent.getHeight() > extent.getWidth()) { |
|
69 |
y = extent.getY(); |
|
70 |
h = extent.getHeight(); |
|
71 |
w = (view.getCanvasWith() * h) / view.getCanvasHeight(); |
|
72 |
x = extent.getCenterX() - (w / 2); |
|
73 |
} else { |
|
74 |
x = extent.getX(); |
|
75 |
w = extent.getWidth(); |
|
76 |
h = (view.getCanvasHeight() * w) / view.getCanvasWith(); |
|
77 |
y = extent.getCenterY() + (h / 2); |
|
78 |
} |
|
79 |
Rectangle2D r = new Rectangle2D.Double(x, y, w, h); |
|
80 |
request(r); |
|
81 |
return r; |
|
82 |
} |
|
83 |
|
|
84 |
public Rectangle2D request(Rectangle2D extent) { |
|
85 |
if(extent == null) |
|
86 |
return lyr.getFullExtent(); |
|
87 |
|
|
88 |
//Ajustamos el extent al del raster |
|
89 |
Extent ext = new Extent(extent); |
|
90 |
Extent extSelection = RasterUtilities.calculateAdjustedView(ext, lyr.getFullRasterExtent()); |
|
91 |
|
|
92 |
ViewPortData vp = new ViewPortData(null, ext, new Dimension(view.getCanvasWith(), view.getCanvasHeight())); |
|
93 |
vp.mat = new AffineTransform(); |
|
94 |
vp.mat.setToScale(view.getCanvasWith()/ext.width() , -view.getCanvasHeight()/ext.height()); |
|
95 |
|
|
96 |
try { |
|
97 |
BufferedImage img = (BufferedImage)lyr.getRender().draw(view.getCanvasGraphic(), vp); |
|
98 |
if(img != null) |
|
99 |
setDrawParams(img, extSelection.toRectangle2D()); |
|
100 |
else |
|
101 |
throw new InvalidSetViewException("Buffer de dibujado vacio"); |
|
102 |
} catch (RasterDriverException e) { |
|
103 |
} catch (InvalidSetViewException e) { |
|
104 |
} catch (InterruptedException e) { |
|
105 |
} |
|
106 |
return extent; |
|
107 |
} |
|
108 |
|
|
109 |
/* |
|
110 |
* (non-Javadoc) |
|
111 |
* @see org.gvsig.rastertools.georeferencing.ui.zoom.IExtensionRequest#fullExtent(java.awt.Dimension) |
|
112 |
*/ |
|
113 |
public void fullExtent() { |
|
114 |
this.initRequest(lyr.getFullRasterExtent().toRectangle2D()); |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* Dibuja la capa raster pasada por par?metro sobre un buffer con las coordenadas |
|
119 |
* pixel especificadas. |
|
120 |
* @param size Tama?o del graphics sobre el que se dibuja |
|
121 |
* @param x Posici?n x donde se empieza a leer la capa raster para la petici?n |
|
122 |
* @param y Posici?n x donde se empieza a leer la capa raster para la petici?n |
|
123 |
* @param w Ancho de la petici?n sobre la capa raster |
|
124 |
* @param h Alto de la petici?n sobre la capa raster |
|
125 |
*/ |
|
126 |
private BufferedImage drawRasterLayer(Dimension size, int x, int y, int w, int h, int wCanvas, int hCanvas) { |
|
127 |
Rectangle2D r = new Rectangle2D.Double(x, y, w, h); |
|
128 |
|
|
129 |
int pxW = 0, pxH = 0; |
|
130 |
if( (size.getWidth() > size.getHeight() && r.getWidth() > r.getHeight()) || |
|
131 |
(size.getWidth() < size.getHeight() && r.getWidth() > r.getHeight())) { |
|
132 |
pxW = (int)size.getWidth(); |
|
133 |
pxH = (int)((r.getHeight() * size.getWidth()) / r.getWidth()); |
|
134 |
} else { |
|
135 |
pxH = (int)size.getHeight(); |
|
136 |
pxW = (int)((r.getWidth() * size.getHeight()) / r.getHeight()); |
|
137 |
} |
|
138 |
BufferedImage img = new BufferedImage(pxW, pxH, BufferedImage.TYPE_INT_RGB); |
|
139 |
|
|
140 |
try { |
|
141 |
if (lyr.getBufferFactory() != null && lyr.getBandCount() == 1) { |
|
142 |
lyr.getBufferFactory().setDrawableBands(new int[] { 0, 0, 0 }); |
|
143 |
} else if (lyr.getBufferFactory() != null && lyr.getBufferFactory().getDataSource().getBandCount() == 2) { |
|
144 |
lyr.getBufferFactory().setDrawableBands(new int[] { 0, 1, 1 }); |
|
145 |
} else { |
|
146 |
lyr.getBufferFactory().setDrawableBands(new int[] { 0, 1, 2 }); |
|
147 |
} |
|
148 |
|
|
149 |
lyr.getBufferFactory().setAreaOfInterest(x, y, w, h, pxW, pxH); |
|
150 |
IBuffer buf = lyr.getBufferFactory().getRasterBuf(); |
|
151 |
for (int i = 0; i < pxH; i++) { |
|
152 |
for (int j = 0; j < pxW; j++) { |
|
153 |
img.setRGB(j, i, ((buf.getElemByte(i, j, 0) & 0xff) << 16) + |
|
154 |
((buf.getElemByte(i, j, 1) & 0xff) << 8) + |
|
155 |
(buf.getElemByte(i, j, 2) & 0xff)); |
|
156 |
} |
|
157 |
} |
|
158 |
} catch (RasterDriverException e) { |
|
159 |
//TODO: Lanzar una excepci?n |
|
160 |
} catch (InvalidSetViewException e) { |
|
161 |
//TODO: Lanzar una excepci?n |
|
162 |
} catch (InterruptedException e) { |
|
163 |
//TODO: Lanzar una excepci?n |
|
164 |
} catch (NullPointerException e) { |
|
165 |
//TODO: Lanzar una excepci?n |
|
166 |
} |
|
167 |
|
|
168 |
return img; |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* Dibuja la capa raster pasada por par?metro sobre un buffer. |
|
173 |
* @param size Tama?o del graphics sobre el que se dibuja |
|
174 |
* @return BufferedImage cargado con los datos o null si no se ha podido dibujar |
|
175 |
*/ |
|
176 |
public BufferedImage drawRasterLayer(Dimension size) { |
|
177 |
return drawRasterLayer(size, 0, 0, (int)lyr.getPxWidth(), (int)lyr.getPxHeight(), view.getCanvasWith(), view.getCanvasHeight()); |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* Asigna los par?metros para el control de zoom del mapa |
|
182 |
* @param img BufferedImage |
|
183 |
* @param vp ViewPort |
|
184 |
*/ |
|
185 |
public void setDrawParams(BufferedImage img, Rectangle2D extBuf) { |
|
186 |
if(view != null && lyr != null) { |
|
187 |
view.setPixelDrawParams(img, extBuf, extBuf.getWidth()/img.getWidth(), new Point2D.Double(extBuf.getCenterX(), extBuf.getCenterY())); |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/ui/zoom/ViewControl.java | ||
---|---|---|
19 | 19 |
package org.gvsig.rastertools.georeferencing.ui.zoom; |
20 | 20 |
|
21 | 21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Dimension; |
|
23 | 22 |
import java.awt.GridBagConstraints; |
24 | 23 |
import java.awt.GridBagLayout; |
25 | 24 |
import java.awt.Insets; |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/ui/zoom/ViewRasterRequestManager.java | ||
---|---|---|
1 |
/* 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; |
|
20 |
|
|
21 |
import java.awt.Dimension; |
|
22 |
import java.awt.Graphics2D; |
|
23 |
import java.awt.geom.Point2D; |
|
24 |
import java.awt.geom.Rectangle2D; |
|
25 |
import java.awt.image.BufferedImage; |
|
26 |
|
|
27 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
|
28 |
import org.gvsig.raster.dataset.InvalidSetViewException; |
|
29 |
import org.gvsig.raster.dataset.io.RasterDriverException; |
|
30 |
import org.gvsig.raster.datastruct.Extent; |
|
31 |
import org.gvsig.raster.datastruct.ViewPortData; |
|
32 |
import org.gvsig.raster.util.RasterUtilities; |
|
33 |
import org.gvsig.rastertools.georeferencing.view.ViewDialog; |
|
34 |
|
|
35 |
/** |
|
36 |
* Gestor de peticiones de zoom sobre el panel con el raster a georreferenciar. |
|
37 |
* Implementa el interfaz IExtensionRequest para que este comunique la peticiones |
|
38 |
* de zoom y ViewRasterRequestManager pueda hacer las peticiones de datos a la capa. |
|
39 |
* |
|
40 |
* 30/12/2007 |
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
42 |
*/ |
|
43 |
public class ViewRasterRequestManager implements IExtensionRequest { |
|
44 |
private FLyrRasterSE lyr = null; |
|
45 |
private ViewDialog view = null; |
|
46 |
|
|
47 |
/** |
|
48 |
* Asigna la capa a georreferenciar de donde se obtienen los datos. |
|
49 |
* @param lyr |
|
50 |
*/ |
|
51 |
public ViewRasterRequestManager(ViewDialog view, FLyrRasterSE lyr) { |
|
52 |
this.lyr = lyr; |
|
53 |
this.view = view; |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* Calcula la extensi?n que contendr? la vista a partir del extent |
|
58 |
* m?ximo de la capa/s que contienen . Tienen en cuenta las distintan proporciones |
|
59 |
* entre vista y petici?n |
|
60 |
* @param Rectangle2D |
|
61 |
*/ |
|
62 |
public Rectangle2D initRequest(Rectangle2D extent) { |
|
63 |
double x, y, w, h; |
|
64 |
//Calculamos la extensi?n de la vista para el extent m?ximo que va a contener |
|
65 |
//teniendo en cuenta las proporciones de ambos. |
|
66 |
if(extent.getHeight() > extent.getWidth()) { |
|
67 |
y = extent.getY(); |
|
68 |
h = extent.getHeight(); |
|
69 |
w = (view.getCanvasWidth() * h) / view.getCanvasHeight(); |
|
70 |
x = extent.getCenterX() - (w / 2); |
|
71 |
} else { |
|
72 |
x = extent.getX(); |
|
73 |
w = extent.getWidth(); |
|
74 |
h = (view.getCanvasHeight() * w) / view.getCanvasWidth(); |
|
75 |
y = extent.getCenterY() - (h / 2); |
|
76 |
} |
|
77 |
Rectangle2D r = new Rectangle2D.Double(x, y, w, h); |
|
78 |
request(r); |
|
79 |
return r; |
|
80 |
} |
|
81 |
|
|
82 |
/* |
|
83 |
* (non-Javadoc) |
|
84 |
* @see org.gvsig.rastertools.georeferencing.ui.zoom.IExtensionRequest#request(java.awt.geom.Rectangle2D) |
|
85 |
*/ |
|
86 |
public Rectangle2D request(Rectangle2D extent) { |
|
87 |
if(extent == null) |
|
88 |
return lyr.getFullExtent(); |
|
89 |
|
|
90 |
//Ajustamos el extent al del raster |
|
91 |
Extent ext = new Extent(extent);//.getX(), extent.getY(), extent.getX() + extent.getWidth(), extent.getY() - extent.getHeight()); |
|
92 |
Extent extSelection = RasterUtilities.calculateAdjustedView(ext, lyr.getFullRasterExtent()); |
|
93 |
|
|
94 |
//Obtenemos el viewport y calculamos la matriz de transformaci?n |
|
95 |
ViewPortData vp = new ViewPortData( null, ext, new Dimension(view.getCanvasWidth(), view.getCanvasHeight())); |
|
96 |
vp.calculateAffineTransform(); |
|
97 |
|
|
98 |
//Calculamos el punto del canvas de la vista donde se empieza a dibujar el buffer de la imagen |
|
99 |
Point2D pt = new Point2D.Double(extSelection.getULX(), extSelection.getLRY()); |
|
100 |
vp.mat.transform(pt, pt); |
|
101 |
|
|
102 |
try { |
|
103 |
//Dibujamos a trav?s del render de la capa en un graphics como el de la vista |
|
104 |
BufferedImage initImg = new BufferedImage(view.getCanvasWidth(), view.getCanvasHeight(), BufferedImage.TYPE_INT_RGB); |
|
105 |
BufferedImage drawedImg = (BufferedImage)lyr.getRender().draw((Graphics2D)initImg.getGraphics(), vp); |
|
106 |
((Graphics2D)initImg.getGraphics()).drawImage(drawedImg, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), null); |
|
107 |
|
|
108 |
//Asignamos el buffer a dibujar al canvas |
|
109 |
if(initImg != null) |
|
110 |
setDrawParams(initImg, extent); |
|
111 |
else |
|
112 |
throw new InvalidSetViewException("Buffer de dibujado vacio"); |
|
113 |
} catch (RasterDriverException e) { |
|
114 |
} catch (InvalidSetViewException e) { |
|
115 |
} catch (InterruptedException e) { |
|
116 |
} |
|
117 |
return extent; |
|
118 |
} |
|
119 |
|
|
120 |
/* |
|
121 |
* (non-Javadoc) |
|
122 |
* @see org.gvsig.rastertools.georeferencing.ui.zoom.IExtensionRequest#fullExtent(java.awt.Dimension) |
|
123 |
*/ |
|
124 |
public void fullExtent() { |
|
125 |
this.initRequest(lyr.getFullRasterExtent().toRectangle2D()); |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* Asigna los par?metros para el control de zoom del mapa |
|
130 |
* @param img BufferedImage |
|
131 |
* @param vp ViewPort |
|
132 |
*/ |
|
133 |
public void setDrawParams(BufferedImage img, Rectangle2D extBuf) { |
|
134 |
if(view != null && lyr != null) { |
|
135 |
if(img != null) |
|
136 |
view.setPixelDrawParams(img, extBuf, extBuf.getWidth()/img.getWidth(), new Point2D.Double(extBuf.getCenterX(), extBuf.getCenterY())); |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/ui/zoom/layers/ZoomCursorGraphicLayer.java | ||
---|---|---|
1 |
/* 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.layers; |
|
20 |
|
|
21 |
import java.awt.Color; |
|
22 |
import java.awt.Graphics2D; |
|
23 |
import java.awt.event.MouseEvent; |
|
24 |
import java.awt.geom.Rectangle2D; |
|
25 |
|
|
26 |
import org.gvsig.rastertools.georeferencing.ui.zoom.IGraphicLayer; |
|
27 |
|
|
28 |
/** |
|
29 |
* Capa gr?fica que se dibuja sobre una vista de zoom un cursor |
|
30 |
* rectangular que representa una ventanta de zoom sobre la vista |
|
31 |
* 22/12/2007 |
|
32 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
33 |
*/ |
|
34 |
public class ZoomCursorGraphicLayer implements IGraphicLayer { |
|
35 |
private Color color = Color.RED; |
|
36 |
private int wCursor = 0; |
|
37 |
private int hCursor = 0; |
|
38 |
private int posX = 0; |
|
39 |
private int posY = 0; |
|
40 |
|
|
41 |
/** |
|
42 |
* Constructor. Asigna el ancho y alto del rectangulo del cursor y la |
|
43 |
* posici?n en la inicializaci?n. |
|
44 |
*/ |
|
45 |
public ZoomCursorGraphicLayer(int pX, int pY, int w, int h) { |
|
46 |
wCursor = w; |
|
47 |
hCursor = h; |
|
48 |
posX = pX; |
|
49 |
posY = pY; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* Asigna la posici?n del cursor en el canvas |
|
54 |
* @param x Posici?n en X |
|
55 |
* @param y Posici?n en Y |
|
56 |
*/ |
|
57 |
public void setCursorPosition(int x, int y) { |
|
58 |
this.posX = x; |
|
59 |
this.posY = y; |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* Asigna el tama?o del cursor en pixeles del canvas |
|
64 |
* @param w Ancho |
|
65 |
* @param h Alto |
|
66 |
*/ |
|
67 |
public void setCursorSize(int w, int h) { |
|
68 |
this.wCursor = w; |
|
69 |
this.hCursor = h; |
|
70 |
} |
|
71 |
|
|
72 |
/* |
|
73 |
* (non-Javadoc) |
|
74 |
* @see org.gvsig.rastertools.georeferencing.ui.zoom.IGraphicLayer#draw(java.awt.Graphics2D, org.gvsig.raster.datastruct.Extent, int, int) |
|
75 |
*/ |
|
76 |
public void draw(Graphics2D g, Rectangle2D ext, int w, int h) { |
|
77 |
g.setColor(Color.RED); |
|
78 |
g.drawRect(posX - (wCursor >> 1), posY - (hCursor >> 1), wCursor, hCursor); |
|
79 |
g.drawLine(posX, posY - (hCursor >> 1), posX, 0); |
|
80 |
g.drawLine(posX, posY + (hCursor >> 1), posX, h); |
|
81 |
g.drawLine(0, posY, posX - (wCursor >> 1), posY); |
|
82 |
g.drawLine(posX + (wCursor >> 1), posY, w, posY); |
|
83 |
} |
|
84 |
|
|
85 |
/* |
|
86 |
* (non-Javadoc) |
|
87 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
|
88 |
*/ |
|
89 |
public void mouseClicked(MouseEvent e) { |
|
90 |
} |
|
91 |
|
|
92 |
/* |
|
93 |
* (non-Javadoc) |
|
94 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) |
|
95 |
*/ |
|
96 |
public void mouseEntered(MouseEvent e) { |
|
97 |
} |
|
98 |
|
|
99 |
/* |
|
100 |
* (non-Javadoc) |
|
101 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) |
|
102 |
*/ |
|
103 |
public void mouseExited(MouseEvent e) { |
|
104 |
} |
|
105 |
|
|
106 |
/* |
|
107 |
* (non-Javadoc) |
|
108 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
|
109 |
*/ |
|
110 |
public void mousePressed(MouseEvent e) { |
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
/* |
|
115 |
* (non-Javadoc) |
|
116 |
* @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) |
|
117 |
*/ |
|
118 |
public void mouseReleased(MouseEvent e) { |
|
119 |
|
|
120 |
} |
|
121 |
|
|
122 |
/* |
|
123 |
* (non-Javadoc) |
|
124 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) |
|
125 |
*/ |
|
126 |
public void mouseDragged(MouseEvent e) { |
|
127 |
|
|
128 |
} |
|
129 |
|
|
130 |
/* |
|
131 |
* (non-Javadoc) |
|
132 |
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) |
|
133 |
*/ |
|
134 |
public void mouseMoved(MouseEvent e) { |
|
135 |
|
|
136 |
} |
|
137 |
|
|
138 |
/** |
|
139 |
* Obtiene el color del cursor |
|
140 |
* @return Color |
|
141 |
*/ |
|
142 |
public Color getColor() { |
|
143 |
return color; |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* Asigna el color del cursor |
|
148 |
* @param color |
|
149 |
*/ |
|
150 |
public void setColor(Color color) { |
|
151 |
this.color = color; |
|
152 |
} |
|
153 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/ui/zoom/ZoomRectangleTool.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
public class ZoomRectangleTool extends BaseViewTool implements MouseListener, MouseMotionListener { |
36 | 36 |
private Point2D initPoint = null; |
37 |
private int x = 0, y = 0, w = 0, h = 0;
|
|
37 |
private double x = 0, y = 0, w = 0, h = 0;
|
|
38 | 38 |
private Rectangle2D result = null; |
39 | 39 |
|
40 | 40 |
/** |
... | ... | |
55 | 55 |
if(initPoint == null || w == 0 || h == 0) |
56 | 56 |
return; |
57 | 57 |
g.setColor(Color.RED); |
58 |
g.drawRect(x, y, w, h);
|
|
58 |
g.drawRect((int)x, (int)y, (int)w, (int)h);
|
|
59 | 59 |
} |
60 | 60 |
|
61 | 61 |
/* |
... | ... | |
81 | 81 |
*/ |
82 | 82 |
public void mouseDragged(MouseEvent e) { |
83 | 83 |
if(selectArea) { |
84 |
x = (int)initPoint.getX();
|
|
85 |
y = (int)initPoint.getY();
|
|
84 |
x = initPoint.getX(); |
|
85 |
y = initPoint.getY(); |
|
86 | 86 |
w = Math.abs(e.getX() - x); |
87 | 87 |
h = Math.abs(e.getY() - y); |
88 | 88 |
if(e.getX() < x) |
... | ... | |
91 | 91 |
y = e.getY(); |
92 | 92 |
Graphics g1 = canvas.getGraphics(); |
93 | 93 |
g1.setColor(Color.RED); |
94 |
g1.drawRect(x, y, (int)w, (int)h);
|
|
94 |
g1.drawRect((int)x,(int)y, (int)w, (int)h);
|
|
95 | 95 |
} |
96 | 96 |
} |
97 | 97 |
|
... | ... | |
104 | 104 |
|
105 | 105 |
//Ajuste de la petici?n a la proporci?n del canvas. Esto se hace porque la relaci?n entre |
106 | 106 |
//el ancho y alto del canvas es distinta a la del cuadro que hemos pintado en pantalla. |
107 |
int centerX = x + (w / 2);
|
|
108 |
int centerY = y + (h / 2);
|
|
107 |
double centerX = x + (w / 2);
|
|
108 |
double centerY = y + (h / 2);
|
|
109 | 109 |
if(w >= h) { //La X y la W no varian |
110 | 110 |
h = (canvas.getHeight() * w) / canvas.getWidth(); |
111 | 111 |
y = centerY - (h / 2); |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/Georeferencing.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package org.gvsig.rastertools.georeferencing; |
20 | 20 |
|
21 |
import java.awt.Dimension; |
|
22 | 21 |
import java.awt.geom.Point2D; |
23 | 22 |
import java.awt.geom.Rectangle2D; |
24 | 23 |
import java.awt.image.BufferedImage; |
... | ... | |
31 | 30 |
import org.gvsig.raster.util.RasterToolsUtil; |
32 | 31 |
import org.gvsig.rastertools.georeferencing.ui.launcher.GeorefLauncherDialog; |
33 | 32 |
import org.gvsig.rastertools.georeferencing.ui.table.GCPTablePanel; |
33 |
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewRasterRequestManager; |
|
34 | 34 |
import org.gvsig.rastertools.georeferencing.view.ViewDialog; |
35 | 35 |
import org.gvsig.rastertools.georeferencing.view.ZoomMapDialog; |
36 | 36 |
import org.gvsig.rastertools.georeferencing.view.ZoomRasterDialog; |
... | ... | |
128 | 128 |
zoomPixel = new ZoomRasterDialog(smallWindowsWidth + tableWidth, posYViews, smallWindowsWidth, smallWindowsHeight); |
129 | 129 |
|
130 | 130 |
view = new ViewDialog(wViews, 0, wViews, hViews); |
131 |
viewRequestManager = new ViewRasterRequestManager(view, lyrToGeoref); |
|
131 |
view.setShowInfo(true); |
|
132 |
//Gestor de peticiones a la capa (IExtensionRequest) |
|
133 |
ViewRasterRequestManager viewRequestManager = new ViewRasterRequestManager(view, lyrToGeoref); |
|
134 |
//Asignamos al componente cual ser? su gestor de peticiones. Cada vez que se pulse un zoom el componente har? |
|
135 |
//una llamada request a su gestor de peticiones |
|
132 | 136 |
view.setExtensionRequest(viewRequestManager); |
133 | 137 |
|
134 | 138 |
/*GeoPoint gp = new GeoPoint(new Point2D.Double(100, 100), null); |
135 | 139 |
GPGraphic gpg = new GPGraphic(GPGraphic.PIXEL, gp); |
136 | 140 |
view.getPixelGraphicLayer().addGeoPoint(gpg);*/ |
137 | 141 |
|
138 |
BufferedImage imgRasterToGeoref = viewRequestManager.drawRasterLayer(new Dimension(wViews, hViews)); |
|
142 |
/*BufferedImage imgRasterToGeoref = viewRequestManager.drawRasterLayer(new Dimension(wViews, hViews));
|
|
139 | 143 |
if(imgView != null) |
140 | 144 |
setMapParams(imgView, vp); |
141 | 145 |
if(imgRasterToGeoref != null) |
142 | 146 |
setPixelParams(imgRasterToGeoref, lyrToGeoref); |
143 |
|
|
147 |
*/ |
|
144 | 148 |
PluginServices.getMDIManager().addWindow(view); |
145 | 149 |
PluginServices.getMDIManager().addWindow(table); |
146 | 150 |
PluginServices.getMDIManager().addWindow(zoomMap); |
147 | 151 |
PluginServices.getMDIManager().addWindow(zoomPixel); |
152 |
|
|
153 |
//Inicializamos la extensi?n del componente y dibujamos |
|
154 |
viewRequestManager.initRequest(lyrToGeoref.getFullExtent()); |
|
155 |
view.setZoomCursorSize(zoomPixel.getCanvasWidth(), zoomPixel.getCanvasHeight()); |
|
148 | 156 |
} |
149 | 157 |
|
150 | 158 |
/** |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/view/ZoomMapDialog.java | ||
---|---|---|
24 | 24 |
import java.awt.geom.Rectangle2D; |
25 | 25 |
import java.awt.image.BufferedImage; |
26 | 26 |
|
27 |
import javax.swing.JPanel; |
|
28 |
|
|
29 | 27 |
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewControl; |
30 | 28 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.CenterPointGraphicLayer; |
31 | 29 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.GPGraphic; |
... | ... | |
40 | 38 |
* 22/12/2007 |
41 | 39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
42 | 40 |
*/ |
43 |
public class ZoomMapDialog extends JPanel implements IWindow {
|
|
41 |
public class ZoomMapDialog extends BaseZoomView implements IWindow {
|
|
44 | 42 |
private static final long serialVersionUID = 1L; |
45 |
private ViewControl zoomMapControl = null; |
|
46 | 43 |
private CenterPointGraphicLayer mapGraphicLayer = null; |
47 | 44 |
|
48 | 45 |
private int w = 320; |
... | ... | |
103 | 100 |
* @return |
104 | 101 |
*/ |
105 | 102 |
public ViewControl getZoomMapControl() { |
106 |
if(zoomMapControl == null) {
|
|
107 |
zoomMapControl = new ViewControl(ViewControl.RIGHT_CONTROL);
|
|
108 |
zoomMapControl.hideButton(ViewControl.PREV_ZOOM);
|
|
109 |
zoomMapControl.hideButton(ViewControl.FULL_VIEW);
|
|
110 |
zoomMapControl.hideButton(ViewControl.SELECT_ZOOM_AREA);
|
|
103 |
if(zoomPixelControl == null) {
|
|
104 |
zoomPixelControl = new ViewControl(ViewControl.RIGHT_CONTROL);
|
|
105 |
zoomPixelControl.hideButton(ViewControl.PREV_ZOOM);
|
|
106 |
zoomPixelControl.hideButton(ViewControl.FULL_VIEW);
|
|
107 |
zoomPixelControl.hideButton(ViewControl.SELECT_ZOOM_AREA);
|
|
111 | 108 |
} |
112 |
return zoomMapControl;
|
|
109 |
return zoomPixelControl;
|
|
113 | 110 |
} |
114 | 111 |
|
115 | 112 |
/** |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/view/ZoomRasterDialog.java | ||
---|---|---|
24 | 24 |
import java.awt.geom.Rectangle2D; |
25 | 25 |
import java.awt.image.BufferedImage; |
26 | 26 |
|
27 |
import javax.swing.JPanel; |
|
28 |
|
|
29 | 27 |
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewControl; |
30 | 28 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.CenterPointGraphicLayer; |
31 | 29 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.GPGraphic; |
... | ... | |
40 | 38 |
* 22/12/2007 |
41 | 39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
42 | 40 |
*/ |
43 |
public class ZoomRasterDialog extends JPanel implements IWindow {
|
|
41 |
public class ZoomRasterDialog extends BaseZoomView implements IWindow {
|
|
44 | 42 |
private static final long serialVersionUID = 1L; |
45 |
private ViewControl zoomPixelControl = null; |
|
46 | 43 |
private CenterPointGraphicLayer pixelGraphicLayer = null; |
47 | 44 |
|
48 | 45 |
private int w = 320; |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/view/BaseZoomView.java | ||
---|---|---|
1 |
/* 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.view; |
|
20 |
|
|
21 |
import java.awt.Graphics2D; |
|
22 |
|
|
23 |
import javax.swing.JPanel; |
|
24 |
|
|
25 |
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewControl; |
|
26 |
|
|
27 |
/** |
|
28 |
* Clase de la que heredan los dialogos de vista y zoom que utilizan |
|
29 |
* el ViewControl. Contiene m?todos generales para el acceso a informaci?n |
|
30 |
* del control. |
|
31 |
* |
|
32 |
* 20/01/2008 |
|
33 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
34 |
*/ |
|
35 |
public abstract class BaseZoomView extends JPanel { |
|
36 |
protected ViewControl zoomPixelControl = null; |
|
37 |
|
|
38 |
/** |
|
39 |
* Obtiene el graphics del canvas |
|
40 |
* @return |
|
41 |
*/ |
|
42 |
public Graphics2D getCanvasGraphic() { |
|
43 |
return (Graphics2D)zoomPixelControl.getCanvas().getGraphics(); |
|
44 |
} |
|
45 |
|
|
46 |
/** |
|
47 |
* Obtiene el ancho del canvas |
|
48 |
* @return |
|
49 |
*/ |
|
50 |
public int getCanvasWidth() { |
|
51 |
return zoomPixelControl.getCanvasWith(); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Obtiene el alto del canvas |
|
56 |
* @return |
|
57 |
*/ |
|
58 |
public int getCanvasHeight() { |
|
59 |
return zoomPixelControl.getCanvasHeight(); |
|
60 |
} |
|
61 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/view/ViewDialog.java | ||
---|---|---|
19 | 19 |
package org.gvsig.rastertools.georeferencing.view; |
20 | 20 |
|
21 | 21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Graphics2D; |
|
23 | 22 |
import java.awt.geom.Point2D; |
24 | 23 |
import java.awt.geom.Rectangle2D; |
25 | 24 |
import java.awt.image.BufferedImage; |
26 | 25 |
|
27 |
import javax.swing.JPanel; |
|
28 |
|
|
29 | 26 |
import org.gvsig.rastertools.georeferencing.ui.zoom.IExtensionRequest; |
30 | 27 |
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewControl; |
31 | 28 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.GCPsGraphicLayer; |
32 | 29 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.GPGraphic; |
30 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.ZoomCursorGraphicLayer; |
|
33 | 31 |
|
34 | 32 |
import com.iver.andami.PluginServices; |
35 | 33 |
import com.iver.andami.ui.mdiManager.IWindow; |
... | ... | |
41 | 39 |
* 22/12/2007 |
42 | 40 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
43 | 41 |
*/ |
44 |
public class ViewDialog extends JPanel implements IWindow {
|
|
42 |
public class ViewDialog extends BaseZoomView implements IWindow {
|
|
45 | 43 |
private static final long serialVersionUID = 1L; |
46 |
private ViewControl zoomPixelControl = null; |
|
47 | 44 |
private GCPsGraphicLayer graphicLayer = null; |
45 |
private ZoomCursorGraphicLayer zoomCursorGraphic = null; |
|
48 | 46 |
private int w = 640; |
49 | 47 |
private int h = 100; |
50 | 48 |
private int posX = 0; |
... | ... | |
91 | 89 |
setLayout(new BorderLayout()); |
92 | 90 |
add(getZoomPixelControl(), BorderLayout.CENTER); |
93 | 91 |
getPixelGraphicLayer(); |
92 |
getZoomCursorGraphicLayer(); |
|
94 | 93 |
} |
95 | 94 |
|
96 | 95 |
/** |
... | ... | |
140 | 139 |
} |
141 | 140 |
|
142 | 141 |
/** |
143 |
* Obtiene el ancho del canvas |
|
144 |
* @return |
|
145 |
*/ |
|
146 |
public int getCanvasWith() { |
|
147 |
return zoomPixelControl.getCanvasWith(); |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* Obtiene el alto del canvas |
|
142 |
* Obtiene el la capa gr?fica con la ventana de zoom |
|
152 | 143 |
* @return |
153 | 144 |
*/ |
154 |
public int getCanvasHeight() { |
|
155 |
return zoomPixelControl.getCanvasHeight(); |
|
145 |
public ZoomCursorGraphicLayer getZoomCursorGraphicLayer() { |
|
146 |
if(zoomCursorGraphic == null) { |
|
147 |
zoomCursorGraphic = new ZoomCursorGraphicLayer(w / 2, h / 2, 40, 20); |
|
148 |
getZoomPixelControl().setGraphicLayer(zoomCursorGraphic); |
|
149 |
} |
|
150 |
return zoomCursorGraphic; |
|
156 | 151 |
} |
157 |
|
|
152 |
|
|
158 | 153 |
/** |
159 |
* Obtiene el graphics del canvas |
|
160 |
* @return |
|
161 |
*/ |
|
162 |
public Graphics2D getCanvasGraphic() { |
|
163 |
return (Graphics2D)zoomPixelControl.getCanvas().getGraphics(); |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 | 154 |
* Activa o desactiva el mostrado de informaci?n |
168 | 155 |
* @param showInfo |
169 | 156 |
*/ |
... | ... | |
171 | 158 |
zoomPixelControl.getCanvas().setShowInfo(show); |
172 | 159 |
} |
173 | 160 |
|
161 |
/** |
|
162 |
* Asigna el ancho y el alto de la ventana del cursor |
|
163 |
* @param w Ancho |
|
164 |
* @param h Alto |
|
165 |
*/ |
|
166 |
public void setZoomCursorSize(int w, int h) { |
|
167 |
getZoomCursorGraphicLayer().setCursorSize(w, h); |
|
168 |
} |
|
169 |
|
|
174 | 170 |
/* |
175 | 171 |
* (non-Javadoc) |
176 | 172 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo() |
Also available in: Unified diff