Revision 18277 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/Georeferencing.java
Georeferencing.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package org.gvsig.rastertools.georeferencing; |
20 | 20 |
|
21 |
import java.awt.geom.Point2D; |
|
22 | 21 |
import java.awt.geom.Rectangle2D; |
23 | 22 |
import java.awt.image.BufferedImage; |
24 | 23 |
import java.util.ArrayList; |
... | ... | |
31 | 30 |
import org.gvsig.rastertools.georeferencing.ui.launcher.GeorefLauncherDialog; |
32 | 31 |
import org.gvsig.rastertools.georeferencing.ui.table.GCPTablePanel; |
33 | 32 |
import org.gvsig.rastertools.georeferencing.ui.zoom.InvalidRequestException; |
33 |
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewMapRequestManager; |
|
34 | 34 |
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewRasterRequestManager; |
35 | 35 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.ZoomCursorGraphicLayer; |
36 | 36 |
import org.gvsig.rastertools.georeferencing.ui.zoom.tools.ToolEvent; |
... | ... | |
44 | 44 |
import com.iver.andami.ui.mdiManager.IWindow; |
45 | 45 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
46 | 46 |
import com.iver.cit.gvsig.ProjectExtension; |
47 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
47 | 48 |
import com.iver.cit.gvsig.fmap.ViewPort; |
48 | 49 |
import com.iver.cit.gvsig.project.Project; |
49 | 50 |
import com.iver.cit.gvsig.project.documents.view.ProjectView; |
... | ... | |
76 | 77 |
|
77 | 78 |
private GeorefLauncherDialog initDialog = null; |
78 | 79 |
private FLyrRasterSE lyrToGeoref = null; |
80 |
private String selectedView = null; |
|
79 | 81 |
private static GCPTablePanel table = null; |
80 |
private static ZoomMapDialog zoomMap = null; |
|
81 |
private static ZoomRasterDialog zoomPixel = null; |
|
82 |
private static ViewDialog view = null; |
|
82 |
|
|
83 | 83 |
private static final int smallWindowsHeight = 100; |
84 | 84 |
private static final double smallWindowsWidthPercent = 0.5; |
85 |
private ViewRasterRequestManager viewRequestManager = null; |
|
86 |
private ViewRasterRequestManager viewRequestManagerZoomPixel = null; |
|
87 | 85 |
|
86 |
private static ViewDialog viewRaster = null; |
|
87 |
private static ViewDialog viewMap = null; |
|
88 |
|
|
89 |
private static ZoomMapDialog zoomMap = null; |
|
90 |
private static ZoomRasterDialog zoomPixel = null; |
|
91 |
|
|
92 |
private ViewRasterRequestManager viewRasterRequestManager = null; |
|
93 |
private ViewMapRequestManager viewMapRequestManager = null; |
|
94 |
|
|
95 |
private ViewRasterRequestManager zoomRasterRequestManager = null; |
|
96 |
private ViewMapRequestManager zoomMapRequestManager = null; |
|
97 |
|
|
88 | 98 |
public Georeferencing() { |
89 | 99 |
|
90 | 100 |
} |
... | ... | |
104 | 114 |
int smallWindowsWidth = (int)(p.getWidth() * (smallWindowsWidthPercent * 0.5)); |
105 | 115 |
int tableWidth = (int)(p.getWidth() * (1 - smallWindowsWidthPercent)); |
106 | 116 |
|
117 |
//Si hay ventanas de georreferenciaci?n abiertas las cerramos |
|
118 |
if(zoomMap != null) |
|
119 |
PluginServices.getMDIManager().closeWindow(zoomMap); |
|
120 |
if(zoomPixel != null) |
|
121 |
PluginServices.getMDIManager().closeWindow(zoomPixel); |
|
122 |
if(viewRaster != null) |
|
123 |
PluginServices.getMDIManager().closeWindow(viewRaster); |
|
124 |
if(viewRaster != null) |
|
125 |
PluginServices.getMDIManager().closeWindow(viewMap); |
|
126 |
if(table != null) |
|
127 |
PluginServices.getMDIManager().closeWindow(table); |
|
128 |
|
|
129 |
MapControl mapControl = null; |
|
107 | 130 |
IWindow[] windowList = PluginServices.getMDIManager().getAllWindows(); |
108 | 131 |
BufferedImage imgView = null; |
109 | 132 |
ViewPort vp = null; |
110 | 133 |
for (int i = 0; i < windowList.length; i++) { |
111 |
if(windowList[i] instanceof IView) { |
|
134 |
if(windowList[i] instanceof IView && windowList[i].getWindowInfo().getTitle().endsWith(": " + selectedView)) {
|
|
112 | 135 |
WindowInfo info = windowList[i].getWindowInfo(); |
136 |
|
|
113 | 137 |
info.setX(0); |
114 | 138 |
info.setY(0); |
115 | 139 |
info.setWidth(wViews); |
116 | 140 |
info.setHeight(posYViews); |
117 | 141 |
|
142 |
mapControl = ((IView)windowList[i]).getMapControl(); |
|
118 | 143 |
imgView = ((IView)windowList[i]).getMapControl().getImage(); |
119 | 144 |
vp = ((IView)windowList[i]).getMapControl().getViewPort(); |
120 | 145 |
} |
121 | 146 |
} |
122 |
if(zoomMap != null) |
|
123 |
PluginServices.getMDIManager().closeWindow(zoomMap); |
|
124 |
if(zoomPixel != null) |
|
125 |
PluginServices.getMDIManager().closeWindow(zoomPixel); |
|
126 |
if(view != null) |
|
127 |
PluginServices.getMDIManager().closeWindow(view); |
|
128 |
if(table != null) |
|
129 |
PluginServices.getMDIManager().closeWindow(table); |
|
130 | 147 |
|
131 | 148 |
table = new GCPTablePanel(smallWindowsWidth, posYViews, tableWidth, smallWindowsHeight); |
132 | 149 |
|
150 |
//Inicializaci?n de la vista mapa |
|
151 |
viewMap = new ViewDialog(0, 0, wViews, hViews, this); |
|
152 |
viewMap.setShowInfo(true); |
|
153 |
viewMapRequestManager = new ViewMapRequestManager(viewMap, mapControl); |
|
154 |
viewMap.setExtensionRequest(viewMapRequestManager); |
|
155 |
|
|
133 | 156 |
//Inicializaci?n de la vista raster |
134 |
view = new ViewDialog(wViews, 0, wViews, hViews, this); |
|
135 |
view.setShowInfo(true); |
|
136 |
viewRequestManager = new ViewRasterRequestManager(view, lyrToGeoref);
|
|
137 |
view.setExtensionRequest(viewRequestManager);
|
|
157 |
viewRaster = new ViewDialog(wViews, 0, wViews, hViews, this);
|
|
158 |
viewRaster.setShowInfo(true);
|
|
159 |
viewRasterRequestManager = new ViewRasterRequestManager(viewRaster, lyrToGeoref);
|
|
160 |
viewRaster.setExtensionRequest(viewRasterRequestManager);
|
|
138 | 161 |
|
139 | 162 |
//Inicializaci?n del zoom de la vista raster |
140 | 163 |
zoomPixel = new ZoomRasterDialog(smallWindowsWidth + tableWidth, posYViews, smallWindowsWidth, smallWindowsHeight); |
141 |
viewRequestManagerZoomPixel = new ViewRasterRequestManager(zoomPixel, lyrToGeoref);
|
|
142 |
zoomPixel.setExtensionRequest(viewRequestManagerZoomPixel);
|
|
164 |
zoomRasterRequestManager = new ViewRasterRequestManager(zoomPixel, lyrToGeoref);
|
|
165 |
zoomPixel.setExtensionRequest(zoomRasterRequestManager);
|
|
143 | 166 |
|
144 | 167 |
//Inicializaci?n del zoom de la vista de referencia |
145 | 168 |
zoomMap = new ZoomMapDialog(0, posYViews, smallWindowsWidth, smallWindowsHeight); |
169 |
zoomMapRequestManager = new ViewMapRequestManager(zoomMap, mapControl); |
|
170 |
zoomMap.setExtensionRequest(zoomMapRequestManager); |
|
146 | 171 |
|
147 | 172 |
/*GeoPoint gp = new GeoPoint(new Point2D.Double(100, 100), null); |
148 | 173 |
GPGraphic gpg = new GPGraphic(GPGraphic.PIXEL, gp); |
149 |
view.getPixelGraphicLayer().addGeoPoint(gpg);*/ |
|
174 |
view.getPixelGraphicLayer().addGeoPoint(gpg); |
|
175 |
*/ |
|
150 | 176 |
|
151 |
/*BufferedImage imgRasterToGeoref = viewRequestManager.drawRasterLayer(new Dimension(wViews, hViews)); |
|
152 |
if(imgView != null) |
|
153 |
setMapParams(imgView, vp); |
|
154 |
if(imgRasterToGeoref != null) |
|
155 |
setPixelParams(imgRasterToGeoref, lyrToGeoref); |
|
156 |
*/ |
|
157 | 177 |
//A?adimos las ventanas a gvSIG |
158 |
PluginServices.getMDIManager().addWindow(view); |
|
178 |
PluginServices.getMDIManager().addWindow(viewRaster); |
|
179 |
PluginServices.getMDIManager().addWindow(viewMap); |
|
159 | 180 |
PluginServices.getMDIManager().addWindow(table); |
160 | 181 |
PluginServices.getMDIManager().addWindow(zoomMap); |
161 | 182 |
PluginServices.getMDIManager().addWindow(zoomPixel); |
162 | 183 |
|
163 |
//Inicializamos la extensi?n del componente y dibujamos |
|
164 | 184 |
try { |
165 |
viewRequestManager.initRequest(lyrToGeoref.getFullExtent());/*new Rectangle2D.Double( lyrToGeoref.getFullRasterExtent().getULX(), |
|
166 |
lyrToGeoref.getFullRasterExtent().getULY(), |
|
167 |
lyrToGeoref.getFullRasterExtent().width(), |
|
168 |
lyrToGeoref.getFullRasterExtent().height()));*/ |
|
169 |
view.setZoomCursorSize(zoomPixel.getCanvasWidth() / 3, zoomPixel.getCanvasHeight() / 3); |
|
185 |
//Inicializamos la vista de mapa |
|
186 |
viewMapRequestManager.initRequest(mapControl.getMapContext().getLayers().getFullExtent()); |
|
187 |
viewMap.setZoomCursorSize(zoomMap.getCanvasWidth() / 3, zoomMap.getCanvasHeight() / 3); |
|
188 |
|
|
189 |
//Inicializamos la vista de raster |
|
190 |
viewRasterRequestManager.initRequest(lyrToGeoref.getFullExtent()); |
|
191 |
viewRaster.setZoomCursorSize(zoomPixel.getCanvasWidth() / 3, zoomPixel.getCanvasHeight() / 3); |
|
170 | 192 |
|
171 |
Rectangle2D ext = view.getCursorAdjustedWorldCoordinates(zoomPixel.getCanvasWidth(), zoomPixel.getCanvasHeight()); |
|
172 |
viewRequestManagerZoomPixel.initRequest(lyrToGeoref.getFullExtent()); |
|
173 |
//viewRequestManagerZoomPixel.setDrawParams(null, new Rectangle2D.Double(ext.getX(), ext.getY() - ext.getHeight(), ext.getWidth(), ext.getHeight())); |
|
174 |
viewRequestManagerZoomPixel.request(ext); |
|
193 |
//Inicializamos el zoom de mapa |
|
194 |
Rectangle2D mapExtent = mapControl.getMapContext().getFullExtent(); |
|
195 |
Rectangle2D ext = viewMap.getCursorAdjustedWorldCoordinates(zoomMap.getCanvasWidth(), zoomMap.getCanvasHeight()); |
|
196 |
zoomMapRequestManager.initRequest(mapControl.getMapContext().getFullExtent()); |
|
197 |
zoomMapRequestManager.request(new Rectangle2D.Double(ext.getX(), mapExtent.getMaxY() - (mapExtent.getMinY() - ext.getY()), ext.getWidth(), ext.getHeight())); |
|
198 |
|
|
199 |
//Inicializamos el zoom de raster |
|
200 |
ext = viewRaster.getCursorAdjustedWorldCoordinates(zoomPixel.getCanvasWidth(), zoomPixel.getCanvasHeight()); |
|
201 |
zoomRasterRequestManager.initRequest(lyrToGeoref.getFullExtent()); |
|
202 |
zoomRasterRequestManager.request(new Rectangle2D.Double(ext.getX(), lyrToGeoref.getFullRasterExtent().maxY() - (lyrToGeoref.getFullRasterExtent().minY() - ext.getY()), ext.getWidth(), ext.getHeight())); |
|
175 | 203 |
} catch (InvalidRequestException e1) { |
176 | 204 |
RasterToolsUtil.messageBoxError("error_setview_preview", this); |
205 |
}catch (Exception e1) { |
|
206 |
RasterToolsUtil.messageBoxError("error_setview_preview", this); |
|
177 | 207 |
} |
178 | 208 |
|
179 | 209 |
} |
180 | 210 |
|
181 | 211 |
/** |
182 |
* Obtiene y asigna los par?metros para el control de zoom del mapa |
|
183 |
* @param img BufferedImage |
|
184 |
* @param vp ViewPort |
|
185 |
*/ |
|
186 |
public void setMapParams(BufferedImage img, ViewPort vp) { |
|
187 |
if(zoomMap != null && img != null) { |
|
188 |
Rectangle2D r = vp.getAdjustedExtent(); |
|
189 |
int w = vp.getImageWidth(); |
|
190 |
zoomMap.setDrawParams(img, r, r.getWidth() / w, new Point2D.Double(r.getCenterX(), r.getCenterY())); |
|
191 |
zoomMap.getMapGraphicLayer(); |
|
192 |
} |
|
193 |
} |
|
194 |
|
|
195 |
/** |
|
196 |
* Obtiene y asigna los par?metros para el control de zoom del mapa |
|
197 |
* @param img BufferedImage |
|
198 |
* @param vp ViewPort |
|
199 |
*/ |
|
200 |
public void setPixelParams(BufferedImage img, FLyrRasterSE lyr) { |
|
201 |
if(view != null && zoomPixel != null && img != null && lyr != null) { |
|
202 |
Rectangle2D extBuf; |
|
203 |
try { |
|
204 |
extBuf = viewRequestManager.request(null); |
|
205 |
viewRequestManager.setDrawParams(img, extBuf); |
|
206 |
zoomPixel.setDrawParams(img, extBuf, extBuf.getHeight()/img.getHeight(), new Point2D.Double(extBuf.getCenterX(), extBuf.getCenterY())); |
|
207 |
zoomPixel.getPixelGraphicLayer(); |
|
208 |
} catch (InvalidRequestException e1) { |
|
209 |
RasterToolsUtil.messageBoxError("error_setview_preview", this); |
|
210 |
} |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
/** |
|
215 | 212 |
* Lanzador del cuadro de inicializaci?n de propiedades de georreferenciaci?n. |
216 | 213 |
*/ |
217 | 214 |
private void launcher() { |
... | ... | |
232 | 229 |
// Bot?n de Aceptar |
233 | 230 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) { |
234 | 231 |
if(initDialog != null) { |
232 |
selectedView = initDialog.getSelectedView(); |
|
235 | 233 |
lyrToGeoref = initDialog.getLayer(); |
236 | 234 |
if(lyrToGeoref == null) |
237 | 235 |
RasterToolsUtil.messageBoxError("layer_not_loaded", this); |
... | ... | |
255 | 253 |
public void endAction(ToolEvent ev) { |
256 | 254 |
if(ev.getSource() instanceof ZoomCursorGraphicLayer) { |
257 | 255 |
try { |
258 |
Rectangle2D ext = view.getCursorAdjustedWorldCoordinates(zoomPixel.getCanvasWidth(), zoomPixel.getCanvasHeight()); |
|
259 |
viewRequestManagerZoomPixel.request(ext); |
|
256 |
Rectangle2D ext = viewRaster.getCursorAdjustedWorldCoordinates(zoomPixel.getCanvasWidth(), zoomPixel.getCanvasHeight()); |
|
257 |
zoomRasterRequestManager.request(ext); |
|
258 |
ext = viewMap.getCursorAdjustedWorldCoordinates(zoomMap.getCanvasWidth(), zoomMap.getCanvasHeight()); |
|
259 |
zoomMapRequestManager.request(ext); |
|
260 | 260 |
} catch (InvalidRequestException e1) { |
261 | 261 |
RasterToolsUtil.messageBoxError("error_setview_preview", this); |
262 | 262 |
} |
Also available in: Unified diff