root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / cutting / ui / CuttingPanel.java @ 11414
History | View | Annotate | Download (23.8 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.cutting.ui; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Dimension; |
23 |
import java.awt.GridBagConstraints; |
24 |
import java.awt.GridBagLayout; |
25 |
import java.awt.Insets; |
26 |
import java.io.File; |
27 |
import java.util.ArrayList; |
28 |
|
29 |
import javax.swing.JCheckBox; |
30 |
import javax.swing.JLabel; |
31 |
import javax.swing.JPanel; |
32 |
import javax.swing.JTabbedPane; |
33 |
import javax.swing.JTextField; |
34 |
|
35 |
import org.gvsig.fmap.layers.FLyrRasterSE; |
36 |
import org.gvsig.gui.beans.buttonbar.ButtonBarContainer; |
37 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
38 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
39 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
40 |
import org.gvsig.gui.beans.coorddatainput.CoordDataInputContainer; |
41 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
42 |
import org.gvsig.gui.beans.table.TableContainer; |
43 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
44 |
import org.gvsig.raster.dataset.RasterMultiDataset; |
45 |
import org.gvsig.rastertools.cutting.ui.listener.CuttingMouseViewListener; |
46 |
import org.gvsig.rastertools.cutting.ui.listener.CuttingPanelListener; |
47 |
|
48 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
49 |
import com.iver.andami.PluginServices; |
50 |
import com.iver.andami.ui.mdiManager.IWindow; |
51 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
52 |
import com.iver.cit.gvsig.fmap.MapControl; |
53 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
54 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
55 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
56 |
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
57 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
58 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
59 |
/**
|
60 |
* <code>CuttingPanel</code>. Interfaz de usuario para el recorte de rasters.
|
61 |
*
|
62 |
* @version 17/04/2007
|
63 |
* @author Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
64 |
*/
|
65 |
public class CuttingPanel extends DefaultButtonsPanel implements ButtonsPanelListener { |
66 |
private static final long serialVersionUID = 3078196473228467834L; |
67 |
|
68 |
private int wPanel = 420; |
69 |
|
70 |
private CuttingDialog cuttingDialog = null; |
71 |
|
72 |
private CoordDataInputContainer coor_pixel = null; |
73 |
private CoordDataInputContainer coor_reales = null; |
74 |
private ButtonBarContainer buttonBarContainer = null; |
75 |
private JPanel pSelection = null; |
76 |
private JPanel jOptions = null; |
77 |
private JPanel jPNameFile = null; |
78 |
private TableContainer tSelection = null; |
79 |
private ResolutionPanel pResolution = null; |
80 |
private JCheckBox jCheckBox = null; |
81 |
private JCheckBox jCheckLoadLayerInToc = null; |
82 |
private JCheckBox jCheckSaveFile = null; |
83 |
private JTextField filenameTextField = null; |
84 |
private JTabbedPane jTabbedPane1 = null; |
85 |
|
86 |
private FLayer fLayer = null; |
87 |
|
88 |
/**
|
89 |
* Variable para numerar las nuevos recortes creados.
|
90 |
* @see #setNewLayerText()
|
91 |
*/
|
92 |
static int numberNewLayer = 1; |
93 |
|
94 |
/**
|
95 |
* Valores reales para el ancho, alto y tama?o de celda. Esto es necesario porque
|
96 |
* en la caja de texto se guardan con decimales recortados y cuando se pide el valor
|
97 |
* se devuelven completos.
|
98 |
*/
|
99 |
private double realWidth, realHeight; |
100 |
|
101 |
/**
|
102 |
* Relaci?n entre el ancho y alto en pixeles de la imagen
|
103 |
*/
|
104 |
private double relWidthHeight = 0; |
105 |
|
106 |
/**
|
107 |
* Valores reales para el tama?o de la ventana. Esto es necesario porque
|
108 |
* en la caja de texto se guardan con decimales recortados y cuando se pide el valor
|
109 |
* se devuelven completos.
|
110 |
*/
|
111 |
private double wcMinX, wcMinY, wcMaxX, wcMaxY; |
112 |
private double pxMinX, pxMinY, pxMaxX, pxMaxY; |
113 |
|
114 |
CuttingPanelListener cuttingPanelListener = null;
|
115 |
|
116 |
/**
|
117 |
* Herramienta seleccionada en el momento de la apertura del dialogo
|
118 |
*/
|
119 |
private String lastTool = null; |
120 |
private MapControl mapControl = null; |
121 |
private String viewName = null; |
122 |
|
123 |
/**
|
124 |
* Crea un nuevo <code>CuttingPanel</code>
|
125 |
* @param cuttingDialog
|
126 |
*/
|
127 |
public CuttingPanel(CuttingDialog cuttingDialog) {
|
128 |
super(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY);
|
129 |
|
130 |
this.cuttingDialog = cuttingDialog;
|
131 |
initialize(); |
132 |
cuttingPanelListener = new CuttingPanelListener(this); |
133 |
|
134 |
getCoor_pixel().getPDataInput11().getJTextField().addKeyListener(cuttingPanelListener); |
135 |
getCoor_pixel().getPDataInput11().getJTextField().addFocusListener(cuttingPanelListener); |
136 |
getCoor_pixel().getPDataInput12().getJTextField().addKeyListener(cuttingPanelListener); |
137 |
getCoor_pixel().getPDataInput12().getJTextField().addFocusListener(cuttingPanelListener); |
138 |
getCoor_pixel().getPDataInput21().getJTextField().addKeyListener(cuttingPanelListener); |
139 |
getCoor_pixel().getPDataInput21().getJTextField().addFocusListener(cuttingPanelListener); |
140 |
getCoor_pixel().getPDataInput22().getJTextField().addKeyListener(cuttingPanelListener); |
141 |
getCoor_pixel().getPDataInput22().getJTextField().addFocusListener(cuttingPanelListener); |
142 |
|
143 |
getCoor_reales().getPDataInput11().getJTextField().addKeyListener(cuttingPanelListener); |
144 |
getCoor_reales().getPDataInput11().getJTextField().addFocusListener(cuttingPanelListener); |
145 |
getCoor_reales().getPDataInput12().getJTextField().addKeyListener(cuttingPanelListener); |
146 |
getCoor_reales().getPDataInput12().getJTextField().addFocusListener(cuttingPanelListener); |
147 |
getCoor_reales().getPDataInput21().getJTextField().addKeyListener(cuttingPanelListener); |
148 |
getCoor_reales().getPDataInput21().getJTextField().addFocusListener(cuttingPanelListener); |
149 |
getCoor_reales().getPDataInput22().getJTextField().addKeyListener(cuttingPanelListener); |
150 |
getCoor_reales().getPDataInput22().getJTextField().addFocusListener(cuttingPanelListener); |
151 |
|
152 |
getPResolution().getCCellSize().getJTextField().addKeyListener(cuttingPanelListener); |
153 |
getPResolution().getCCellSize().getJTextField().addFocusListener(cuttingPanelListener); |
154 |
getPResolution().getCWidth().getJTextField().addKeyListener(cuttingPanelListener); |
155 |
getPResolution().getCWidth().getJTextField().addFocusListener(cuttingPanelListener); |
156 |
getPResolution().getCHeight().getJTextField().addKeyListener(cuttingPanelListener); |
157 |
getPResolution().getCHeight().getJTextField().addFocusListener(cuttingPanelListener); |
158 |
|
159 |
getButtonBarContainer().getButton(0).addActionListener(cuttingPanelListener);
|
160 |
getButtonBarContainer().getButton(1).addActionListener(cuttingPanelListener);
|
161 |
|
162 |
this.addButtonPressedListener(cuttingPanelListener);
|
163 |
} |
164 |
|
165 |
/**
|
166 |
* Obtener el <code>CuttingDialog</code> asociado a este objeto.
|
167 |
* @return CuttingDialog
|
168 |
*/
|
169 |
public CuttingDialog getCuttingDialog() {
|
170 |
return cuttingDialog;
|
171 |
} |
172 |
|
173 |
/**
|
174 |
* Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
|
175 |
* en cada llamada un nombre consecutivo.
|
176 |
*/
|
177 |
public void setNewLayerText() { |
178 |
filenameTextField.setText("NewLayer_" + CuttingPanel.numberNewLayer);
|
179 |
CuttingPanel.numberNewLayer++; |
180 |
} |
181 |
|
182 |
/**
|
183 |
* Obtener la capa de un raster.
|
184 |
* @return
|
185 |
*/
|
186 |
public FLayer getFLayer() {
|
187 |
return fLayer;
|
188 |
} |
189 |
|
190 |
/**
|
191 |
* Establecer la capa para usarla en el recorte
|
192 |
* @param fLayer
|
193 |
*/
|
194 |
public void setLayer(FLayer fLayer) { |
195 |
this.fLayer = fLayer;
|
196 |
View view = (View) PluginServices.getMDIManager().getActiveWindow(); |
197 |
viewName = PluginServices.getMDIManager().getWindowInfo(view).getTitle(); |
198 |
mapControl = view.getMapControl(); |
199 |
|
200 |
lastTool = mapControl.getCurrentTool(); |
201 |
|
202 |
// Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
203 |
// la barra de estado
|
204 |
StatusBarListener sbl = new StatusBarListener(mapControl);
|
205 |
|
206 |
// Cortar Raster
|
207 |
CuttingMouseViewListener cuttingMouseListener = new CuttingMouseViewListener(mapControl, this); |
208 |
mapControl.addMapTool("cutRaster", new Behavior[] { |
209 |
new RectangleBehavior(cuttingMouseListener), new MouseMovementBehavior(sbl) |
210 |
} |
211 |
); |
212 |
|
213 |
// Rellenar el arbol de bandas
|
214 |
RasterMultiDataset mDataset = ((FLyrRasterSE) fLayer).getDatasource().getGeoRasterMultiFile(); |
215 |
for (int i = 0; i < mDataset.getDatasetCount(); i++) { |
216 |
String fName = mDataset.getDataset(i).getFName();
|
217 |
String bandName = new File(fName).getName(); |
218 |
|
219 |
if (mDataset.getDataset(i).getBandCount() > 1) { |
220 |
for (int b = 0; b < mDataset.getDataset(i).getBandCount(); b++) { |
221 |
Object row[] = { new Boolean(true), |
222 |
new String("B" + (b + 1) + " - " + bandName) }; |
223 |
try {
|
224 |
getTSelection().addRow(row); |
225 |
} catch (NotInitializeException e) {
|
226 |
e.printStackTrace(); |
227 |
} |
228 |
} |
229 |
} else {
|
230 |
Object row[] = { new Boolean(true), new String("B - " + bandName) }; |
231 |
try {
|
232 |
getTSelection().addRow(row); |
233 |
} catch (NotInitializeException e) {
|
234 |
e.printStackTrace(); |
235 |
} |
236 |
} |
237 |
} |
238 |
|
239 |
// Obtener la extension completa de la capa
|
240 |
try {
|
241 |
cuttingPanelListener.setExtent(fLayer.getFullExtent()); |
242 |
} catch (ExpansionFileReadException e) {
|
243 |
e.printStackTrace(); |
244 |
} catch (ReadDriverException e) {
|
245 |
e.printStackTrace(); |
246 |
} |
247 |
|
248 |
// Definir el ancho y el alto de la vista en pixeles.
|
249 |
ArrayList attr = ((FLyrRasterSE) fLayer).getSource().getAttributes();
|
250 |
for (int i = 0; i < attr.size(); i++) { |
251 |
Object[] a = (Object[]) attr.get(i); |
252 |
if (a[0].toString().equals("Width")) |
253 |
cuttingPanelListener.setWidthPx(((Integer) a[1]).intValue()); |
254 |
if (a[0].toString().equals("Height")) |
255 |
cuttingPanelListener.setHeightPx(((Integer) a[1]).intValue()); |
256 |
} |
257 |
} |
258 |
|
259 |
/**
|
260 |
* Acciones que se realizan para seleccionar la tool CutRaster
|
261 |
*/
|
262 |
public void selectToolButton() { |
263 |
// seleccionamos la vista de gvSIG
|
264 |
com.iver.cit.gvsig.project.documents.view.gui.View theView = null;
|
265 |
try {
|
266 |
IWindow[] allViews = PluginServices.getMDIManager().getAllWindows();
|
267 |
for (int i = 0; i < allViews.length; i++) { |
268 |
if (allViews[i] instanceof com.iver.cit.gvsig.project.documents.view.gui.View |
269 |
&& PluginServices.getMDIManager().getWindowInfo((View) allViews[i])
|
270 |
.getTitle().equals(viewName)) |
271 |
theView = (com.iver.cit.gvsig.project.documents.view.gui.View) allViews[i]; |
272 |
} |
273 |
if (theView == null) |
274 |
return;
|
275 |
} catch (ClassCastException ex) { |
276 |
// logger.error(PluginServices.getText(this, "cant_get_view "), ex);
|
277 |
return;
|
278 |
} |
279 |
MapControl m_MapControl = theView.getMapControl(); |
280 |
|
281 |
// Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
282 |
// la barra de estado
|
283 |
StatusBarListener sbl = new StatusBarListener(m_MapControl);
|
284 |
|
285 |
// Cortar Raster
|
286 |
CuttingMouseViewListener cuttingMouseListener = new CuttingMouseViewListener(m_MapControl, this); |
287 |
m_MapControl.addMapTool("cutRaster", new Behavior[] { |
288 |
new RectangleBehavior(cuttingMouseListener), new MouseMovementBehavior(sbl) |
289 |
} |
290 |
); |
291 |
|
292 |
m_MapControl.setTool("cutRaster");
|
293 |
} |
294 |
|
295 |
/**
|
296 |
* This method initializes this
|
297 |
*/
|
298 |
private void initialize() { |
299 |
jTabbedPane1 = new JTabbedPane(); |
300 |
|
301 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
302 |
gridBagConstraints.gridx = 0;
|
303 |
gridBagConstraints.gridy = 0;
|
304 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
305 |
gridBagConstraints1.gridx = 0;
|
306 |
gridBagConstraints1.gridy = 1;
|
307 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
308 |
gridBagConstraints2.gridx = 0;
|
309 |
gridBagConstraints2.gridy = 2;
|
310 |
gridBagConstraints2.insets = new java.awt.Insets(5, 0, 0, 0); |
311 |
|
312 |
JPanel jpanel1 = new JPanel(); |
313 |
jpanel1.setLayout(new GridBagLayout()); |
314 |
jpanel1.add(getCoor_pixel(), gridBagConstraints); |
315 |
jpanel1.add(getCoor_reales(), gridBagConstraints1); |
316 |
jpanel1.add(getButtonBarContainer(), gridBagConstraints2); |
317 |
|
318 |
jTabbedPane1.addTab(PluginServices.getText(this, "coordenadas_recorte"), jpanel1); |
319 |
jTabbedPane1.addTab(PluginServices.getText(this, "resolucion_espacial"), getPResolution()); |
320 |
jTabbedPane1.addTab(PluginServices.getText(this, "seleccion_bandas"), getPSelection()); |
321 |
jTabbedPane1.addTab(PluginServices.getText(this, "otras_opciones"), getJOptions()); |
322 |
|
323 |
this.setLayout(new BorderLayout()); |
324 |
this.add(jTabbedPane1, BorderLayout.CENTER); |
325 |
|
326 |
setNewLayerText(); |
327 |
} |
328 |
|
329 |
/*
|
330 |
* (non-Javadoc)
|
331 |
* @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
|
332 |
*/
|
333 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
334 |
} |
335 |
|
336 |
/**
|
337 |
* This method initializes jPanel
|
338 |
*
|
339 |
* @return javax.swing.JPanel
|
340 |
*/
|
341 |
public CoordDataInputContainer getCoor_pixel() {
|
342 |
if (coor_pixel == null) { |
343 |
coor_pixel = new CoordDataInputContainer(wPanel, 90); |
344 |
coor_pixel.setParameters(PluginServices.getText(this, "coordenadas_pixel"), |
345 |
PluginServices.getText(this, "sup_izq"), |
346 |
"X" ,"Y", |
347 |
PluginServices.getText(this, "inf_der"), |
348 |
"X", "Y"); |
349 |
coor_pixel.setDecimalValues(true);
|
350 |
} |
351 |
return coor_pixel;
|
352 |
} |
353 |
|
354 |
/**
|
355 |
* This method initializes jPanel1
|
356 |
*
|
357 |
* @return javax.swing.JPanel
|
358 |
*/
|
359 |
public CoordDataInputContainer getCoor_reales() {
|
360 |
if (coor_reales == null) { |
361 |
coor_reales = new CoordDataInputContainer(wPanel, 90); |
362 |
coor_reales.setParameters(PluginServices.getText(this, "coordenadas_reales"), |
363 |
PluginServices.getText(this, "sup_izq"), |
364 |
"X" ,"Y", |
365 |
PluginServices.getText(this, "inf_der"), |
366 |
"X", "Y"); |
367 |
coor_reales.setDecimalValues(true);
|
368 |
} |
369 |
return coor_reales;
|
370 |
} |
371 |
|
372 |
/**
|
373 |
* This method initializes jButton
|
374 |
*
|
375 |
* @return javax.swing.JButton
|
376 |
*/
|
377 |
public ButtonBarContainer getButtonBarContainer() {
|
378 |
if (buttonBarContainer == null) { |
379 |
buttonBarContainer = new ButtonBarContainer();
|
380 |
buttonBarContainer.setPreferredSize(new java.awt.Dimension(wPanel - 4, 32)); |
381 |
buttonBarContainer.addButton("fullExtent.png", PluginServices.getText(this, "fullExtent"), 0); |
382 |
buttonBarContainer.addButton("selectTool.png", PluginServices.getText(this, "select_tool"), 1); |
383 |
buttonBarContainer.setButtonAlignment("right");
|
384 |
buttonBarContainer.setComponentBorder(false);
|
385 |
} |
386 |
return buttonBarContainer;
|
387 |
} |
388 |
|
389 |
/**
|
390 |
* This method initializes jPanel
|
391 |
*
|
392 |
* @return javax.swing.JPanel
|
393 |
*/
|
394 |
public ResolutionPanel getPResolution() {
|
395 |
if (pResolution == null) { |
396 |
pResolution = new ResolutionPanel();
|
397 |
pResolution.setPreferredSize(new java.awt.Dimension(wPanel, 120)); |
398 |
pResolution.validate(); |
399 |
} |
400 |
return pResolution;
|
401 |
} |
402 |
|
403 |
/**
|
404 |
* This method initializes jPanel1
|
405 |
*
|
406 |
* @return javax.swing.JPanel
|
407 |
*/
|
408 |
private JPanel getPSelection() { |
409 |
if (pSelection == null) { |
410 |
pSelection = new JPanel(); |
411 |
pSelection.setLayout(new BorderLayout()); |
412 |
pSelection.setPreferredSize(new java.awt.Dimension(wPanel, 120)); |
413 |
pSelection.add(getTSelection(), BorderLayout.CENTER);
|
414 |
|
415 |
} |
416 |
return pSelection;
|
417 |
} |
418 |
|
419 |
/**
|
420 |
* Obtiene la tabla de selecci?n de bandas
|
421 |
* @return Tabla de selecci?n de bandas
|
422 |
*/
|
423 |
public TableContainer getTSelection(){
|
424 |
if (tSelection == null) { |
425 |
String[] columnNames = {PluginServices.getText(this, "bandas"), PluginServices.getText(this, "nombre")}; |
426 |
int[] columnWidths = {75, 305}; |
427 |
tSelection = new TableContainer(columnNames, columnWidths);
|
428 |
tSelection.setModel("CheckBoxModel");
|
429 |
tSelection.setControlVisible(false);
|
430 |
tSelection.initialize(); |
431 |
} |
432 |
|
433 |
return tSelection;
|
434 |
} |
435 |
|
436 |
/**
|
437 |
* This method initializes jOptions
|
438 |
*
|
439 |
* @return javax.swing.JPanel
|
440 |
*/
|
441 |
private JPanel getJOptions() { |
442 |
if (jOptions == null) { |
443 |
jOptions = new JPanel(); |
444 |
jOptions.setLayout(new GridBagLayout()); |
445 |
jOptions.add(getJPNameFile(), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, |
446 |
GridBagConstraints.CENTER, GridBagConstraints.BOTH, |
447 |
new Insets(0, 0, 5, 5), 0, 0)); |
448 |
jOptions.add(getCbOneLyrPerBand(), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, |
449 |
GridBagConstraints.CENTER, GridBagConstraints.BOTH, |
450 |
new Insets(0, 0, 5, 5), 0, 0)); |
451 |
jOptions.add(getCbSaveFile(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, |
452 |
GridBagConstraints.CENTER, GridBagConstraints.BOTH, |
453 |
new Insets(0, 0, 5, 5), 0, 0)); |
454 |
jOptions.add(getCbLoadLayerInToc(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, |
455 |
GridBagConstraints.CENTER, GridBagConstraints.BOTH, |
456 |
new Insets(0, 0, 5, 5), 0, 0)); |
457 |
jOptions.setPreferredSize(new java.awt.Dimension(wPanel, 135)); |
458 |
} |
459 |
return jOptions;
|
460 |
} |
461 |
|
462 |
/**
|
463 |
* This method initializes jPNameFile
|
464 |
*
|
465 |
* @return javax.swing.JPanel
|
466 |
*/
|
467 |
private JPanel getJPNameFile() { |
468 |
if (jPNameFile == null) { |
469 |
jPNameFile = new JPanel(); |
470 |
jPNameFile.add(new JLabel(PluginServices.getText(this, "nombre_capas") + ":")); |
471 |
jPNameFile.add(getFilenameTextField()); |
472 |
} |
473 |
return jPNameFile;
|
474 |
} |
475 |
|
476 |
/**
|
477 |
* This method initializes filenameTextField
|
478 |
*
|
479 |
* @return javax.swing.JTextField
|
480 |
*/
|
481 |
public JTextField getFilenameTextField() { |
482 |
if (filenameTextField == null) { |
483 |
filenameTextField = new JTextField(); |
484 |
filenameTextField.setPreferredSize(new Dimension(150, filenameTextField.getPreferredSize().height)); |
485 |
} |
486 |
return filenameTextField;
|
487 |
} |
488 |
|
489 |
/**
|
490 |
* This method initializes jCheckSaveFile
|
491 |
*
|
492 |
* @return javax.swing.JCheckBox
|
493 |
*/
|
494 |
public JCheckBox getCbSaveFile() { |
495 |
if (jCheckSaveFile == null) { |
496 |
jCheckSaveFile = new JCheckBox(); |
497 |
jCheckSaveFile.setText(PluginServices.getText(this, "guardar_en_disco")); |
498 |
} |
499 |
return jCheckSaveFile;
|
500 |
} |
501 |
|
502 |
/**
|
503 |
* This method initializes jCheckBox
|
504 |
*
|
505 |
* @return javax.swing.JCheckBox
|
506 |
*/
|
507 |
public JCheckBox getCbOneLyrPerBand() { |
508 |
if (jCheckBox == null) { |
509 |
jCheckBox = new JCheckBox(); |
510 |
jCheckBox.setText(PluginServices.getText(this, "crear_1_capa_por_banda")); |
511 |
} |
512 |
return jCheckBox;
|
513 |
} |
514 |
|
515 |
/**
|
516 |
* This method initializes jCheckLoadLayerInToc
|
517 |
*
|
518 |
* @return javax.swing.JCheckBox
|
519 |
*/
|
520 |
public JCheckBox getCbLoadLayerInToc() { |
521 |
if (jCheckLoadLayerInToc == null) { |
522 |
jCheckLoadLayerInToc = new JCheckBox(); |
523 |
jCheckLoadLayerInToc.setText(PluginServices.getText(this, "cargar_en_toc")); |
524 |
} |
525 |
return jCheckLoadLayerInToc;
|
526 |
} |
527 |
|
528 |
/**
|
529 |
* Asigna el valor del campo "Ancho" a partir del double que lo representa
|
530 |
* y con el n?mero de decimales que se especifica en el par?metro dec
|
531 |
* @param width Ancho
|
532 |
* @param dec N?mero de decimales
|
533 |
*/
|
534 |
public void setWidthText(double width, int dec){ |
535 |
realWidth = width; |
536 |
getPResolution().setWidthText(width, dec); |
537 |
} |
538 |
|
539 |
/**
|
540 |
* Obtiene la relaci?n entre el ancho y alto de la imagen
|
541 |
* @return
|
542 |
*/
|
543 |
public double getRelWidthHeight(){ |
544 |
return relWidthHeight;
|
545 |
} |
546 |
|
547 |
/**
|
548 |
* Asigna el valor del campo "Alto" a partir del double que lo representa
|
549 |
* y con el n?mero de decimales que se especifica en el par?metro dec
|
550 |
* @param height Alto
|
551 |
* @param dec N?mero de decimales
|
552 |
*/
|
553 |
public void setHeightText(double height, int dec){ |
554 |
realHeight = height; |
555 |
getPResolution().setHeightText(height, dec); |
556 |
} |
557 |
|
558 |
/**
|
559 |
* Asigna el valor del campo "tama?o de celda" a partir del double que lo representa
|
560 |
* y con el n?mero de decimales que se especifica en el par?metro dec
|
561 |
* @param cellSize Tama?o de celda en double
|
562 |
* @param dec N?mero de decimales
|
563 |
*/
|
564 |
public void setCellSizeText(double cellSize, int dec){ |
565 |
getPResolution().setCellSizeText(cellSize, dec); |
566 |
} |
567 |
|
568 |
/**
|
569 |
* Asigna las coordenadas del mundo real a partir de n?meros en coma flotante.
|
570 |
* @param minx coordenada m?nima de X
|
571 |
* @param miny coordenada m?nima de Y
|
572 |
* @param maxx coordenada m?xima de X
|
573 |
* @param maxy coordenada m?xima de Y
|
574 |
* @param dec N?mero de decimales a mostrar en la caja de texto
|
575 |
*/
|
576 |
public void setCoorRealFromDouble(double minx, double miny, double maxx, double maxy, int dec){ |
577 |
wcMinX = minx; |
578 |
wcMinY = miny; |
579 |
wcMaxX = maxx; |
580 |
wcMaxY = maxy; |
581 |
setCoordReal(getCoord(minx, miny, maxx, maxy, dec)); |
582 |
} |
583 |
|
584 |
/**
|
585 |
* Obtiene un texto con las coordenadas a partir de n?meros en coma flotante.
|
586 |
* @param minx coordenada m?nima de X
|
587 |
* @param miny coordenada m?nima de Y
|
588 |
* @param maxx coordenada m?xima de X
|
589 |
* @param maxy coordenada m?xima de Y
|
590 |
* @param dec N?mero de decimales a mostrar en la caja de texto
|
591 |
*/
|
592 |
private String[] getCoord(double minx, double miny, double maxx, double maxy, int dec) { |
593 |
String[] coordPx = new String[4]; |
594 |
int indexPoint = String.valueOf(minx).indexOf('.'); |
595 |
try {
|
596 |
coordPx[0] = String.valueOf(minx).substring(0, indexPoint + dec); |
597 |
} catch (StringIndexOutOfBoundsException ex) { |
598 |
coordPx[0] = String.valueOf(minx); |
599 |
} |
600 |
indexPoint = String.valueOf(miny).indexOf('.'); |
601 |
try {
|
602 |
coordPx[1] = String.valueOf(miny).substring(0, indexPoint + dec); |
603 |
} catch (StringIndexOutOfBoundsException ex) { |
604 |
coordPx[1] = String.valueOf(miny); |
605 |
} |
606 |
indexPoint = String.valueOf(maxx).indexOf('.'); |
607 |
try {
|
608 |
coordPx[2] = String.valueOf(maxx).substring(0, indexPoint + dec); |
609 |
} catch (StringIndexOutOfBoundsException ex) { |
610 |
coordPx[2] = String.valueOf(maxx); |
611 |
} |
612 |
indexPoint = String.valueOf(maxy).indexOf('.'); |
613 |
try {
|
614 |
coordPx[3] = String.valueOf(maxy).substring(0, indexPoint + dec); |
615 |
} catch (StringIndexOutOfBoundsException ex) { |
616 |
coordPx[3] = String.valueOf(maxy); |
617 |
} |
618 |
return coordPx;
|
619 |
} |
620 |
|
621 |
/**
|
622 |
* Asigna los valores de las coordenadas reales.
|
623 |
* @param values
|
624 |
*/
|
625 |
private void setCoordReal(String[] values){ |
626 |
getCoor_reales().setValues(values); |
627 |
} |
628 |
|
629 |
/**
|
630 |
* Asigna las coordenadas pixel a partir de n?meros en coma flotante.
|
631 |
* @param minx coordenada m?nima de X
|
632 |
* @param miny coordenada m?nima de Y
|
633 |
* @param maxx coordenada m?xima de X
|
634 |
* @param maxy coordenada m?xima de Y
|
635 |
* @param dec N?mero de decimales a mostrar en la caja de texto
|
636 |
*/
|
637 |
public void setCoorPixelFromDouble(double minx, double miny, double maxx, double maxy, int dec){ |
638 |
pxMinX = minx; |
639 |
pxMinY = miny; |
640 |
pxMaxX = maxx; |
641 |
pxMaxY = maxy; |
642 |
setCoordPixel(getCoord(minx, miny, maxx, maxy, dec)); |
643 |
} |
644 |
|
645 |
/**
|
646 |
* Asigna los valores de las coordenadas p?xel.
|
647 |
* @return
|
648 |
*/
|
649 |
private void setCoordPixel(String[] values){ |
650 |
this.getCoor_pixel().setValues(values);
|
651 |
} |
652 |
|
653 |
/**
|
654 |
* Asigna la relaci?n entre el ancho y alto de la imagen
|
655 |
* @param rel
|
656 |
*/
|
657 |
public void setRelWidthHeight(double rel){ |
658 |
relWidthHeight = rel; |
659 |
} |
660 |
|
661 |
/**
|
662 |
* Obtiene la coordenada de m?xima X en pixel.
|
663 |
* @return Coordenada de m?xima X en pixel
|
664 |
*/
|
665 |
public double getPxMaxX() { |
666 |
return pxMaxX;
|
667 |
} |
668 |
|
669 |
/**
|
670 |
* Obtiene la coordenada de m?xima Y en pixel.
|
671 |
* @return Coordenada de m?xima Y en pixel
|
672 |
*/
|
673 |
public double getPxMaxY() { |
674 |
return pxMaxY;
|
675 |
} |
676 |
|
677 |
/**
|
678 |
* Obtiene la coordenada de m?nima X en pixel.
|
679 |
* @return Coordenada de m?nima X en pixel
|
680 |
*/
|
681 |
public double getPxMinX() { |
682 |
return pxMinX;
|
683 |
} |
684 |
|
685 |
/**
|
686 |
* Obtiene la coordenada de m?nima Y en pixel.
|
687 |
* @return Coordenada de m?nima Y en pixel
|
688 |
*/
|
689 |
public double getPxMinY() { |
690 |
return pxMinY;
|
691 |
} |
692 |
|
693 |
/**
|
694 |
* Obtiene la coordenada de m?xima X real.
|
695 |
* @return Coordenada de m?xima X real.
|
696 |
*/
|
697 |
public double getWcMaxX() { |
698 |
return wcMaxX;
|
699 |
} |
700 |
|
701 |
/**
|
702 |
* Obtiene la coordenada de m?xima Y real.
|
703 |
* @return Coordenada de m?xima Y real
|
704 |
*/
|
705 |
public double getWcMaxY() { |
706 |
return wcMaxY;
|
707 |
} |
708 |
|
709 |
/**
|
710 |
* Obtiene la coordenada de m?nima X real.
|
711 |
* @return Coordenada de m?nima X real
|
712 |
*/
|
713 |
public double getWcMinX() { |
714 |
return wcMinX;
|
715 |
} |
716 |
|
717 |
/**
|
718 |
* Obtiene la coordenada de m?nima Y real.
|
719 |
* @return Coordenada de m?nima Y real
|
720 |
*/
|
721 |
public double getWcMinY() { |
722 |
return wcMinY;
|
723 |
} |
724 |
|
725 |
/**
|
726 |
* Obtiene el <code>MapControl</code> de gvSIG
|
727 |
* @return <code>MapControl</code>
|
728 |
*/
|
729 |
public MapControl getMapControl() {
|
730 |
return mapControl;
|
731 |
} |
732 |
|
733 |
/**
|
734 |
* Obtiene la ultima herramienta seleccionada antes de cargar el recorte
|
735 |
* @return
|
736 |
*/
|
737 |
public String getLastTool() { |
738 |
return lastTool;
|
739 |
} |
740 |
|
741 |
/**
|
742 |
* Obtiene el nombre de la vista
|
743 |
* @return
|
744 |
*/
|
745 |
public String getViewName() { |
746 |
return viewName;
|
747 |
} |
748 |
|
749 |
/**
|
750 |
* Devuelve el valor del campo "tama?o de celda"
|
751 |
* @return
|
752 |
*/
|
753 |
public double getWidthText(){ |
754 |
return realWidth;
|
755 |
} |
756 |
|
757 |
/**
|
758 |
* Devuelve el valor del campo "tama?o de celda"
|
759 |
* @return
|
760 |
*/
|
761 |
public double getHeightText(){ |
762 |
return realHeight;
|
763 |
} |
764 |
} |