svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / clipping / ui / listener / ClippingPanelListener.java @ 22529
History | View | Annotate | Download (28.2 KB)
1 | 11352 | bsanchez | /* 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 | 14827 | bsanchez | package org.gvsig.rastertools.clipping.ui.listener; |
20 | 11352 | bsanchez | |
21 | import java.awt.Component; |
||
22 | import java.awt.Cursor; |
||
23 | 12807 | nacho | import java.awt.Dimension; |
24 | 11352 | bsanchez | import java.awt.event.ActionEvent; |
25 | import java.awt.event.ActionListener; |
||
26 | 12793 | nacho | import java.awt.geom.AffineTransform; |
27 | 12807 | nacho | import java.awt.geom.NoninvertibleTransformException; |
28 | import java.awt.geom.Point2D; |
||
29 | 11352 | bsanchez | import java.awt.geom.Rectangle2D; |
30 | import java.io.File; |
||
31 | 19930 | nbrodin | import java.util.ArrayList; |
32 | 13557 | bsanchez | import java.util.EventObject; |
33 | 11352 | bsanchez | |
34 | import javax.swing.JOptionPane; |
||
35 | |||
36 | 12425 | nacho | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
37 | 11352 | bsanchez | import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
38 | import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
||
39 | import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
||
40 | 13557 | bsanchez | import org.gvsig.gui.beans.coordinatespanel.CoordinatesEvent; |
41 | import org.gvsig.gui.beans.coordinatespanel.CoordinatesListener; |
||
42 | import org.gvsig.gui.beans.coordinatespanel.CoordinatesPanel; |
||
43 | import org.gvsig.gui.beans.datainput.DataInputContainerListener; |
||
44 | 11352 | bsanchez | import org.gvsig.gui.beans.table.models.CheckBoxModel; |
45 | 18538 | nbrodin | import org.gvsig.raster.IProcessActions; |
46 | 18962 | nbrodin | import org.gvsig.raster.RasterLibrary; |
47 | 18538 | nbrodin | import org.gvsig.raster.RasterProcess; |
48 | 18857 | nbrodin | import org.gvsig.raster.buffer.WriterBufferServer; |
49 | 18042 | nbrodin | import org.gvsig.raster.dataset.properties.DatasetColorInterpretation; |
50 | 12383 | nacho | import org.gvsig.raster.datastruct.Extent; |
51 | 19930 | nbrodin | import org.gvsig.raster.grid.roi.ROI; |
52 | 21044 | nbrodin | import org.gvsig.raster.hierarchy.IRasterGeoOperations; |
53 | import org.gvsig.raster.hierarchy.IRasterOperations; |
||
54 | 17804 | nbrodin | import org.gvsig.raster.util.RasterToolsUtil; |
55 | 19568 | bsanchez | import org.gvsig.raster.util.process.ClippingProcess; |
56 | 21015 | nbrodin | import org.gvsig.rastertools.clipping.ClippingData; |
57 | 14829 | bsanchez | 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 | 14827 | bsanchez | import org.gvsig.rastertools.clipping.ui.ClippingPanel; |
62 | 21684 | bsanchez | import org.gvsig.rastertools.saveraster.ui.info.EndInfoDialog; |
63 | 11352 | bsanchez | |
64 | import com.iver.andami.PluginServices; |
||
65 | import com.iver.andami.Utilities; |
||
66 | 21044 | nbrodin | import com.iver.andami.ui.mdiManager.IWindow; |
67 | import com.iver.cit.gvsig.fmap.MapControl; |
||
68 | 11352 | bsanchez | import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
69 | 21044 | nbrodin | import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
70 | import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
||
71 | import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
||
72 | 11352 | bsanchez | import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent; |
73 | import com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener; |
||
74 | 21044 | nbrodin | import com.iver.cit.gvsig.project.documents.view.gui.View; |
75 | import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
||
76 | 11352 | bsanchez | /**
|
77 | 14846 | bsanchez | * <code>ClippingPanelListener</code> es una clase donde se recoger?n y
|
78 | 11408 | bsanchez | * tratar?n todos los eventos del panel de recorte
|
79 | 12369 | bsanchez | *
|
80 | 11352 | bsanchez | * @version 19/04/2007
|
81 | 12369 | bsanchez | * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
82 | 11352 | bsanchez | */
|
83 | 14829 | bsanchez | public class ClippingPanelListener implements ActionListener, RectangleListener, ButtonsPanelListener, CoordinatesListener, DataInputContainerListener, IProcessActions { |
84 | 21684 | bsanchez | private Dimension dim = new Dimension(); |
85 | private AffineTransform at = null; |
||
86 | private ClippingPanel clippingPanel = null; |
||
87 | private ClippingData data = null; |
||
88 | private boolean enableValueChangedEvent = true; |
||
89 | |||
90 | private FLyrRasterSE fLayer = null; |
||
91 | private MapControl mapControl = null; |
||
92 | |||
93 | 15929 | bsanchez | /**
|
94 | 21044 | nbrodin | * Herramienta seleccionada en el momento de la apertura del dialogo
|
95 | */
|
||
96 | private String lastTool = null; |
||
97 | |||
98 | private String viewName = null; |
||
99 | |||
100 | /**
|
||
101 | 14846 | bsanchez | * Crea un nuevo <code>ClippingPanelListener</code> con el
|
102 | * <code>ClippingPanelListener</code> asociado
|
||
103 | 14071 | bsanchez | * @param panel
|
104 | */
|
||
105 | 14846 | bsanchez | public ClippingPanelListener(ClippingPanel clippingPanel) {
|
106 | this.clippingPanel = clippingPanel;
|
||
107 | 14071 | bsanchez | } |
108 | 21044 | nbrodin | |
109 | /**
|
||
110 | * Asigna el modelo de datos
|
||
111 | * @param data
|
||
112 | */
|
||
113 | public void setData(ClippingData data) { |
||
114 | this.data = data;
|
||
115 | } |
||
116 | 11408 | bsanchez | |
117 | 15929 | bsanchez | /**
|
118 | 14089 | bsanchez | * Asigna la matriz de transformaci?n entre puntos en coordenadas del raster y
|
119 | * puntos en coordenadas reales.
|
||
120 | 14071 | bsanchez | * @param AffineTransform
|
121 | */
|
||
122 | 21044 | nbrodin | private void setAffineTransform(AffineTransform at) { |
123 | 15929 | bsanchez | this.at = at;
|
124 | } |
||
125 | 13021 | bsanchez | |
126 | 15929 | bsanchez | /**
|
127 | * Asigna la dimensi?n del raster
|
||
128 | * @param dim
|
||
129 | */
|
||
130 | public void setDimension(Dimension dim) { |
||
131 | this.dim = dim;
|
||
132 | } |
||
133 | 11897 | bsanchez | |
134 | 15929 | bsanchez | /**
|
135 | * M?todo que se invoca cuando se disparan los eventos de los botones de
|
||
136 | * extensi?n completa o de seleccion de extensi?n con el rat?n
|
||
137 | */
|
||
138 | public void actionPerformed(ActionEvent e) { |
||
139 | // Bot?n de selecci?n del extent completo
|
||
140 | // Modificamos las coordenadas reales y recalculamos las coordenadas pixel
|
||
141 | if (e.getSource() == getResolutionPanel().getButtonRestore()) {
|
||
142 | 21044 | nbrodin | getClippingPanel().restoreStatus(data); |
143 | 15929 | bsanchez | } |
144 | 19930 | nbrodin | |
145 | //Bot?n de selecci?n del ?rea m?xima asociada a los ROIs
|
||
146 | if (e.getSource() == getCoordinatesPanel().getButtonBarContainer().getButton(0)) { |
||
147 | 21044 | nbrodin | ArrayList roiList = getFLayer().getRois();
|
148 | if(roiList != null && roiList.size() > 0) { |
||
149 | 21737 | nbrodin | Extent ext = ROI.getROIsMaximunExtent(roiList); |
150 | 21044 | nbrodin | assignROISExtent(ext, getFLayer()); |
151 | } else
|
||
152 | assignFullExtent(); |
||
153 | 19930 | nbrodin | return;
|
154 | } |
||
155 | 14071 | bsanchez | |
156 | 15929 | bsanchez | // Bot?n de selecci?n del extent completo
|
157 | // Modificamos las coordenadas reales y recalculamos las coordenadas pixel
|
||
158 | 19930 | nbrodin | if (e.getSource() == getCoordinatesPanel().getButtonBarContainer().getButton(1)) { |
159 | assignFullExtent(); |
||
160 | 15929 | bsanchez | return;
|
161 | } |
||
162 | 13021 | bsanchez | |
163 | 15929 | bsanchez | // Bot?n de selecci?n de la herramienta de seleccionar desde la vista
|
164 | 19930 | nbrodin | if (e.getSource() == getCoordinatesPanel().getButtonBarContainer().getButton(2)) { |
165 | 21044 | nbrodin | selectToolButton(); |
166 | 15929 | bsanchez | return;
|
167 | } |
||
168 | 19930 | nbrodin | |
169 | 15929 | bsanchez | } |
170 | 19930 | nbrodin | |
171 | /**
|
||
172 | * Asigna el extent completo a los cuadros de texto donde se introducen las coordenadas
|
||
173 | * reales y p?xel.
|
||
174 | */
|
||
175 | private void assignROISExtent(Extent ext, FLyrRasterSE layer) { |
||
176 | AffineTransform at = layer.getAffineTransform();
|
||
177 | 21015 | nbrodin | Point2D ulWc = new Point2D.Double(ext.minX(), ext.maxY()); |
178 | Point2D lrWc = new Point2D.Double(ext.maxX(), ext.minY()); |
||
179 | 19930 | nbrodin | |
180 | 21737 | nbrodin | ulWc = getFLayer().adjustWorldRequest(ulWc); |
181 | lrWc = getFLayer().adjustWorldRequest(lrWc); |
||
182 | 21015 | nbrodin | |
183 | Point2D ulPx = new Point2D.Double(); |
||
184 | Point2D lrPx = new Point2D.Double(); |
||
185 | |||
186 | 19930 | nbrodin | try {
|
187 | 21015 | nbrodin | at.inverseTransform(ulWc, ulPx); |
188 | at.inverseTransform(lrWc, lrPx); |
||
189 | 19930 | nbrodin | } catch (NoninvertibleTransformException e) { |
190 | JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "coordenadas_erroneas")); |
||
191 | return;
|
||
192 | } |
||
193 | 14089 | bsanchez | |
194 | 21015 | nbrodin | data.setCoorRealFromDouble(ulWc.getX(), ulWc.getY(), lrWc.getX(), lrWc.getY()); |
195 | data.setCoorPixelFromDouble(ulPx.getX(), ulPx.getY(), lrPx.getX() - 1, lrPx.getY() - 1); |
||
196 | data.initSize(); |
||
197 | 21044 | nbrodin | getClippingPanel().saveStatus(data); |
198 | 19930 | nbrodin | |
199 | getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(true);
|
||
200 | getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(true);
|
||
201 | } |
||
202 | |||
203 | 15929 | bsanchez | /**
|
204 | 19930 | nbrodin | * Asigna el extent completo a los cuadros de texto donde se introducen las coordenadas
|
205 | * reales y p?xel.
|
||
206 | */
|
||
207 | private void assignFullExtent() { |
||
208 | Point2D ulPx = new Point2D.Double(0, 0); |
||
209 | Point2D lrPx = new Point2D.Double(dim.width, dim.height); |
||
210 | |||
211 | //Convertimos nuevamente a coordenadas reales
|
||
212 | Point2D ulWc = new Point2D.Double(); |
||
213 | Point2D lrWc = new Point2D.Double(); |
||
214 | 21015 | nbrodin | at.transform(ulPx, ulWc); |
215 | at.transform(lrPx, lrWc); |
||
216 | 19930 | nbrodin | |
217 | 21015 | nbrodin | data.setCoorRealFromDouble(ulWc.getX(), ulWc.getY(), lrWc.getX(), lrWc.getY()); |
218 | data.setCoorPixelFromDouble(0, 0, dim.width - 1, dim.height - 1); |
||
219 | data.initSize(); |
||
220 | 21044 | nbrodin | getClippingPanel().saveStatus(data); |
221 | 21015 | nbrodin | |
222 | 19930 | nbrodin | getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(true);
|
223 | getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(true);
|
||
224 | } |
||
225 | 21737 | nbrodin | |
226 | 19930 | nbrodin | /**
|
227 | 15929 | bsanchez | * Al producirse un evento de perdida de foco o pulsaci?n de "enter" en un campo de texto de coordenadas
|
228 | * hay que asignar el nuevo valor introducido.
|
||
229 | * @param obj
|
||
230 | */
|
||
231 | private void eventJTextField(CoordinatesEvent e) { |
||
232 | try {
|
||
233 | 21538 | nbrodin | if (e.getSource() == getCoordinatesPanel().getPixelCoordinates()) {
|
234 | 13557 | bsanchez | if (e.getName().equals("11")) |
235 | 21538 | nbrodin | data.setUlxPx(Double.valueOf(getCoordinatesPanel().getPixelCoordinates().getValue11()).doubleValue());
|
236 | 13557 | bsanchez | if (e.getName().equals("12")) |
237 | 21538 | nbrodin | data.setUlyPx(Double.valueOf(getCoordinatesPanel().getPixelCoordinates().getValue12()).doubleValue());
|
238 | 13557 | bsanchez | if (e.getName().equals("21")) |
239 | 21538 | nbrodin | data.setLrxPx(Double.valueOf(getCoordinatesPanel().getPixelCoordinates().getValue21()).doubleValue());
|
240 | 13557 | bsanchez | if (e.getName().equals("22")) |
241 | 21538 | nbrodin | data.setLryPx(Double.valueOf(getCoordinatesPanel().getPixelCoordinates().getValue22()).doubleValue());
|
242 | 21015 | nbrodin | data.updateObservers(); |
243 | 13557 | bsanchez | } |
244 | 13021 | bsanchez | |
245 | 21538 | nbrodin | if (e.getSource() == getCoordinatesPanel().getRealCoordinates()) {
|
246 | 13557 | bsanchez | if (e.getName().equals("11")) |
247 | 21538 | nbrodin | data.setUlxWc(Double.valueOf(getCoordinatesPanel().getRealCoordinates().getValue11()).doubleValue());
|
248 | 13557 | bsanchez | if (e.getName().equals("12")) |
249 | 21538 | nbrodin | data.setUlyWc(Double.valueOf(getCoordinatesPanel().getRealCoordinates().getValue12()).doubleValue());
|
250 | 13557 | bsanchez | if (e.getName().equals("21")) |
251 | 21538 | nbrodin | data.setLrxWc(Double.valueOf(getCoordinatesPanel().getRealCoordinates().getValue21()).doubleValue());
|
252 | 13557 | bsanchez | if (e.getName().equals("22")) |
253 | 21538 | nbrodin | data.setLryWc(Double.valueOf(getCoordinatesPanel().getRealCoordinates().getValue22()).doubleValue());
|
254 | 21015 | nbrodin | data.updateObservers(); |
255 | 15929 | bsanchez | } |
256 | 13557 | bsanchez | } catch (NumberFormatException ex1) { |
257 | // No hay valores parseables a decimal en las cajas de texto. No hacemos nada
|
||
258 | 11352 | bsanchez | } |
259 | 15929 | bsanchez | } |
260 | 11897 | bsanchez | |
261 | 21015 | nbrodin | |
262 | 11352 | bsanchez | |
263 | 15929 | bsanchez | /**
|
264 | * Recalcula el valor de los campos de coordenadas reales y pixel. Cuando modificamos alg?n campo
|
||
265 | * de las coordenadas reales se modifican los pixeles y viceversa.
|
||
266 | * @param modifyPx true si se ha modificado alg?n campo de coordenadas pixel y false si se ha modificado
|
||
267 | * alg?n campo de las coordenadas reales.
|
||
268 | */
|
||
269 | private void recalcCoordFields(boolean modifyPx) { |
||
270 | 21015 | nbrodin | try {
|
271 | getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(false);
|
||
272 | getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(false);
|
||
273 | 15680 | bsanchez | |
274 | 21015 | nbrodin | if (modifyPx) {
|
275 | Point2D ulPx = new Point2D.Double(data.getUlxPx(), data.getUlyPx()); |
||
276 | Point2D lrPx = new Point2D.Double(data.getLrxPx(), data.getLryPx()); |
||
277 | 11352 | bsanchez | |
278 | 21015 | nbrodin | //Comprobamos que las esquinas no esten cambiadas de sitio
|
279 | if(ulPx.getX() > lrPx.getX()) {
|
||
280 | double ulTmp = ulPx.getX();
|
||
281 | ulPx.setLocation(lrPx.getX(), ulPx.getY()); |
||
282 | lrPx.setLocation(ulTmp, lrPx.getY()); |
||
283 | } |
||
284 | if(ulPx.getY() > lrPx.getY()) {
|
||
285 | double ulTmp = ulPx.getY();
|
||
286 | ulPx.setLocation(ulPx.getX(), lrPx.getY()); |
||
287 | lrPx.setLocation(lrPx.getX(), ulTmp); |
||
288 | } |
||
289 | |||
290 | //Ajustamos la selecci?n al ?rea
|
||
291 | ulPx = adjustPixelRequest(ulPx); |
||
292 | lrPx = adjustPixelRequest(lrPx); |
||
293 | 11897 | bsanchez | |
294 | 21015 | nbrodin | Point2D ulWc = new Point2D.Double(); |
295 | Point2D lrWc = new Point2D.Double(); |
||
296 | at.transform(ulPx, ulWc); |
||
297 | at.transform(new Point2D.Double(lrPx.getX() + 1, lrPx.getY() + 1), lrWc); |
||
298 | 11897 | bsanchez | |
299 | 21015 | nbrodin | data.setCoorRealFromDouble(ulWc.getX(), ulWc.getY(), lrWc.getX(), lrWc.getY()); |
300 | data.setCoorPixelFromDouble(ulPx.getX(), ulPx.getY(), lrPx.getX(), lrPx.getY()); |
||
301 | data.initSize(); |
||
302 | 21044 | nbrodin | getClippingPanel().saveStatus(data); |
303 | 21015 | nbrodin | |
304 | getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(true);
|
||
305 | getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(true);
|
||
306 | } else {
|
||
307 | Point2D ulWc = new Point2D.Double(data.getUlxWc(), data.getUlyWc()); |
||
308 | Point2D lrWc = new Point2D.Double(data.getLrxWc(), data.getLryWc()); |
||
309 | |||
310 | //Ajustamos la selecci?n al ?rea
|
||
311 | 21737 | nbrodin | ulWc = getFLayer().adjustWorldRequest(ulWc); |
312 | lrWc = getFLayer().adjustWorldRequest(lrWc); |
||
313 | 21015 | nbrodin | |
314 | Point2D ulPx = new Point2D.Double(); |
||
315 | Point2D lrPx = new Point2D.Double(); |
||
316 | |||
317 | try {
|
||
318 | at.inverseTransform(ulWc, ulPx); |
||
319 | at.inverseTransform(lrWc, lrPx); |
||
320 | } catch (NoninvertibleTransformException e) { |
||
321 | JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "coordenadas_erroneas")); |
||
322 | return;
|
||
323 | 15929 | bsanchez | } |
324 | 21015 | nbrodin | |
325 | data.setCoorRealFromDouble(ulWc.getX(), ulWc.getY(), lrWc.getX(), lrWc.getY()); |
||
326 | data.setCoorPixelFromDouble(Math.abs(ulPx.getX()), Math.abs(ulPx.getY()), Math.abs(lrPx.getX() - 1), Math.abs(lrPx.getY() - 1)); |
||
327 | data.initSize(); |
||
328 | 21044 | nbrodin | getClippingPanel().saveStatus(data); |
329 | 21015 | nbrodin | |
330 | getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(true);
|
||
331 | getClippingPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(true);
|
||
332 | 15929 | bsanchez | } |
333 | 21015 | nbrodin | } catch (NumberFormatException ex) { |
334 | return;
|
||
335 | 15929 | bsanchez | } |
336 | 13021 | bsanchez | |
337 | 15929 | bsanchez | } |
338 | 12807 | nacho | |
339 | 15929 | bsanchez | /**
|
340 | 21015 | nbrodin | * Ajusta las coordenadas especificadas en los par?metros al ?rea m?xima
|
341 | * del raster en p?xeles
|
||
342 | * @param req
|
||
343 | 15929 | bsanchez | */
|
344 | 21015 | nbrodin | private Point2D adjustPixelRequest(Point2D req) { |
345 | req.setLocation(Math.max(0, req.getX()), Math.max(0, req.getY())); |
||
346 | req.setLocation(Math.min(dim.width - 1, req.getX()), Math.min(dim.height - 1, req.getY())); |
||
347 | return req;
|
||
348 | 15929 | bsanchez | } |
349 | 21015 | nbrodin | |
350 | 15929 | bsanchez | /**
|
351 | * Invocaci?n de los eventos de la ventana de <code>DefaultButtonsPanel</code>
|
||
352 | */
|
||
353 | public void actionButtonPressed(ButtonsPanelEvent e) { |
||
354 | // Bot?n de Aceptar
|
||
355 | if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
||
356 | accept(); |
||
357 | close(); |
||
358 | } |
||
359 | 13134 | bsanchez | |
360 | 15929 | bsanchez | // Bot?n de Aplicar
|
361 | 17804 | nbrodin | if (e.getButton() == ButtonsPanel.BUTTON_APPLY)
|
362 | 15929 | bsanchez | accept(); |
363 | 11352 | bsanchez | |
364 | 15929 | bsanchez | // Bot?n de Cerrar
|
365 | 17804 | nbrodin | if (e.getButton() == ButtonsPanel.BUTTON_CANCEL)
|
366 | 15929 | bsanchez | close(); |
367 | 13134 | bsanchez | |
368 | 21044 | nbrodin | getFLayer().getMapContext().invalidate(); |
369 | 15929 | bsanchez | } |
370 | 11384 | bsanchez | |
371 | 15929 | bsanchez | /**
|
372 | * Cerrar la ventana del recorte
|
||
373 | */
|
||
374 | private void close() { |
||
375 | try {
|
||
376 | 21044 | nbrodin | if (getLastTool() != null) |
377 | getMapControl().setTool(getLastTool()); |
||
378 | 15929 | bsanchez | PluginServices.getMDIManager().closeWindow(getClippingPanel().getClippingDialog()); |
379 | } catch (ArrayIndexOutOfBoundsException ex) { |
||
380 | // Si la ventana no se puede eliminar no hacemos nada
|
||
381 | } |
||
382 | } |
||
383 | 11897 | bsanchez | |
384 | 15929 | bsanchez | /**
|
385 | * Obtener el <code>ClippingPanel</code> asociado
|
||
386 | * @return ClippingPanel
|
||
387 | */
|
||
388 | private ClippingPanel getClippingPanel() {
|
||
389 | return clippingPanel;
|
||
390 | } |
||
391 | |||
392 | private ClippingCoordinatesPanel getCoordinatesPanel() {
|
||
393 | 14846 | bsanchez | return getClippingPanel().getCoordinatesPanel();
|
394 | 14097 | bsanchez | } |
395 | 15929 | bsanchez | |
396 | 14829 | bsanchez | private ClippingResolutionPanel getResolutionPanel() {
|
397 | 14846 | bsanchez | return getClippingPanel().getResolutionPanel();
|
398 | 14097 | bsanchez | } |
399 | 15929 | bsanchez | |
400 | 14829 | bsanchez | private ClippingOptionsPanel getOptionsPanel() {
|
401 | 14846 | bsanchez | return getClippingPanel().getOptionsPanel();
|
402 | 14097 | bsanchez | } |
403 | 15929 | bsanchez | |
404 | 14829 | bsanchez | private ClippingSelectionPanel getSelectionPanel() {
|
405 | 14846 | bsanchez | return getClippingPanel().getSelectionPanel();
|
406 | 14097 | bsanchez | } |
407 | 11352 | bsanchez | |
408 | 15929 | bsanchez | /**
|
409 | * Acciones realizadas cuando se acepta en el dialogo. Se obtendr?n los datos
|
||
410 | * de recorte desde el dialogo, crearemos el objeto ClippingProcess que
|
||
411 | * gestiona el recortado, ajustamos el tama?o del grid de salida y procesamos.
|
||
412 | */
|
||
413 | private void accept() { |
||
414 | // Controlamos las coordenadas del recorte que no se salgan de la imagen.
|
||
415 | // De ser as? mostramos un error
|
||
416 | 21538 | nbrodin | CoordinatesPanel coordinatesReales = getCoordinatesPanel().getRealCoordinates(); |
417 | 15929 | bsanchez | double ulx = 0; |
418 | double lrx = 0; |
||
419 | double lry = 0; |
||
420 | double uly = 0; |
||
421 | try {
|
||
422 | ulx = Double.parseDouble(coordinatesReales.getValue11());
|
||
423 | lry = Double.parseDouble(coordinatesReales.getValue22());
|
||
424 | lrx = Double.parseDouble(coordinatesReales.getValue21());
|
||
425 | uly = Double.parseDouble(coordinatesReales.getValue12());
|
||
426 | 21044 | nbrodin | Rectangle2D ext = getFLayer().getFullExtent();
|
427 | 20610 | bsanchez | if (((int) ulx) > ((int) ext.getMaxX()) || ((int) lrx) < ((int) ext.getMinX()) || ((int) uly) > ((int) ext.getMaxY()) || ((int) lry) < ((int) ext.getMinY())) { |
428 | JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "coordenadas_erroneas")); |
||
429 | 15929 | bsanchez | return;
|
430 | } |
||
431 | } catch (NumberFormatException e) { |
||
432 | 20610 | bsanchez | JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "coordenadas_erroneas")); |
433 | 15929 | bsanchez | return;
|
434 | 21044 | nbrodin | } |
435 | 11897 | bsanchez | |
436 | 15929 | bsanchez | // Obtenemos las coordenadas del recorte
|
437 | 21538 | nbrodin | CoordinatesPanel coordinatesPixel = getCoordinatesPanel().getPixelCoordinates(); |
438 | 15929 | bsanchez | int[] dValues = new int[4]; |
439 | try {
|
||
440 | dValues[0] = (int) Math.round(Double.valueOf(coordinatesPixel.getValue11()).doubleValue()); |
||
441 | dValues[1] = (int) Math.round(Double.valueOf(coordinatesPixel.getValue22()).doubleValue()); |
||
442 | dValues[2] = (int) Math.round(Double.valueOf(coordinatesPixel.getValue21()).doubleValue()); |
||
443 | dValues[3] = (int) Math.round(Double.valueOf(coordinatesPixel.getValue12()).doubleValue()); |
||
444 | } catch (NumberFormatException exc) { |
||
445 | // Los valores de las cajas son incorrectos. Terminamos la funci?n
|
||
446 | return;
|
||
447 | } |
||
448 | 11897 | bsanchez | |
449 | 15929 | bsanchez | // Seleccionamos las bandas que se usaran en el recorte a partir de la tabla
|
450 | int countBands = 0; |
||
451 | int rowCount = ((CheckBoxModel) getSelectionPanel().getTableContainer().getModel()).getRowCount();
|
||
452 | for (int iRow = 0; iRow < rowCount; iRow++) |
||
453 | if ((((Boolean) ((CheckBoxModel) getSelectionPanel().getTableContainer().getModel()).getValueAt(iRow, 0))).booleanValue()) |
||
454 | countBands++; |
||
455 | 11352 | bsanchez | |
456 | 15929 | bsanchez | int[] drawableBands = new int[countBands]; |
457 | int i = 0; |
||
458 | for (int iRow = 0; iRow < rowCount; iRow++) { |
||
459 | if ((((Boolean) ((CheckBoxModel) getSelectionPanel().getTableContainer().getModel()).getValueAt(iRow, 0))).booleanValue()) { |
||
460 | int row = ((Integer) ((CheckBoxModel) getSelectionPanel().getTableContainer().getModel()).getValueAt(iRow, 2)).intValue(); |
||
461 | drawableBands[i++] = row; |
||
462 | } |
||
463 | } |
||
464 | 11352 | bsanchez | |
465 | 15929 | bsanchez | /**
|
466 | * Donde se va a guardar el fichero
|
||
467 | */
|
||
468 | 20610 | bsanchez | String path;
|
469 | if (getOptionsPanel().getCbSaveFile().isSelected())
|
||
470 | path = getOptionsPanel().getDirectoryTextField().getText(); |
||
471 | else
|
||
472 | 15929 | bsanchez | path = Utilities.createTempDirectory();
|
473 | 20610 | bsanchez | |
474 | 15929 | bsanchez | String file = getOptionsPanel().getFilenameTextField().getText();
|
475 | 20610 | bsanchez | if (file.compareTo(RasterLibrary.getOnlyLayerName()) == 0) |
476 | 18962 | nbrodin | RasterLibrary.usesOnlyLayerName(); |
477 | 11352 | bsanchez | |
478 | 20610 | bsanchez | if (file == "") |
479 | file = "cutlayer";
|
||
480 | |||
481 | 15929 | bsanchez | String filename = path + File.separator + file; |
482 | 20610 | bsanchez | |
483 | if (new File(filename + ".tif").exists()) |
||
484 | if (!RasterToolsUtil.messageBoxYesOrNot("raster_error_file_exists", getOptionsPanel())) |
||
485 | 17804 | nbrodin | return;
|
486 | 11384 | bsanchez | |
487 | 15929 | bsanchez | /**
|
488 | * Preparacion para la generacion del proceso del recorte
|
||
489 | */
|
||
490 | 21044 | nbrodin | if (getFLayer() == null) |
491 | 15929 | bsanchez | return;
|
492 | 11384 | bsanchez | |
493 | 15929 | bsanchez | WriterBufferServer dataWriter1 = new WriterBufferServer();
|
494 | 11384 | bsanchez | |
495 | 21044 | nbrodin | AffineTransform transf = calcAffineTransform(ulx, uly, lrx, lry,
|
496 | Math.round(data.getPxWidth()), Math.round(data.getPxHeight()), at); |
||
497 | 11897 | bsanchez | |
498 | 15929 | bsanchez | int interpMethod = getResolutionPanel().getSelectedInterpolationMethod();
|
499 | 20610 | bsanchez | |
500 | // Creamos la interpretaci?n de color para el caso de que la salida tenga
|
||
501 | // m?s de una banda por fichero. Siempre creamos RED, GREEN y BLUE
|
||
502 | 18042 | nbrodin | String[] ci = new String[drawableBands.length]; |
503 | for (int j = 0; j < ci.length; j++) { |
||
504 | switch (j) {
|
||
505 | 20610 | bsanchez | case 0: |
506 | if (ci.length >= 3) |
||
507 | ci[j] = DatasetColorInterpretation.RED_BAND; |
||
508 | else
|
||
509 | ci[j] = DatasetColorInterpretation.GRAY_BAND; |
||
510 | break;
|
||
511 | case 1: |
||
512 | if (ci.length >= 3) |
||
513 | ci[j] = DatasetColorInterpretation.GREEN_BAND; |
||
514 | else
|
||
515 | ci[j] = DatasetColorInterpretation.UNDEF_BAND; |
||
516 | break;
|
||
517 | case 2: |
||
518 | ci[j] = DatasetColorInterpretation.BLUE_BAND; |
||
519 | break;
|
||
520 | default:
|
||
521 | ci[j] = DatasetColorInterpretation.UNDEF_BAND; |
||
522 | break;
|
||
523 | 18042 | nbrodin | } |
524 | } |
||
525 | 20610 | bsanchez | |
526 | 17600 | nbrodin | RasterProcess clippingProcess = new ClippingProcess();
|
527 | clippingProcess.setActions(this);
|
||
528 | 21044 | nbrodin | clippingProcess.addParam("viewname", getViewName());
|
529 | 22051 | nbrodin | //clippingProcess.addParam("pixelcoordinates", dValues);
|
530 | clippingProcess.addParam("realcoordinates", new double[]{ulx, uly, lrx, lry}); |
||
531 | 17600 | nbrodin | clippingProcess.addParam("filename", filename);
|
532 | clippingProcess.addParam("datawriter", dataWriter1);
|
||
533 | 21044 | nbrodin | clippingProcess.addParam("layer", getFLayer());
|
534 | 17600 | nbrodin | clippingProcess.addParam("drawablebands", drawableBands);
|
535 | clippingProcess.addParam("onelayerperband", new Boolean(getOptionsPanel().getCbOneLyrPerBand().isSelected())); |
||
536 | clippingProcess.addParam("interpolationmethod", new Integer(interpMethod)); |
||
537 | clippingProcess.addParam("affinetransform", transf);
|
||
538 | 18042 | nbrodin | clippingProcess.addParam("colorInterpretation", new DatasetColorInterpretation(ci)); |
539 | 21015 | nbrodin | clippingProcess.addParam("resolution", new int[]{(int) Math.round(data.getPxWidth()), |
540 | (int) Math.round(data.getPxHeight())}); |
||
541 | 15929 | bsanchez | clippingProcess.start(); |
542 | } |
||
543 | 12030 | bsanchez | |
544 | 15929 | bsanchez | /**
|
545 | * Calcula la matriz de transformaci?n que se usar? para el nuevo raster generado.
|
||
546 | * @param ulx Coordenada X real de la esquina superior izquierda
|
||
547 | * @param uly Coordenada Y real de la esquina superior izquierda
|
||
548 | * @param lrx Coordenada X real de la esquina inferior derecha
|
||
549 | * @param lry Coordenada Y real de la esquina inferior derecha
|
||
550 | * @param width Ancho en p?xeles del nuevo raster
|
||
551 | * @param height Alto en p?xeles del nuevo raster
|
||
552 | 21044 | nbrodin | * @param trans Matriz de transformaci?n de la nueva capa
|
553 | 15929 | bsanchez | * @return Matriz de transformaci?n para el nuevo raster
|
554 | */
|
||
555 | 21044 | nbrodin | private AffineTransform calcAffineTransform(double ulx, double uly, double lrx, double lry, |
556 | double width, double height, AffineTransform trans) { |
||
557 | 15929 | bsanchez | Point2D ul = new Point2D.Double(ulx, uly); |
558 | Point2D lr = new Point2D.Double(lrx, lry); |
||
559 | try {
|
||
560 | 21044 | nbrodin | trans.inverseTransform(ul, ul); |
561 | trans.inverseTransform(lr, lr); |
||
562 | 15929 | bsanchez | } catch (NoninvertibleTransformException e) { |
563 | 21044 | nbrodin | JOptionPane.showMessageDialog(null, RasterToolsUtil.getText(this, "coordenadas_erroneas")); |
564 | 15929 | bsanchez | return new AffineTransform(); |
565 | } |
||
566 | double w = Math.abs(lr.getX() - ul.getX()); |
||
567 | 11897 | bsanchez | |
568 | 15929 | bsanchez | Point2D ur = new Point2D.Double(ul.getX() + w, ul.getY()); |
569 | Point2D ll = new Point2D.Double(lr.getX() - w, lr.getY() ); |
||
570 | 13021 | bsanchez | |
571 | 15929 | bsanchez | //Obtenemos la georreferenciaci?n de las cuatro esquinas del nuevo raster
|
572 | 21044 | nbrodin | trans.transform(ul, ul); |
573 | trans.transform(ur, ur); |
||
574 | trans.transform(lr, lr); |
||
575 | trans.transform(ll, ll); |
||
576 | 13021 | bsanchez | |
577 | 15929 | bsanchez | double pixelSizeX = (ur.getX() - ul.getX()) / width;
|
578 | double pixelSizeY = (ll.getY() - ul.getY()) / height;
|
||
579 | 21044 | nbrodin | double rotX = trans.getShearX();
|
580 | double rotY = trans.getShearY();
|
||
581 | 15929 | bsanchez | return new AffineTransform(pixelSizeX, rotY, rotX, pixelSizeY, ulx, uly); |
582 | } |
||
583 | 14083 | nbrodin | |
584 | 15929 | bsanchez | /*
|
585 | * (non-Javadoc)
|
||
586 | * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
|
||
587 | */
|
||
588 | public boolean cancelDrawing() { |
||
589 | return false; |
||
590 | } |
||
591 | 13021 | bsanchez | |
592 | 15929 | bsanchez | /*
|
593 | * (non-Javadoc)
|
||
594 | * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
|
||
595 | 15782 | bsanchez | */
|
596 | 15929 | bsanchez | public Cursor getCursor() { |
597 | return null; |
||
598 | } |
||
599 | |||
600 | 14083 | nbrodin | /*
|
601 | * (non-Javadoc)
|
||
602 | 15929 | bsanchez | * @see org.gvsig.gui.beans.coordinatespanel.CoordinatesListener#actionValueChanged(org.gvsig.gui.beans.coordinatespanel.CoordinatesEvent)
|
603 | 14083 | nbrodin | */
|
604 | 15929 | bsanchez | public void actionValueChanged(CoordinatesEvent e) { |
605 | 21538 | nbrodin | if (e.getSource() == getCoordinatesPanel().getPixelCoordinates()) {
|
606 | 15929 | bsanchez | eventJTextField(e); |
607 | recalcCoordFields(true);
|
||
608 | } |
||
609 | 21538 | nbrodin | if (e.getSource() == getCoordinatesPanel().getRealCoordinates()) {
|
610 | 15929 | bsanchez | eventJTextField(e); |
611 | recalcCoordFields(false);
|
||
612 | } |
||
613 | } |
||
614 | 15782 | bsanchez | |
615 | 15929 | bsanchez | /*
|
616 | * (non-Javadoc)
|
||
617 | * @see org.gvsig.gui.beans.datainput.DataInputContainerListener#actionValueChanged(java.util.EventObject)
|
||
618 | */
|
||
619 | public void actionValueChanged(EventObject e) { |
||
620 | if(!enableValueChangedEvent)
|
||
621 | return;
|
||
622 | 15782 | bsanchez | |
623 | 15929 | bsanchez | enableValueChangedEvent = false; //Desactivamos el evento de cambio de valor de las cajas de texto para que no se bucle |
624 | 15782 | bsanchez | |
625 | 15929 | bsanchez | if (e.getSource() == getResolutionPanel().getCCellSize().getDataInputField()) {
|
626 | // Cambiamos PS ==> wPx=wWC/PS & hPx=wPx/rel
|
||
627 | double ps = 0; |
||
628 | try {
|
||
629 | ps = Double.parseDouble(getResolutionPanel().getCCellSize().getValue());
|
||
630 | } catch (NumberFormatException ex) { |
||
631 | return;
|
||
632 | } |
||
633 | 21015 | nbrodin | data.setPxWidth(data.getWcWidth() / ps); |
634 | data.setPxHeight(data.getWcHeight() / ps); |
||
635 | data.updateObservers(); |
||
636 | 15929 | bsanchez | } else if (e.getSource() == getResolutionPanel().getCWidth().getDataInputField()) { |
637 | // Cambiamos wPx ==> hPx=wPx/rel & PS=wWC/wPx
|
||
638 | double wPx = 0; |
||
639 | try {
|
||
640 | wPx = Double.parseDouble(getResolutionPanel().getCWidth().getValue());
|
||
641 | } catch (NumberFormatException ex) { |
||
642 | return;
|
||
643 | } |
||
644 | 21015 | nbrodin | data.setPxWidth(wPx); |
645 | data.setPxHeight(Math.round(wPx / data.getRatio()));
|
||
646 | data.updateObservers(); |
||
647 | 15929 | bsanchez | } else if (e.getSource() == getResolutionPanel().getCHeight().getDataInputField()) { |
648 | // Cambiamos hPx ==> wPx=rel*wPx & PS=hWC/hPx
|
||
649 | double hPx = 0; |
||
650 | try {
|
||
651 | hPx = Double.parseDouble(getResolutionPanel().getCHeight().getValue());
|
||
652 | } catch (NumberFormatException ex) { |
||
653 | return;
|
||
654 | } |
||
655 | 21015 | nbrodin | data.setPxHeight(hPx); |
656 | data.setPxWidth(Math.round(Math.round(hPx * data.getRatio()))); |
||
657 | data.updateObservers(); |
||
658 | 15782 | bsanchez | } |
659 | 15929 | bsanchez | enableValueChangedEvent = true;
|
660 | 14083 | nbrodin | } |
661 | 14527 | nbrodin | |
662 | /**
|
||
663 | 15929 | bsanchez | * Asigna el valor para la activaci?n y desactivaci?n del evento de cambio de valor en
|
664 | 14527 | nbrodin | * las cajas de texto.
|
665 | * @param enableValueChangedEvent
|
||
666 | */
|
||
667 | public void setEnableValueChangedEvent(boolean enableValueChangedEvent) { |
||
668 | this.enableValueChangedEvent = enableValueChangedEvent;
|
||
669 | } |
||
670 | 15929 | bsanchez | |
671 | 20650 | nbrodin | /*
|
672 | * (non-Javadoc)
|
||
673 | * @see org.gvsig.raster.IProcessActions#end(java.lang.Object)
|
||
674 | */
|
||
675 | 15929 | bsanchez | public void end(Object params) { |
676 | if( params instanceof Object[] && |
||
677 | 16167 | nbrodin | ((Object[])params).length == 2 && |
678 | ((Object[])params)[0] instanceof String && |
||
679 | ((Object[])params)[1] instanceof Long) { |
||
680 | 15929 | bsanchez | |
681 | 16167 | nbrodin | String fName = (String)((Object[])params)[0]; |
682 | long milis = ((Long)((Object[])params)[1]).longValue(); |
||
683 | 15929 | bsanchez | |
684 | 21684 | bsanchez | EndInfoDialog.show(fName, milis); |
685 | 15929 | bsanchez | } |
686 | } |
||
687 | 21044 | nbrodin | |
688 | /**
|
||
689 | * Obtener la capa de un raster.
|
||
690 | * @return
|
||
691 | */
|
||
692 | public FLyrRasterSE getFLayer() {
|
||
693 | return fLayer;
|
||
694 | } |
||
695 | |||
696 | /**
|
||
697 | * Obtiene la ultima herramienta seleccionada antes de cargar el recorte
|
||
698 | * @return
|
||
699 | */
|
||
700 | public String getLastTool() { |
||
701 | return lastTool;
|
||
702 | } |
||
703 | 15929 | bsanchez | |
704 | 21044 | nbrodin | /**
|
705 | * Obtiene el nombre de la vista
|
||
706 | * @return
|
||
707 | */
|
||
708 | public String getViewName() { |
||
709 | return viewName;
|
||
710 | } |
||
711 | |||
712 | /**
|
||
713 | * Establecer la capa para usarla en el recorte
|
||
714 | * @param fLayer
|
||
715 | */
|
||
716 | public void setLayer(FLyrRasterSE fLayer) { |
||
717 | this.fLayer = fLayer;
|
||
718 | View view = (View) PluginServices.getMDIManager().getActiveWindow(); |
||
719 | viewName = PluginServices.getMDIManager().getWindowInfo(view).getTitle(); |
||
720 | mapControl = view.getMapControl(); |
||
721 | |||
722 | lastTool = mapControl.getCurrentTool(); |
||
723 | |||
724 | // Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
||
725 | // la barra de estado
|
||
726 | StatusBarListener sbl = new StatusBarListener(mapControl);
|
||
727 | |||
728 | // Cortar Raster
|
||
729 | ClippingMouseViewListener clippingMouseViewListener = new ClippingMouseViewListener(mapControl, getClippingPanel(), data, fLayer);
|
||
730 | mapControl.addMapTool("cutRaster", new Behavior[] { |
||
731 | new RectangleBehavior(clippingMouseViewListener), new MouseMovementBehavior(sbl) |
||
732 | } |
||
733 | ); |
||
734 | |||
735 | getSelectionPanel().setLayer(fLayer); |
||
736 | |||
737 | // Obtener la extension completa de la capa
|
||
738 | |||
739 | if(fLayer instanceof IRasterGeoOperations && fLayer instanceof IRasterOperations) { |
||
740 | setAffineTransform(((IRasterGeoOperations)fLayer).getAffineTransform()); |
||
741 | setDimension(new Dimension((int)((IRasterOperations)fLayer).getPxWidth(), (int)((IRasterOperations)fLayer).getPxHeight())); |
||
742 | } else {
|
||
743 | RasterToolsUtil.messageBoxError("Error obteniendo el extent.", this); |
||
744 | return;
|
||
745 | } |
||
746 | |||
747 | } |
||
748 | |||
749 | /**
|
||
750 | * Acciones que se realizan para seleccionar la tool CutRaster
|
||
751 | */
|
||
752 | public void selectToolButton() { |
||
753 | // seleccionamos la vista de gvSIG
|
||
754 | com.iver.cit.gvsig.project.documents.view.gui.View theView = null;
|
||
755 | try {
|
||
756 | IWindow[] allViews = PluginServices.getMDIManager().getAllWindows();
|
||
757 | for (int i = 0; i < allViews.length; i++) { |
||
758 | if (allViews[i] instanceof com.iver.cit.gvsig.project.documents.view.gui.View |
||
759 | && PluginServices.getMDIManager().getWindowInfo((View) allViews[i])
|
||
760 | .getTitle().equals(viewName)) |
||
761 | theView = (com.iver.cit.gvsig.project.documents.view.gui.View) allViews[i]; |
||
762 | } |
||
763 | if (theView == null) |
||
764 | return;
|
||
765 | } catch (ClassCastException ex) { |
||
766 | 22529 | bsanchez | // RasterToolsUtil.messageBoxError("cant_get_view "), this, ex);
|
767 | 21044 | nbrodin | return;
|
768 | } |
||
769 | MapControl m_MapControl = theView.getMapControl(); |
||
770 | |||
771 | // Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
||
772 | // la barra de estado
|
||
773 | StatusBarListener sbl = new StatusBarListener(m_MapControl);
|
||
774 | |||
775 | // Cortar Raster
|
||
776 | ClippingMouseViewListener clippingMouseViewListener = new ClippingMouseViewListener(m_MapControl, getClippingPanel(), data, getFLayer());
|
||
777 | m_MapControl.addMapTool("cutRaster", new Behavior[] { |
||
778 | new RectangleBehavior(clippingMouseViewListener), new MouseMovementBehavior(sbl) |
||
779 | } |
||
780 | ); |
||
781 | |||
782 | m_MapControl.setTool("cutRaster");
|
||
783 | } |
||
784 | |||
785 | /**
|
||
786 | * Obtiene el <code>MapControl</code> de gvSIG
|
||
787 | * @return <code>MapControl</code>
|
||
788 | */
|
||
789 | public MapControl getMapControl() {
|
||
790 | return mapControl;
|
||
791 | } |
||
792 | |||
793 | |||
794 | 15929 | bsanchez | public void rectangle(RectangleEvent event) throws BehaviorException {} |
795 | public void interrupted() {} |
||
796 | 11352 | bsanchez | } |