root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / clipping / ui / listener / ClippingPanelListener.java @ 20650
History | View | Annotate | Download (35.2 KB)
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.clipping.ui.listener; |
20 |
|
21 |
import java.awt.Component; |
22 |
import java.awt.Cursor; |
23 |
import java.awt.Dimension; |
24 |
import java.awt.event.ActionEvent; |
25 |
import java.awt.event.ActionListener; |
26 |
import java.awt.geom.AffineTransform; |
27 |
import java.awt.geom.NoninvertibleTransformException; |
28 |
import java.awt.geom.Point2D; |
29 |
import java.awt.geom.Rectangle2D; |
30 |
import java.io.File; |
31 |
import java.util.ArrayList; |
32 |
import java.util.EventObject; |
33 |
|
34 |
import javax.swing.JFrame; |
35 |
import javax.swing.JOptionPane; |
36 |
|
37 |
import org.apache.log4j.Logger; |
38 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
39 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
40 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
41 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
42 |
import org.gvsig.gui.beans.coordinatespanel.CoordinatesEvent; |
43 |
import org.gvsig.gui.beans.coordinatespanel.CoordinatesListener; |
44 |
import org.gvsig.gui.beans.coordinatespanel.CoordinatesPanel; |
45 |
import org.gvsig.gui.beans.datainput.DataInputContainerListener; |
46 |
import org.gvsig.gui.beans.table.models.CheckBoxModel; |
47 |
import org.gvsig.raster.IProcessActions; |
48 |
import org.gvsig.raster.RasterLibrary; |
49 |
import org.gvsig.raster.RasterProcess; |
50 |
import org.gvsig.raster.buffer.WriterBufferServer; |
51 |
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation; |
52 |
import org.gvsig.raster.datastruct.Extent; |
53 |
import org.gvsig.raster.grid.roi.ROI; |
54 |
import org.gvsig.raster.util.RasterToolsUtil; |
55 |
import org.gvsig.raster.util.RasterUtilities; |
56 |
import org.gvsig.raster.util.process.ClippingProcess; |
57 |
import org.gvsig.rastertools.clipping.panels.ClippingCoordinatesPanel; |
58 |
import org.gvsig.rastertools.clipping.panels.ClippingOptionsPanel; |
59 |
import org.gvsig.rastertools.clipping.panels.ClippingResolutionPanel; |
60 |
import org.gvsig.rastertools.clipping.panels.ClippingSelectionPanel; |
61 |
import org.gvsig.rastertools.clipping.ui.ClippingPanel; |
62 |
import org.gvsig.rastertools.saveraster.ui.info.EndInfoPanel; |
63 |
|
64 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
65 |
import com.iver.andami.PluginServices; |
66 |
import com.iver.andami.Utilities; |
67 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
68 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
69 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
70 |
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent; |
71 |
import com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener; |
72 |
/**
|
73 |
* <code>ClippingPanelListener</code> es una clase donde se recoger?n y
|
74 |
* tratar?n todos los eventos del panel de recorte
|
75 |
*
|
76 |
* @version 19/04/2007
|
77 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
78 |
*/
|
79 |
public class ClippingPanelListener implements ActionListener, RectangleListener, ButtonsPanelListener, CoordinatesListener, DataInputContainerListener, IProcessActions { |
80 |
private Dimension dim = new Dimension(); |
81 |
private AffineTransform at = null; |
82 |
private ClippingPanel clippingPanel = null; |
83 |
private int widthPx = 0; |
84 |
private int heightPx = 0; |
85 |
private boolean enableValueChangedEvent = true; |
86 |
/**
|
87 |
* Crea un nuevo <code>ClippingPanelListener</code> con el
|
88 |
* <code>ClippingPanelListener</code> asociado
|
89 |
* @param panel
|
90 |
*/
|
91 |
public ClippingPanelListener(ClippingPanel clippingPanel) {
|
92 |
this.clippingPanel = clippingPanel;
|
93 |
} |
94 |
|
95 |
/**
|
96 |
* Asigna la matriz de transformaci?n entre puntos en coordenadas del raster y
|
97 |
* puntos en coordenadas reales.
|
98 |
* @param AffineTransform
|
99 |
*/
|
100 |
public void setAffineTransform(AffineTransform at) { |
101 |
this.at = at;
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* Asigna la dimensi?n del raster
|
106 |
* @param dim
|
107 |
*/
|
108 |
public void setDimension(Dimension dim) { |
109 |
this.dim = dim;
|
110 |
} |
111 |
|
112 |
/**
|
113 |
* M?todo que se invoca cuando se disparan los eventos de los botones de
|
114 |
* extensi?n completa o de seleccion de extensi?n con el rat?n
|
115 |
*/
|
116 |
public void actionPerformed(ActionEvent e) { |
117 |
// Bot?n de selecci?n del extent completo
|
118 |
// Modificamos las coordenadas reales y recalculamos las coordenadas pixel
|
119 |
if (e.getSource() == getResolutionPanel().getButtonRestore()) {
|
120 |
getClippingPanel().restoreStatusText(); |
121 |
} |
122 |
|
123 |
//Bot?n de selecci?n del ?rea m?xima asociada a los ROIs
|
124 |
if (e.getSource() == getCoordinatesPanel().getButtonBarContainer().getButton(0)) { |
125 |
FLayer lyr = getClippingPanel().getFLayer(); |
126 |
if(lyr instanceof FLyrRasterSE) { |
127 |
ArrayList roiList = ((FLyrRasterSE)lyr).getRois();
|
128 |
if(roiList != null && roiList.size() > 0) { |
129 |
Extent ext = getMaximunExtent(roiList); |
130 |
assignROISExtent(ext, ((FLyrRasterSE)lyr)); |
131 |
} else
|
132 |
assignFullExtent(); |
133 |
} |
134 |
return;
|
135 |
} |
136 |
|
137 |
// Bot?n de selecci?n del extent completo
|
138 |
// Modificamos las coordenadas reales y recalculamos las coordenadas pixel
|
139 |
if (e.getSource() == getCoordinatesPanel().getButtonBarContainer().getButton(1)) { |
140 |
assignFullExtent(); |
141 |
return;
|
142 |
} |
143 |
|
144 |
// Bot?n de selecci?n de la herramienta de seleccionar desde la vista
|
145 |
if (e.getSource() == getCoordinatesPanel().getButtonBarContainer().getButton(2)) { |
146 |
getClippingPanel().selectToolButton(); |
147 |
return;
|
148 |
} |
149 |
|
150 |
} |
151 |
|
152 |
/**
|
153 |
* Asigna el extent completo a los cuadros de texto donde se introducen las coordenadas
|
154 |
* reales y p?xel.
|
155 |
*/
|
156 |
private void assignROISExtent(Extent ext, FLyrRasterSE layer) { |
157 |
AffineTransform at = layer.getAffineTransform();
|
158 |
Point2D ulPx = new Point2D.Double(ext.minX(), ext.maxY()); |
159 |
Point2D lrPx = new Point2D.Double(ext.maxX(), ext.minY()); |
160 |
Point2D urPx = new Point2D.Double(ext.maxX(), ext.maxY()); |
161 |
Point2D llPx = new Point2D.Double(ext.minX(), ext.minY()); |
162 |
|
163 |
try {
|
164 |
at.inverseTransform(ulPx, ulPx); |
165 |
at.inverseTransform(lrPx, lrPx); |
166 |
at.inverseTransform(urPx, urPx); |
167 |
at.inverseTransform(llPx, llPx); |
168 |
} catch (NoninvertibleTransformException e) { |
169 |
JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "coordenadas_erroneas")); |
170 |
return;
|
171 |
} |
172 |
|
173 |
Point2D[] pointList = new Point2D[]{ulPx, lrPx, urPx, llPx}; |
174 |
Point2D dim = new Point2D.Double(layer.getPxWidth(), layer.getPxHeight()); |
175 |
|
176 |
//Ajustamos los puntos al ?rea en pixeles del raster
|
177 |
RasterUtilities.adjustToPixelSize(pointList, dim); |
178 |
|
179 |
double minX = Math.min(ulPx.getX(), lrPx.getX()); |
180 |
double maxX = Math.max(ulPx.getX(), lrPx.getX()); |
181 |
double minY = Math.min(ulPx.getY(), lrPx.getY()); |
182 |
double maxY = Math.max(ulPx.getY(), lrPx.getY()); |
183 |
|
184 |
//Convertimos nuevamente a coordenadas reales
|
185 |
Point2D ulWc = new Point2D.Double(); |
186 |
Point2D lrWc = new Point2D.Double(); |
187 |
at.transform(new Point2D.Double(minX, minY), ulWc); |
188 |
at.transform(new Point2D.Double(maxX + 1, maxY + 1), lrWc); |
189 |
|
190 |
getClippingPanel().setCoorRealFromDouble(ulWc.getX(), ulWc.getY(), lrWc.getX(), lrWc.getY(), 3);
|
191 |
|
192 |
getClippingPanel().setCoorPixelFromDouble(minX, minY, maxX, maxY, 3);
|
193 |
getClippingPanel().getClippingPanelListener().setEnableValueChangedEvent(false);
|
194 |
getClippingPanel().setWidthText(Math.abs(maxX - minX), 0); |
195 |
getClippingPanel().setHeightText(Math.abs(maxY - minY), 0); |
196 |
getClippingPanel().setCellSizeText(Math.abs(ulWc.getX() - lrWc.getX()) / Math.abs(maxX - minX), 4); |
197 |
getClippingPanel().getClippingPanelListener().setEnableValueChangedEvent(true);
|
198 |
getClippingPanel().setRelWidthHeight((double) (Math.abs(maxX - minX) / Math.abs(maxY - minY))); |
199 |
getClippingPanel().saveStatusText(); |
200 |
|
201 |
getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(true);
|
202 |
getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(true);
|
203 |
} |
204 |
|
205 |
/**
|
206 |
* Asigna el extent completo a los cuadros de texto donde se introducen las coordenadas
|
207 |
* reales y p?xel.
|
208 |
*/
|
209 |
private void assignFullExtent() { |
210 |
Point2D ulPx = new Point2D.Double(0, 0); |
211 |
Point2D lrPx = new Point2D.Double(dim.width, dim.height); |
212 |
|
213 |
double minX = Math.min(ulPx.getX(), lrPx.getX()); |
214 |
double maxX = Math.max(ulPx.getX(), lrPx.getX()); |
215 |
double minY = Math.min(ulPx.getY(), lrPx.getY()); |
216 |
double maxY = Math.max(ulPx.getY(), lrPx.getY()); |
217 |
|
218 |
//Convertimos nuevamente a coordenadas reales
|
219 |
Point2D ulWc = new Point2D.Double(); |
220 |
Point2D lrWc = new Point2D.Double(); |
221 |
at.transform(new Point2D.Double(minX, minY), ulWc); |
222 |
at.transform(new Point2D.Double(maxX, maxY), lrWc); |
223 |
|
224 |
getClippingPanel().setCoorRealFromDouble(ulWc.getX(), ulWc.getY(), lrWc.getX(), lrWc.getY(), 3);
|
225 |
getClippingPanel().setCoorPixelFromDouble(0, 0, dim.width - 1, dim.height - 1, 3); |
226 |
getClippingPanel().getClippingPanelListener().setEnableValueChangedEvent(false);
|
227 |
getClippingPanel().setWidthText(Math.abs(maxX - minX), 0); |
228 |
getClippingPanel().setHeightText(Math.abs(maxY - minY), 0); |
229 |
getClippingPanel().setCellSizeText(((lrWc.getX() - ulWc.getX()) / dim.width), 4);
|
230 |
getClippingPanel().getClippingPanelListener().setEnableValueChangedEvent(true);
|
231 |
getClippingPanel().setRelWidthHeight((double) (dim.getWidth() / dim.getHeight()));
|
232 |
getClippingPanel().saveStatusText(); |
233 |
|
234 |
getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(true);
|
235 |
getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(true);
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* Obtiene el extent m?ximo de todas las ROIs
|
240 |
* @param rois Lista de ROIs para calcular la extensi?n m?xima que ocupan
|
241 |
* @return Entent m?ximo
|
242 |
*/
|
243 |
private Extent getMaximunExtent(ArrayList rois) { |
244 |
double minx = 0, miny = 0, maxx = 0, maxy = 0; |
245 |
for (int i = 0; i < rois.size(); i++) { |
246 |
Extent ext = ((ROI) rois.get(i)).getGridExtent(); |
247 |
if(i == 0) { |
248 |
minx = ext.minX(); |
249 |
miny = ext.minY(); |
250 |
maxx = ext.maxX(); |
251 |
maxy = ext.maxY(); |
252 |
} else {
|
253 |
if(ext.minX() < minx)
|
254 |
minx = ext.minX(); |
255 |
if(ext.minY() < miny)
|
256 |
miny = ext.minY(); |
257 |
if(ext.maxX() > maxx)
|
258 |
maxx = ext.maxX(); |
259 |
if(ext.maxY() > maxy)
|
260 |
maxy = ext.maxY(); |
261 |
} |
262 |
} |
263 |
return new Extent(minx, miny, maxx, maxy); |
264 |
} |
265 |
|
266 |
/**
|
267 |
* Al producirse un evento de perdida de foco o pulsaci?n de "enter" en un campo de texto de coordenadas
|
268 |
* hay que asignar el nuevo valor introducido.
|
269 |
* @param obj
|
270 |
*/
|
271 |
private void eventJTextField(CoordinatesEvent e) { |
272 |
try {
|
273 |
if (e.getSource() == getCoordinatesPanel().getCoordinatesPixel()) {
|
274 |
if (e.getName().equals("11")) |
275 |
getClippingPanel().setCoorPixelFromDouble( |
276 |
Double.valueOf(getCoordinatesPanel().getCoordinatesPixel().getValue11()).doubleValue(),
|
277 |
getClippingPanel().getPxMinY(), |
278 |
getClippingPanel().getPxMaxX(), |
279 |
getClippingPanel().getPxMaxY(), |
280 |
3);
|
281 |
if (e.getName().equals("12")) |
282 |
getClippingPanel().setCoorPixelFromDouble( |
283 |
getClippingPanel().getPxMinX(), |
284 |
Double.valueOf(getCoordinatesPanel().getCoordinatesPixel().getValue12()).doubleValue(),
|
285 |
getClippingPanel().getPxMaxX(), |
286 |
getClippingPanel().getPxMaxY(), |
287 |
3);
|
288 |
if (e.getName().equals("21")) |
289 |
getClippingPanel().setCoorPixelFromDouble( |
290 |
getClippingPanel().getPxMinX(), |
291 |
getClippingPanel().getPxMinY(), |
292 |
Double.valueOf(getCoordinatesPanel().getCoordinatesPixel().getValue21()).doubleValue(),
|
293 |
getClippingPanel().getPxMaxY(), |
294 |
3);
|
295 |
if (e.getName().equals("22")) |
296 |
getClippingPanel().setCoorPixelFromDouble( |
297 |
getClippingPanel().getPxMinX(), |
298 |
getClippingPanel().getPxMinY(), |
299 |
getClippingPanel().getPxMaxX(), |
300 |
Double.valueOf(getCoordinatesPanel().getCoordinatesPixel().getValue22()).doubleValue(),
|
301 |
3);
|
302 |
} |
303 |
|
304 |
if (e.getSource() == getCoordinatesPanel().getCoordinatesReales()) {
|
305 |
Extent ex = getMapWindow(); |
306 |
if (ex == null) |
307 |
return;
|
308 |
|
309 |
if (e.getName().equals("11")) |
310 |
getClippingPanel().setCoorRealFromDouble( |
311 |
Double.valueOf(getCoordinatesPanel().getCoordinatesReales().getValue11()).doubleValue(),
|
312 |
ex.getULY(), |
313 |
ex.getLRX(), |
314 |
ex.getLRY(), |
315 |
6);
|
316 |
if (e.getName().equals("12")) |
317 |
getClippingPanel().setCoorRealFromDouble( |
318 |
ex.getULX(), |
319 |
Double.valueOf(getCoordinatesPanel().getCoordinatesReales().getValue12()).doubleValue(),
|
320 |
ex.getLRX(), |
321 |
ex.getLRY(), |
322 |
6);
|
323 |
if (e.getName().equals("21")) |
324 |
getClippingPanel().setCoorRealFromDouble( |
325 |
ex.getULX(), |
326 |
ex.getULY(), |
327 |
Double.valueOf(getCoordinatesPanel().getCoordinatesReales().getValue21()).doubleValue(),
|
328 |
ex.getLRY(), |
329 |
6);
|
330 |
if (e.getName().equals("22")) |
331 |
getClippingPanel().setCoorRealFromDouble( |
332 |
ex.getULX(), |
333 |
ex.getULY(), |
334 |
ex.getLRX(), |
335 |
Double.valueOf(getCoordinatesPanel().getCoordinatesReales().getValue22()).doubleValue(),
|
336 |
6);
|
337 |
} |
338 |
} catch (NumberFormatException ex1) { |
339 |
// No hay valores parseables a decimal en las cajas de texto. No hacemos nada
|
340 |
} |
341 |
} |
342 |
|
343 |
/**
|
344 |
* Comprueba si todos los campos de coordenadas est?n llenos
|
345 |
* @return true si todos los campos de coordenadas est?n llenos y false si hay
|
346 |
* alguno vacio.
|
347 |
* @deprecated Ya no es necesario con el nuevo componente
|
348 |
*/
|
349 |
private boolean isFieldsFill() { |
350 |
if (getCoordinatesPanel().getCoordinatesPixel().getValue11().equals("") || |
351 |
getCoordinatesPanel().getCoordinatesPixel().getValue12().equals("") ||
|
352 |
getCoordinatesPanel().getCoordinatesPixel().getValue21().equals("") ||
|
353 |
getCoordinatesPanel().getCoordinatesPixel().getValue22().equals("") ||
|
354 |
getCoordinatesPanel().getCoordinatesReales().getValue11().equals("") ||
|
355 |
getCoordinatesPanel().getCoordinatesReales().getValue12().equals("") ||
|
356 |
getCoordinatesPanel().getCoordinatesReales().getValue21().equals("") ||
|
357 |
getCoordinatesPanel().getCoordinatesReales().getValue22().equals(""))
|
358 |
return false; |
359 |
return true; |
360 |
} |
361 |
|
362 |
/**
|
363 |
* Obtiene un rectangulo con la ventana en pixeles. Estos datos son leidos desde el interfaz.
|
364 |
* @return Rectangle2D
|
365 |
*/
|
366 |
private Rectangle2D getPxWindow(){ |
367 |
if (getClippingPanel().getPxMinX() == 0 |
368 |
&& getClippingPanel().getPxMinY() == 0
|
369 |
&& getClippingPanel().getPxMaxX() == 0
|
370 |
&& getClippingPanel().getPxMaxY() == 0)
|
371 |
return null; |
372 |
return new Rectangle2D.Double(getClippingPanel().getPxMinX(), |
373 |
getClippingPanel().getPxMinY(), |
374 |
Math.abs(getClippingPanel().getPxMaxX() - getClippingPanel().getPxMinX()),
|
375 |
Math.abs(getClippingPanel().getPxMaxY() - getClippingPanel().getPxMinY()));
|
376 |
} |
377 |
|
378 |
/**
|
379 |
* Obtiene un rectangulo con la ventana en coordenadas reales. Estos datos son leidos desde el interfaz.
|
380 |
* @return Rectangle2D
|
381 |
*/
|
382 |
private Extent getMapWindow(){
|
383 |
if (getClippingPanel().getULX() == 0 |
384 |
&& getClippingPanel().getULY() == 0
|
385 |
&& getClippingPanel().getLRX() == 0
|
386 |
&& getClippingPanel().getLRY() == 0)
|
387 |
return null; |
388 |
return new Extent( getClippingPanel().getULX(), |
389 |
getClippingPanel().getULY(), |
390 |
getClippingPanel().getLRX(), |
391 |
getClippingPanel().getLRY()); |
392 |
} |
393 |
|
394 |
/**
|
395 |
* Recalcula el valor de los campos de coordenadas reales y pixel. Cuando modificamos alg?n campo
|
396 |
* de las coordenadas reales se modifican los pixeles y viceversa.
|
397 |
* @param modifyPx true si se ha modificado alg?n campo de coordenadas pixel y false si se ha modificado
|
398 |
* alg?n campo de las coordenadas reales.
|
399 |
*/
|
400 |
private void recalcCoordFields(boolean modifyPx) { |
401 |
if (isFieldsFill()) {
|
402 |
try {
|
403 |
getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(false);
|
404 |
getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(false);
|
405 |
|
406 |
if (modifyPx) {
|
407 |
Rectangle2D pxWindow = getPxWindow();
|
408 |
if (pxWindow == null) |
409 |
return;
|
410 |
Point2D ulPx = new Point2D.Double(pxWindow.getMinX(), pxWindow.getMinY()); |
411 |
Point2D lrPx = new Point2D.Double(pxWindow.getMaxX(), pxWindow.getMaxY()); |
412 |
|
413 |
//Comprobamos si la selecci?n est? fuera del ?rea
|
414 |
if (isOutside(ulPx, lrPx)) {
|
415 |
getClippingPanel().setCoorPixelFromDouble(0, 0, 0, 0, 0); |
416 |
getClippingPanel().setWidthText(0, 0); |
417 |
getClippingPanel().setHeightText(0, 0); |
418 |
getClippingPanel().setCellSizeText(0, 0); |
419 |
getClippingPanel().setRelWidthHeight(0);
|
420 |
getClippingPanel().setCoorRealFromDouble(0, 0, 0, 0, 0); |
421 |
return;
|
422 |
} |
423 |
|
424 |
//Comprobamos que las esquinas no esten cambiadas de sitio
|
425 |
if(ulPx.getX() > lrPx.getX()) {
|
426 |
double ulTmp = ulPx.getX();
|
427 |
ulPx.setLocation(lrPx.getX(), ulPx.getY()); |
428 |
lrPx.setLocation(ulTmp, lrPx.getY()); |
429 |
} |
430 |
if(ulPx.getY() > lrPx.getY()) {
|
431 |
double ulTmp = ulPx.getY();
|
432 |
ulPx.setLocation(ulPx.getX(), lrPx.getY()); |
433 |
lrPx.setLocation(lrPx.getX(), ulTmp); |
434 |
} |
435 |
|
436 |
Point2D[] pointList = new Point2D[]{ulPx, lrPx}; |
437 |
Point2D dim = new Point2D.Double(this.dim.width, this.dim.height); |
438 |
|
439 |
//Ajustamos los puntos al ?rea en pixeles del raster
|
440 |
RasterUtilities.adjustToPixelSize(pointList, dim); |
441 |
|
442 |
Point2D ulWc = new Point2D.Double(); |
443 |
Point2D lrWc = new Point2D.Double(); |
444 |
at.transform(ulPx, ulWc); |
445 |
at.transform(new Point2D.Double(lrPx.getX(), lrPx.getY()), lrWc); |
446 |
|
447 |
getClippingPanel().setCoorRealFromDouble(ulWc.getX(), ulWc.getY(), lrWc.getX(), lrWc.getY(), 3);
|
448 |
getClippingPanel().setCoorPixelFromDouble(ulPx.getX(), ulPx.getY(), lrPx.getX(), lrPx.getY(), 3);
|
449 |
getClippingPanel().setWidthText(Math.abs(ulPx.getX() - lrPx.getX()), 0); |
450 |
getClippingPanel().setHeightText(Math.abs(ulPx.getY() - lrPx.getY()), 0); |
451 |
getClippingPanel().setCellSizeText((Math.abs(lrWc.getX() - ulWc.getX()) / dim.getX()), 4); |
452 |
getClippingPanel().setRelWidthHeight((double) (Math.abs(ulPx.getX() - lrPx.getX()) / Math.abs(ulPx.getY() - lrPx.getY()))); |
453 |
|
454 |
getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(true);
|
455 |
getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(true);
|
456 |
} else {
|
457 |
Extent mapWindow = getMapWindow(); |
458 |
if (mapWindow == null) |
459 |
return;
|
460 |
|
461 |
Point2D ulPx = new Point2D.Double(mapWindow.getULX(), mapWindow.getULY()); |
462 |
Point2D lrPx = new Point2D.Double(mapWindow.getLRX(), mapWindow.getLRY()); |
463 |
|
464 |
try {
|
465 |
at.inverseTransform(ulPx, ulPx); |
466 |
at.inverseTransform(lrPx, lrPx); |
467 |
} catch (NoninvertibleTransformException e) { |
468 |
JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "coordenadas_erroneas")); |
469 |
return;
|
470 |
} |
471 |
|
472 |
Point2D[] pointList = new Point2D[]{ulPx, lrPx}; |
473 |
Point2D dim = new Point2D.Double(this.dim.width, this.dim.height); |
474 |
|
475 |
//Comprobamos si la selecci?n est? fuera del ?rea
|
476 |
if (isOutside(ulPx, lrPx)) {
|
477 |
getClippingPanel().setCoorPixelFromDouble(0, 0, 0, 0, 0); |
478 |
getClippingPanel().setWidthText(0, 0); |
479 |
getClippingPanel().setHeightText(0, 0); |
480 |
getClippingPanel().setCellSizeText(0, 0); |
481 |
getClippingPanel().setRelWidthHeight(0);
|
482 |
getClippingPanel().setCoorRealFromDouble(0, 0, 0, 0, 0); |
483 |
return;
|
484 |
} |
485 |
// Ajustamos los puntos al ?rea en pixeles del raster
|
486 |
RasterUtilities.adjustToPixelSize(pointList, dim); |
487 |
|
488 |
double minX = Math.min(ulPx.getX(), lrPx.getX()); |
489 |
double maxX = Math.max(ulPx.getX(), lrPx.getX()); |
490 |
double minY = Math.min(ulPx.getY(), lrPx.getY()); |
491 |
double maxY = Math.max(ulPx.getY(), lrPx.getY()); |
492 |
|
493 |
//Convertimos nuevamente a coordenadas reales
|
494 |
Point2D ulWc = new Point2D.Double(); |
495 |
Point2D lrWc = new Point2D.Double(); |
496 |
at.transform(new Point2D.Double(minX, minY), ulWc); |
497 |
at.transform(new Point2D.Double(maxX, maxY), lrWc); |
498 |
|
499 |
getClippingPanel().setCoorRealFromDouble(ulWc.getX(), ulWc.getY(), lrWc.getX(), lrWc.getY(), 3);
|
500 |
getClippingPanel().setCoorPixelFromDouble(minX, minY, maxX, maxY, 3);
|
501 |
getClippingPanel().setWidthText(Math.abs(ulPx.getX() - lrPx.getX()), 0); |
502 |
getClippingPanel().setHeightText(Math.abs(ulPx.getY() - lrPx.getY()), 0); |
503 |
getClippingPanel().setCellSizeText(((maxX - minX) / dim.getX()), 4);
|
504 |
getClippingPanel().setRelWidthHeight((double) (Math.abs(ulPx.getX() - lrPx.getX()) / Math.abs(ulPx.getY() - lrPx.getY()))); |
505 |
|
506 |
getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(true);
|
507 |
getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(true);
|
508 |
} |
509 |
} catch (NumberFormatException ex) { |
510 |
return;
|
511 |
} |
512 |
} |
513 |
} |
514 |
|
515 |
/**
|
516 |
* Comprueba si la selecci?n del punto est? fuera del ?rea del raster.
|
517 |
* @param ulPx Coordenada superior izquierda en pixeles
|
518 |
* @param lrPx Corrdenada inferior derecha en pixeles
|
519 |
* @return true si la selecci?n del punto est? fuera del raster y false si no lo est?
|
520 |
*/
|
521 |
private boolean isOutside(Point2D ulPx, Point2D lrPx) { |
522 |
double minX = Math.min(ulPx.getX(), lrPx.getX()); |
523 |
double minY = Math.min(ulPx.getY(), lrPx.getY()); |
524 |
double maxX = Math.max(ulPx.getX(), lrPx.getX()); |
525 |
double maxY = Math.max(ulPx.getY(), lrPx.getY()); |
526 |
if (minX >= dim.width || minY >= dim.height || maxX < 0 || maxY < 0) |
527 |
return true; |
528 |
return false; |
529 |
} |
530 |
|
531 |
/**
|
532 |
* Definir el ancho de la vista en pixeles
|
533 |
* @param value
|
534 |
*/
|
535 |
public void setWidthPx(int value) { |
536 |
widthPx = value; |
537 |
} |
538 |
|
539 |
/**
|
540 |
* Obtener el ancho de la vista en pixeles
|
541 |
* @return the widthPx
|
542 |
*/
|
543 |
public int getWidthPx() { |
544 |
return widthPx;
|
545 |
} |
546 |
|
547 |
/**
|
548 |
* Definir el alto de la vista en pixeles
|
549 |
* @param value
|
550 |
*/
|
551 |
public void setHeightPx(int value) { |
552 |
heightPx = value; |
553 |
} |
554 |
|
555 |
/**
|
556 |
* Obtener el alto de la vista en pixeles
|
557 |
* @return the heightPx
|
558 |
*/
|
559 |
public int getHeightPx() { |
560 |
return heightPx;
|
561 |
} |
562 |
|
563 |
/**
|
564 |
* Invocaci?n de los eventos de la ventana de <code>DefaultButtonsPanel</code>
|
565 |
*/
|
566 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
567 |
// Bot?n de Aceptar
|
568 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
569 |
if (e.getSource() == getEndInfoDialog().getButtonsPanel()) {
|
570 |
getEndJFrame().setVisible(false);
|
571 |
return;
|
572 |
} |
573 |
accept(); |
574 |
close(); |
575 |
} |
576 |
|
577 |
// Bot?n de Aplicar
|
578 |
if (e.getButton() == ButtonsPanel.BUTTON_APPLY)
|
579 |
accept(); |
580 |
|
581 |
// Bot?n de Cerrar
|
582 |
if (e.getButton() == ButtonsPanel.BUTTON_CANCEL)
|
583 |
close(); |
584 |
|
585 |
getClippingPanel().getFLayer().getMapContext().invalidate(); |
586 |
} |
587 |
|
588 |
/**
|
589 |
* Cerrar la ventana del recorte
|
590 |
*/
|
591 |
private void close() { |
592 |
try {
|
593 |
if (getClippingPanel().getLastTool() != null) |
594 |
getClippingPanel().getMapControl().setTool(getClippingPanel().getLastTool()); |
595 |
PluginServices.getMDIManager().closeWindow(getClippingPanel().getClippingDialog()); |
596 |
} catch (ArrayIndexOutOfBoundsException ex) { |
597 |
// Si la ventana no se puede eliminar no hacemos nada
|
598 |
} |
599 |
} |
600 |
|
601 |
/**
|
602 |
* Obtener el <code>ClippingPanel</code> asociado
|
603 |
* @return ClippingPanel
|
604 |
*/
|
605 |
private ClippingPanel getClippingPanel() {
|
606 |
return clippingPanel;
|
607 |
} |
608 |
|
609 |
private ClippingCoordinatesPanel getCoordinatesPanel() {
|
610 |
return getClippingPanel().getCoordinatesPanel();
|
611 |
} |
612 |
|
613 |
private ClippingResolutionPanel getResolutionPanel() {
|
614 |
return getClippingPanel().getResolutionPanel();
|
615 |
} |
616 |
|
617 |
private ClippingOptionsPanel getOptionsPanel() {
|
618 |
return getClippingPanel().getOptionsPanel();
|
619 |
} |
620 |
|
621 |
private ClippingSelectionPanel getSelectionPanel() {
|
622 |
return getClippingPanel().getSelectionPanel();
|
623 |
} |
624 |
|
625 |
/**
|
626 |
* Acciones realizadas cuando se acepta en el dialogo. Se obtendr?n los datos
|
627 |
* de recorte desde el dialogo, crearemos el objeto ClippingProcess que
|
628 |
* gestiona el recortado, ajustamos el tama?o del grid de salida y procesamos.
|
629 |
*/
|
630 |
private void accept() { |
631 |
// Controlamos las coordenadas del recorte que no se salgan de la imagen.
|
632 |
// De ser as? mostramos un error
|
633 |
CoordinatesPanel coordinatesReales = getCoordinatesPanel().getCoordinatesReales(); |
634 |
double ulx = 0; |
635 |
double lrx = 0; |
636 |
double lry = 0; |
637 |
double uly = 0; |
638 |
try {
|
639 |
ulx = Double.parseDouble(coordinatesReales.getValue11());
|
640 |
lry = Double.parseDouble(coordinatesReales.getValue22());
|
641 |
lrx = Double.parseDouble(coordinatesReales.getValue21());
|
642 |
uly = Double.parseDouble(coordinatesReales.getValue12());
|
643 |
Rectangle2D ext = getClippingPanel().getFLayer().getFullExtent();
|
644 |
if (((int) ulx) > ((int) ext.getMaxX()) || ((int) lrx) < ((int) ext.getMinX()) || ((int) uly) > ((int) ext.getMaxY()) || ((int) lry) < ((int) ext.getMinY())) { |
645 |
JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "coordenadas_erroneas")); |
646 |
return;
|
647 |
} |
648 |
} catch (NumberFormatException e) { |
649 |
JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "coordenadas_erroneas")); |
650 |
return;
|
651 |
} catch (ExpansionFileReadException e) {
|
652 |
Logger.getLogger(getClass().getName()).debug("error en el dibujado", e); |
653 |
} catch (ReadDriverException e) {
|
654 |
Logger.getLogger(getClass().getName()).debug("error en el dibujado", e); |
655 |
} |
656 |
|
657 |
// Obtenemos las coordenadas del recorte
|
658 |
CoordinatesPanel coordinatesPixel = getCoordinatesPanel().getCoordinatesPixel(); |
659 |
int[] dValues = new int[4]; |
660 |
try {
|
661 |
dValues[0] = (int) Math.round(Double.valueOf(coordinatesPixel.getValue11()).doubleValue()); |
662 |
dValues[1] = (int) Math.round(Double.valueOf(coordinatesPixel.getValue22()).doubleValue()); |
663 |
dValues[2] = (int) Math.round(Double.valueOf(coordinatesPixel.getValue21()).doubleValue()); |
664 |
dValues[3] = (int) Math.round(Double.valueOf(coordinatesPixel.getValue12()).doubleValue()); |
665 |
} catch (NumberFormatException exc) { |
666 |
// Los valores de las cajas son incorrectos. Terminamos la funci?n
|
667 |
return;
|
668 |
} |
669 |
|
670 |
// Seleccionamos las bandas que se usaran en el recorte a partir de la tabla
|
671 |
int countBands = 0; |
672 |
int rowCount = ((CheckBoxModel) getSelectionPanel().getTableContainer().getModel()).getRowCount();
|
673 |
for (int iRow = 0; iRow < rowCount; iRow++) |
674 |
if ((((Boolean) ((CheckBoxModel) getSelectionPanel().getTableContainer().getModel()).getValueAt(iRow, 0))).booleanValue()) |
675 |
countBands++; |
676 |
|
677 |
int[] drawableBands = new int[countBands]; |
678 |
int i = 0; |
679 |
for (int iRow = 0; iRow < rowCount; iRow++) { |
680 |
if ((((Boolean) ((CheckBoxModel) getSelectionPanel().getTableContainer().getModel()).getValueAt(iRow, 0))).booleanValue()) { |
681 |
int row = ((Integer) ((CheckBoxModel) getSelectionPanel().getTableContainer().getModel()).getValueAt(iRow, 2)).intValue(); |
682 |
drawableBands[i++] = row; |
683 |
} |
684 |
} |
685 |
|
686 |
/**
|
687 |
* Donde se va a guardar el fichero
|
688 |
*/
|
689 |
String path;
|
690 |
if (getOptionsPanel().getCbSaveFile().isSelected())
|
691 |
path = getOptionsPanel().getDirectoryTextField().getText(); |
692 |
else
|
693 |
path = Utilities.createTempDirectory();
|
694 |
|
695 |
String file = getOptionsPanel().getFilenameTextField().getText();
|
696 |
if (file.compareTo(RasterLibrary.getOnlyLayerName()) == 0) |
697 |
RasterLibrary.usesOnlyLayerName(); |
698 |
|
699 |
if (file == "") |
700 |
file = "cutlayer";
|
701 |
|
702 |
String filename = path + File.separator + file; |
703 |
|
704 |
if (new File(filename + ".tif").exists()) |
705 |
if (!RasterToolsUtil.messageBoxYesOrNot("raster_error_file_exists", getOptionsPanel())) |
706 |
return;
|
707 |
|
708 |
/**
|
709 |
* Preparacion para la generacion del proceso del recorte
|
710 |
*/
|
711 |
if (((FLyrRasterSE) getClippingPanel().getFLayer()) == null) |
712 |
return;
|
713 |
|
714 |
WriterBufferServer dataWriter1 = new WriterBufferServer();
|
715 |
|
716 |
AffineTransform transf = calcAffineTransform(ulx, uly, lrx, lry, getClippingPanel().getWidthText(), getClippingPanel().getHeightText());
|
717 |
|
718 |
int interpMethod = getResolutionPanel().getSelectedInterpolationMethod();
|
719 |
|
720 |
// Creamos la interpretaci?n de color para el caso de que la salida tenga
|
721 |
// m?s de una banda por fichero. Siempre creamos RED, GREEN y BLUE
|
722 |
String[] ci = new String[drawableBands.length]; |
723 |
for (int j = 0; j < ci.length; j++) { |
724 |
switch (j) {
|
725 |
case 0: |
726 |
if (ci.length >= 3) |
727 |
ci[j] = DatasetColorInterpretation.RED_BAND; |
728 |
else
|
729 |
ci[j] = DatasetColorInterpretation.GRAY_BAND; |
730 |
break;
|
731 |
case 1: |
732 |
if (ci.length >= 3) |
733 |
ci[j] = DatasetColorInterpretation.GREEN_BAND; |
734 |
else
|
735 |
ci[j] = DatasetColorInterpretation.UNDEF_BAND; |
736 |
break;
|
737 |
case 2: |
738 |
ci[j] = DatasetColorInterpretation.BLUE_BAND; |
739 |
break;
|
740 |
default:
|
741 |
ci[j] = DatasetColorInterpretation.UNDEF_BAND; |
742 |
break;
|
743 |
} |
744 |
} |
745 |
|
746 |
RasterProcess clippingProcess = new ClippingProcess();
|
747 |
clippingProcess.setActions(this);
|
748 |
clippingProcess.addParam("viewname", getClippingPanel().getViewName());
|
749 |
clippingProcess.addParam("pixelcoordinates", dValues);
|
750 |
clippingProcess.addParam("filename", filename);
|
751 |
clippingProcess.addParam("datawriter", dataWriter1);
|
752 |
clippingProcess.addParam("layer", getClippingPanel().getFLayer());
|
753 |
clippingProcess.addParam("drawablebands", drawableBands);
|
754 |
clippingProcess.addParam("onelayerperband", new Boolean(getOptionsPanel().getCbOneLyrPerBand().isSelected())); |
755 |
clippingProcess.addParam("interpolationmethod", new Integer(interpMethod)); |
756 |
clippingProcess.addParam("affinetransform", transf);
|
757 |
clippingProcess.addParam("colorInterpretation", new DatasetColorInterpretation(ci)); |
758 |
clippingProcess.addParam("resolution", new int[]{(int) getClippingPanel().getWidthText(), |
759 |
(int) getClippingPanel().getHeightText()});
|
760 |
clippingProcess.start(); |
761 |
} |
762 |
|
763 |
/**
|
764 |
* Calcula la matriz de transformaci?n que se usar? para el nuevo raster generado.
|
765 |
* @param ulx Coordenada X real de la esquina superior izquierda
|
766 |
* @param uly Coordenada Y real de la esquina superior izquierda
|
767 |
* @param lrx Coordenada X real de la esquina inferior derecha
|
768 |
* @param lry Coordenada Y real de la esquina inferior derecha
|
769 |
* @param width Ancho en p?xeles del nuevo raster
|
770 |
* @param height Alto en p?xeles del nuevo raster
|
771 |
* @return Matriz de transformaci?n para el nuevo raster
|
772 |
*/
|
773 |
private AffineTransform calcAffineTransform(double ulx, double uly, double lrx, double lry, double width, double height) { |
774 |
Point2D ul = new Point2D.Double(ulx, uly); |
775 |
Point2D lr = new Point2D.Double(lrx, lry); |
776 |
try {
|
777 |
at.inverseTransform(ul, ul); |
778 |
at.inverseTransform(lr, lr); |
779 |
} catch (NoninvertibleTransformException e) { |
780 |
JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "coordenadas_erroneas")); |
781 |
return new AffineTransform(); |
782 |
} |
783 |
double w = Math.abs(lr.getX() - ul.getX()); |
784 |
|
785 |
Point2D ur = new Point2D.Double(ul.getX() + w, ul.getY()); |
786 |
Point2D ll = new Point2D.Double(lr.getX() - w, lr.getY() ); |
787 |
|
788 |
//Obtenemos la georreferenciaci?n de las cuatro esquinas del nuevo raster
|
789 |
at.transform(ul, ul); |
790 |
at.transform(ur, ur); |
791 |
at.transform(lr, lr); |
792 |
at.transform(ll, ll); |
793 |
|
794 |
double pixelSizeX = (ur.getX() - ul.getX()) / width;
|
795 |
double pixelSizeY = (ll.getY() - ul.getY()) / height;
|
796 |
double rotX = at.getShearX();
|
797 |
double rotY = at.getShearY();
|
798 |
return new AffineTransform(pixelSizeX, rotY, rotX, pixelSizeY, ulx, uly); |
799 |
} |
800 |
|
801 |
/*
|
802 |
* (non-Javadoc)
|
803 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
|
804 |
*/
|
805 |
public boolean cancelDrawing() { |
806 |
return false; |
807 |
} |
808 |
|
809 |
/*
|
810 |
* (non-Javadoc)
|
811 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
|
812 |
*/
|
813 |
public Cursor getCursor() { |
814 |
return null; |
815 |
} |
816 |
|
817 |
/*
|
818 |
* (non-Javadoc)
|
819 |
* @see org.gvsig.gui.beans.coordinatespanel.CoordinatesListener#actionValueChanged(org.gvsig.gui.beans.coordinatespanel.CoordinatesEvent)
|
820 |
*/
|
821 |
public void actionValueChanged(CoordinatesEvent e) { |
822 |
if (e.getSource() == getCoordinatesPanel().getCoordinatesPixel()) {
|
823 |
eventJTextField(e); |
824 |
recalcCoordFields(true);
|
825 |
} |
826 |
if (e.getSource() == getCoordinatesPanel().getCoordinatesReales()) {
|
827 |
eventJTextField(e); |
828 |
recalcCoordFields(false);
|
829 |
} |
830 |
} |
831 |
|
832 |
/*
|
833 |
* (non-Javadoc)
|
834 |
* @see org.gvsig.gui.beans.datainput.DataInputContainerListener#actionValueChanged(java.util.EventObject)
|
835 |
*/
|
836 |
public void actionValueChanged(EventObject e) { |
837 |
if(!enableValueChangedEvent)
|
838 |
return;
|
839 |
|
840 |
enableValueChangedEvent = false; //Desactivamos el evento de cambio de valor de las cajas de texto para que no se bucle |
841 |
|
842 |
if (e.getSource() == getResolutionPanel().getCCellSize().getDataInputField()) {
|
843 |
// Cambiamos PS ==> wPx=wWC/PS & hPx=wPx/rel
|
844 |
double ps = 0; |
845 |
try {
|
846 |
ps = Double.parseDouble(getResolutionPanel().getCCellSize().getValue());
|
847 |
} catch (NumberFormatException ex) { |
848 |
return;
|
849 |
} |
850 |
Extent mapWindow = getMapWindow(); |
851 |
Rectangle2D pxWindow = getPxWindow();
|
852 |
if (mapWindow == null || pxWindow == null) |
853 |
return;
|
854 |
getClippingPanel().setWidthText(mapWindow.width() / ps, 0);
|
855 |
getClippingPanel().setHeightText((mapWindow.width() / ps) / getClippingPanel().getRelWidthHeight(), 0);
|
856 |
} else if (e.getSource() == getResolutionPanel().getCWidth().getDataInputField()) { |
857 |
// Cambiamos wPx ==> hPx=wPx/rel & PS=wWC/wPx
|
858 |
double wPx = 0; |
859 |
try {
|
860 |
wPx = Double.parseDouble(getResolutionPanel().getCWidth().getValue());
|
861 |
} catch (NumberFormatException ex) { |
862 |
return;
|
863 |
} |
864 |
Extent mapWindow = getMapWindow(); |
865 |
Rectangle2D pxWindow = getPxWindow();
|
866 |
if (mapWindow == null || pxWindow == null) |
867 |
return;
|
868 |
getClippingPanel().setWidthText(wPx, 0);
|
869 |
getClippingPanel().setHeightText(wPx / getClippingPanel().getRelWidthHeight(), 0);
|
870 |
getClippingPanel().setCellSizeText((mapWindow.width() / wPx), 4);
|
871 |
} else if (e.getSource() == getResolutionPanel().getCHeight().getDataInputField()) { |
872 |
// Cambiamos hPx ==> wPx=rel*wPx & PS=hWC/hPx
|
873 |
double hPx = 0; |
874 |
try {
|
875 |
hPx = Double.parseDouble(getResolutionPanel().getCHeight().getValue());
|
876 |
} catch (NumberFormatException ex) { |
877 |
return;
|
878 |
} |
879 |
Extent mapWindow = getMapWindow(); |
880 |
Rectangle2D pxWindow = getPxWindow();
|
881 |
if (mapWindow == null || pxWindow == null) |
882 |
return;
|
883 |
getClippingPanel().setWidthText(hPx * getClippingPanel().getRelWidthHeight(), 0);
|
884 |
getClippingPanel().setHeightText(hPx, 0);
|
885 |
getClippingPanel().setCellSizeText((mapWindow.height() / hPx), 4);
|
886 |
} |
887 |
enableValueChangedEvent = true;
|
888 |
} |
889 |
|
890 |
/**
|
891 |
* Asigna el valor para la activaci?n y desactivaci?n del evento de cambio de valor en
|
892 |
* las cajas de texto.
|
893 |
* @param enableValueChangedEvent
|
894 |
*/
|
895 |
public void setEnableValueChangedEvent(boolean enableValueChangedEvent) { |
896 |
this.enableValueChangedEvent = enableValueChangedEvent;
|
897 |
} |
898 |
|
899 |
EndInfoPanel endInfoPanel = null;
|
900 |
JFrame endJFrame = null; |
901 |
|
902 |
/**
|
903 |
* Obtiene el panel con la informaci?n de finalizaci?n
|
904 |
* @return EndInfoPanel
|
905 |
*/
|
906 |
public EndInfoPanel getEndInfoDialog() {
|
907 |
if (endInfoPanel==null) { |
908 |
endInfoPanel = new EndInfoPanel();
|
909 |
getEndJFrame().add(endInfoPanel); |
910 |
endInfoPanel.addButtonPressedListener(this);
|
911 |
} |
912 |
return endInfoPanel;
|
913 |
} |
914 |
|
915 |
public JFrame getEndJFrame() { |
916 |
if (endJFrame==null) { |
917 |
endJFrame = new JFrame(RasterToolsUtil.getText(this, "stats")); |
918 |
endJFrame.setResizable(false);
|
919 |
endJFrame.setAlwaysOnTop(true);
|
920 |
} |
921 |
return endJFrame;
|
922 |
} |
923 |
|
924 |
/*
|
925 |
* (non-Javadoc)
|
926 |
* @see org.gvsig.raster.IProcessActions#end(java.lang.Object)
|
927 |
*/
|
928 |
public void end(Object params) { |
929 |
if( params instanceof Object[] && |
930 |
((Object[])params).length == 2 && |
931 |
((Object[])params)[0] instanceof String && |
932 |
((Object[])params)[1] instanceof Long) { |
933 |
|
934 |
String fName = (String)((Object[])params)[0]; |
935 |
long milis = ((Long)((Object[])params)[1]).longValue(); |
936 |
|
937 |
String compression;
|
938 |
File f = new File(fName); |
939 |
if (fName.endsWith("ecw") || |
940 |
fName.endsWith("jp2") ||
|
941 |
fName.endsWith("jpg") ||
|
942 |
fName.endsWith("jpeg"))
|
943 |
compression = "Yes";
|
944 |
else
|
945 |
compression = "No";
|
946 |
|
947 |
getEndInfoDialog().addFile(fName, RasterUtilities.formatTime(milis), RasterUtilities.formatFileSize(f.length()), compression); |
948 |
getEndJFrame().pack(); |
949 |
getEndJFrame().setVisible(true);
|
950 |
} |
951 |
} |
952 |
|
953 |
public void rectangle(RectangleEvent event) throws BehaviorException {} |
954 |
public void interrupted() {} |
955 |
} |