Revision 14083 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/cutting/ui/CuttingPanel.java

View differences:

CuttingPanel.java
20 20

  
21 21
import java.awt.BorderLayout;
22 22
import java.awt.Dimension;
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
25
import java.awt.Insets;
26
import java.awt.event.ActionEvent;
27
import java.awt.event.ActionListener;
28
import java.awt.event.ItemEvent;
29
import java.awt.event.ItemListener;
30
import java.io.File;
23 31
import java.util.ArrayList;
24 32

  
25
import javax.swing.BorderFactory;
33
import javax.swing.JButton;
34
import javax.swing.JCheckBox;
35
import javax.swing.JFileChooser;
36
import javax.swing.JLabel;
26 37
import javax.swing.JPanel;
27 38
import javax.swing.JTabbedPane;
39
import javax.swing.JTextField;
28 40

  
29 41
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
42
import org.gvsig.gui.beans.buttonbar.ButtonBarContainer;
30 43
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
44
import org.gvsig.gui.beans.coordinatespanel.CoordinatesPanel;
31 45
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
46
import org.gvsig.gui.beans.table.TableContainer;
47
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
48
import org.gvsig.raster.dataset.IRasterDataSource;
32 49
import org.gvsig.raster.hierarchy.IRasterGeoOperations;
33 50
import org.gvsig.raster.hierarchy.IRasterOperations;
34 51
import org.gvsig.raster.util.RasterToolsUtil;
35
import org.gvsig.rastertools.cutting.panels.CuttingCoordinatesPanel;
36
import org.gvsig.rastertools.cutting.panels.CuttingOptionsPanel;
37
import org.gvsig.rastertools.cutting.panels.CuttingResolutionPanel;
38
import org.gvsig.rastertools.cutting.panels.CuttingSelectionPanel;
52
import org.gvsig.rastertools.RasterModule;
39 53
import org.gvsig.rastertools.cutting.ui.listener.CuttingMouseViewListener;
40 54
import org.gvsig.rastertools.cutting.ui.listener.CuttingPanelListener;
41 55

  
42 56
import com.iver.andami.PluginServices;
57
import com.iver.andami.messages.NotificationManager;
43 58
import com.iver.andami.ui.mdiManager.IWindow;
59
import com.iver.cit.gvsig.addlayer.fileopen.FileOpenWizard;
44 60
import com.iver.cit.gvsig.fmap.MapControl;
45 61
import com.iver.cit.gvsig.fmap.layers.FLayer;
46 62
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior;
......
54 70
 * @version 17/04/2007
55 71
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
56 72
 */
57
public class CuttingPanel extends DefaultButtonsPanel {
73
public class CuttingPanel extends DefaultButtonsPanel implements ItemListener, ActionListener {
58 74
	private static final long serialVersionUID = 3078196473228467834L;
59 75

  
60
	private CuttingDialog           cuttingDialog        = null;
76
	private int                  wPanel               = 400;
61 77

  
62
	private JTabbedPane             jTabbedPane1         = null;
78
	private CuttingDialog        cuttingDialog        = null;
63 79

  
64
	private CuttingCoordinatesPanel coordinatesPanel     = null;
65
	private CuttingResolutionPanel  resolutionPanel      = null;
66
	private CuttingSelectionPanel   selectionPanel       = null;
67
	private CuttingOptionsPanel     optionsPanel         = null;
80
	private CoordinatesPanel     coordinatesPixel     = null;
81
	private CoordinatesPanel     coordinatesReales    = null;
82
	private ButtonBarContainer   buttonBarContainer   = null;
83
	private JPanel               pSelection           = null;
84
	private JPanel               jOptions             = null;
85
	private JPanel               jPNameFile           = null;
86
	private TableContainer       tSelection           = null;
87
	private ResolutionPanel      pResolution          = null;
88
	private JCheckBox            jCheckBox            = null;
89
	private JCheckBox            jCheckLoadLayerInToc = null;
90
	private JCheckBox            jCheckSaveFile       = null;
91
	private JTextField           filenameTextField    = null;
92
	private JTabbedPane          jTabbedPane1         = null;
93
	private JPanel               jPNameDirectory      = null;
94
	private JTextField           directoryTextField   = null;
95
	private JButton              jBChooseDirectory    = null;
96
	private JLabel               jLabelDirectory      = null;
68 97

  
69
	private FLayer                  fLayer               = null;
98
	private FLayer               fLayer               = null;
70 99

  
71 100
	/**
72
	 * Valores reales para el ancho, alto y tama?o de celda. Esto es necesario
73
	 * porque en la caja de texto se guardan con decimales recortados y cuando se
74
	 * pide el valor se devuelven completos.
75
	 */
76
	private double                  realWidth, realHeight;
101
   * Valores reales para el ancho, alto y tama?o de celda. Esto es necesario
102
   * porque en la caja de texto se guardan con decimales recortados y cuando se
103
   * pide el valor se devuelven completos.
104
   */
105
	private double               realWidth, realHeight;
77 106

  
78 107
	/**
79
	 * Relaci?n entre el ancho y alto en pixeles de la imagen
80
	 */
81
	private double                  relWidthHeight       = 0;
108
   * Relaci?n entre el ancho y alto en pixeles de la imagen
109
   */
110
	private double               relWidthHeight       = 0;
82 111

  
83 112
	/**
84
	 * Valores reales para el tama?o de la ventana. Esto es necesario porque en la
85
	 * caja de texto se guardan con decimales recortados y cuando se pide el valor
86
	 * se devuelven completos.
87
	 */
88
	private double                  wcUlx, wcUly, wcLrx, wcLry;
89
	private double                  pxMinX, pxMinY, pxMaxX, pxMaxY;
113
   * Valores reales para el tama?o de la ventana. Esto es necesario porque en la
114
   * caja de texto se guardan con decimales recortados y cuando se pide el valor
115
   * se devuelven completos.
116
   */
117
	private double               wcUlx, wcUly, wcLrx, wcLry;
118
	private double               pxMinX, pxMinY, pxMaxX, pxMaxY;
90 119

  
91
	private CuttingPanelListener    cuttingPanelListener = null;
120
	private CuttingPanelListener cuttingPanelListener = null;
92 121

  
93 122
	/**
94
	 * Herramienta seleccionada en el momento de la apertura del dialogo
95
	 */
96
	private String                  lastTool             = null;
97
	private MapControl              mapControl           = null;
98
	private String                  viewName             = null;
123
   * Herramienta seleccionada en el momento de la apertura del dialogo
124
   */
125
	private String               lastTool             = null;
126
	private MapControl           mapControl           = null;
127
	private String               viewName             = null;
99 128

  
100 129
	/**
101 130
	 * Crea un nuevo <code>CuttingPanel</code>
......
105 134
		super(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY);
106 135

  
107 136
		this.cuttingDialog = cuttingDialog;
108

  
109 137
		initialize();
138
		cuttingPanelListener = new CuttingPanelListener(this);
110 139

  
111
		getResolutionPanel().getCCellSize().addValueChangedListener(getCuttingPanelListener());
112
		getResolutionPanel().getCWidth().addValueChangedListener(getCuttingPanelListener());
113
		getResolutionPanel().getCHeight().addValueChangedListener(getCuttingPanelListener());
114
		getResolutionPanel().getButtonRestore().addActionListener(getCuttingPanelListener());
140
		getCoordinatesPixel().addValueChangedListener(cuttingPanelListener);
141
		getCoordinatesReales().addValueChangedListener(cuttingPanelListener);
115 142

  
116
		addButtonPressedListener(getCuttingPanelListener());
143
		getPResolution().getCCellSize().addValueChangedListener(cuttingPanelListener);
144
		getPResolution().getCWidth().addValueChangedListener(cuttingPanelListener);
145
		getPResolution().getCHeight().addValueChangedListener(cuttingPanelListener);
146

  
147
		getButtonBarContainer().getButton(0).addActionListener(cuttingPanelListener);
148
		getButtonBarContainer().getButton(1).addActionListener(cuttingPanelListener);
149

  
150
		this.addButtonPressedListener(cuttingPanelListener);
117 151
	}
118
	
119
	/**
120
	 * Crea en caso de no existir y devuelve la clase encargada de recoger los
121
	 * eventos
122
	 * @return
123
	 */
124
	private CuttingPanelListener getCuttingPanelListener() {
125
		if (cuttingPanelListener == null) {
126
			cuttingPanelListener = new CuttingPanelListener(this);
127
		}
128
		return cuttingPanelListener;
129
	}
130 152

  
131 153
	/**
132 154
	 * Obtener el <code>CuttingDialog</code> asociado a este objeto.
......
137 159
	}
138 160

  
139 161
	/**
162
	 * Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
163
	 * en cada llamada un nombre consecutivo.
164
	 */
165
	public void setNewLayerText() {
166
		filenameTextField.setText("NewLayer_" + RasterModule.layerCount);
167
	}
168

  
169
	/**
140 170
	 * Obtener la capa de un raster.
141 171
	 * @return
142 172
	 */
......
166 196
				new RectangleBehavior(cuttingMouseListener), new MouseMovementBehavior(sbl)
167 197
			}
168 198
		);
169
		
170
		getSelectionPanel().setLayer(fLayer);
171 199

  
200
		// Rellenar el arbol de bandas
201
		IRasterDataSource mDataset = ((FLyrRasterSE) fLayer).getDataSource();
202
		for (int i = 0; i < mDataset.getDatasetCount(); i++) {
203
			String fName = mDataset.getDataset(i)[0].getFName();
204
			String bandName = new File(fName).getName();
205

  
206
			if (mDataset.getDataset(i)[0].getBandCount() > 1) {
207
				for (int b = 0; b < mDataset.getDataset(i)[0].getBandCount(); b++) {
208
					Object row[] = { new Boolean(true),
209
							new String("B" + (b + 1) + " - " + bandName) };
210
					try {
211
						getTSelection().addRow(row);
212
					} catch (NotInitializeException e) {
213
						NotificationManager.addError("Error a?adiendo fila a la tabla.", e);
214
					}
215
				}
216
			} else {
217
				Object row[] = { new Boolean(true), new String("B - " + bandName) };
218
				try {
219
					getTSelection().addRow(row);
220
				} catch (NotInitializeException e) {
221
					NotificationManager.addError("Error a?adiendo fila a la tabla.", e);
222
				}
223
			}
224
		}
225

  
172 226
		// Obtener la extension completa de la capa
173 227

  
174 228
		if(fLayer instanceof IRasterGeoOperations && fLayer instanceof IRasterOperations) {
175
			getCuttingPanelListener().setAffineTransform(((IRasterGeoOperations)fLayer).getAffineTransform());
176
			getCuttingPanelListener().setDimension(new Dimension((int)((IRasterOperations)fLayer).getPxWidth(), (int)((IRasterOperations)fLayer).getPxHeight()));
229
			cuttingPanelListener.setAffineTransform(((IRasterGeoOperations)fLayer).getAffineTransform());
230
			cuttingPanelListener.setDimension(new Dimension((int)((IRasterOperations)fLayer).getPxWidth(), (int)((IRasterOperations)fLayer).getPxHeight()));
177 231
		} else {
178 232
			RasterToolsUtil.messageBoxError("Error obteniendo el extent.", this);
179 233
			return;
......
184 238
		for (int i = 0; i < attr.size(); i++) {
185 239
			Object[] a = (Object[]) attr.get(i);
186 240
			if (a[0].toString().equals("Width"))
187
				getCuttingPanelListener().setWidthPx(((Integer) a[1]).intValue());
241
				cuttingPanelListener.setWidthPx(((Integer) a[1]).intValue());
188 242
			if (a[0].toString().equals("Height"))
189
				getCuttingPanelListener().setHeightPx(((Integer) a[1]).intValue());
243
				cuttingPanelListener.setHeightPx(((Integer) a[1]).intValue());
190 244
		}
191 245
	}
192 246

  
......
230 284
	 * This method initializes this
231 285
	 */
232 286
	private void initialize() {
233
		JPanel jPanel = null;
234 287
		jTabbedPane1 = new JTabbedPane();
235
		
236
		jTabbedPane1.addTab(PluginServices.getText(this, "coordenadas_recorte"), getCoordinatesPanel());
237 288

  
238
		jPanel = new JPanel();
239
		jPanel.setLayout(new BorderLayout());
240
		jPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
241
		jPanel.add(getResolutionPanel());
242
		jTabbedPane1.addTab(PluginServices.getText(this, "resolucion_espacial"), jPanel);
289
		JPanel jpanel1 = new JPanel();
290
		jpanel1.setLayout(new GridBagLayout());
243 291

  
244
		jTabbedPane1.addTab(PluginServices.getText(this, "seleccion_bandas"), getSelectionPanel());
292
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
293
		gridBagConstraints.gridx = 0;
294
		gridBagConstraints.gridy = 0;
295
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
296
		gridBagConstraints.weightx = 1.0;
297
		gridBagConstraints.insets = new java.awt.Insets(5, 5, 2, 5);
298
		jpanel1.add(getCoordinatesPixel(), gridBagConstraints);
245 299

  
246
		jPanel = new JPanel();
247
		jPanel.setLayout(new BorderLayout());
248
		jPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
249
		jPanel.add(getOptionsPanel());
250
		jTabbedPane1.addTab(PluginServices.getText(this, "otras_opciones"), jPanel);
300
		gridBagConstraints = new GridBagConstraints();
301
		gridBagConstraints.gridx = 0;
302
		gridBagConstraints.gridy = 1;
303
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
304
		gridBagConstraints.weightx = 1.0;
305
		gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5);
306
		jpanel1.add(getCoordinatesReales(), gridBagConstraints);
251 307

  
308
		gridBagConstraints = new GridBagConstraints();
309
		gridBagConstraints.gridx = 0;
310
		gridBagConstraints.gridy = 2;
311
		gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
312
		gridBagConstraints.insets = new java.awt.Insets(2, 5, 5, 5);
313
		jpanel1.add(getButtonBarContainer(), gridBagConstraints);
314

  
315
		jTabbedPane1.addTab(PluginServices.getText(this, "coordenadas_recorte"), jpanel1);
316
		jTabbedPane1.addTab(PluginServices.getText(this, "resolucion_espacial"), getPResolution());
317
		jTabbedPane1.addTab(PluginServices.getText(this, "seleccion_bandas"), getPSelection());
318
		jTabbedPane1.addTab(PluginServices.getText(this, "otras_opciones"), getJOptions());
319

  
252 320
		setLayout(new BorderLayout());
253 321
		add(jTabbedPane1, BorderLayout.CENTER);
322

  
323
		setNewLayerText();
254 324
	}
255 325

  
256
	public CuttingCoordinatesPanel getCoordinatesPanel() {
257
		if (coordinatesPanel == null) {
258
			coordinatesPanel = new CuttingCoordinatesPanel(getCuttingPanelListener());
326
	/**
327
	 * This method initializes jPanel
328
	 *
329
	 * @return javax.swing.JPanel
330
	 */
331
	public CoordinatesPanel getCoordinatesPixel() {
332
		if (coordinatesPixel == null) {
333
			coordinatesPixel = new CoordinatesPanel();
334
			coordinatesPixel.setParameters(	PluginServices.getText(this, "coordenadas_pixel"),
335
										PluginServices.getText(this, "sup_izq"),
336
										"X" ,"Y",
337
										PluginServices.getText(this, "inf_der"),
338
										"X", "Y");
259 339
		}
260
		return coordinatesPanel;
340
		return coordinatesPixel;
261 341
	}
262
	
342

  
263 343
	/**
344
	 * This method initializes jPanel1
345
	 *
346
	 * @return javax.swing.JPanel
347
	 */
348
	public CoordinatesPanel getCoordinatesReales() {
349
		if (coordinatesReales == null) {
350
			coordinatesReales = new CoordinatesPanel();
351
			coordinatesReales.setParameters(	PluginServices.getText(this, "coordenadas_reales"),
352
										PluginServices.getText(this, "sup_izq"),
353
										"X" ,"Y",
354
										PluginServices.getText(this, "inf_der"),
355
										"X", "Y");
356
		}
357
		return coordinatesReales;
358
	}
359

  
360
	/**
361
	 * This method initializes jButton
362
	 *
363
	 * @return javax.swing.JButton
364
	 */
365
	public ButtonBarContainer getButtonBarContainer() {
366
		if (buttonBarContainer == null) {
367
			buttonBarContainer = new ButtonBarContainer();
368
			buttonBarContainer.setPreferredSize(new java.awt.Dimension(wPanel - 4, 32));
369
			buttonBarContainer.addButton("fullExtent.png", PluginServices.getText(this, "fullExtent"), 0);
370
			buttonBarContainer.addButton("selectTool.png", PluginServices.getText(this, "select_tool"), 1);
371
			buttonBarContainer.setButtonAlignment("right");
372
			buttonBarContainer.setComponentBorder(false);
373
		}
374
		return buttonBarContainer;
375
	}
376

  
377
	/**
264 378
	 * This method initializes jPanel
265 379
	 *
266 380
	 * @return javax.swing.JPanel
267 381
	 */
268
	public CuttingResolutionPanel getResolutionPanel() {
269
		if (resolutionPanel == null) {
270
			resolutionPanel = new CuttingResolutionPanel();
271
			resolutionPanel.validate();
382
	public ResolutionPanel getPResolution() {
383
		if (pResolution == null) {
384
			pResolution = new ResolutionPanel();
385
			pResolution.setPreferredSize(new java.awt.Dimension(wPanel, 120));
386
			pResolution.validate();
272 387
		}
273
		return resolutionPanel;
388
		return pResolution;
274 389
	}
275 390

  
276 391
	/**
......
278 393
	 *
279 394
	 * @return javax.swing.JPanel
280 395
	 */
281
	public CuttingSelectionPanel getSelectionPanel() {
282
		if (selectionPanel == null) {
283
			selectionPanel = new CuttingSelectionPanel();
396
	private JPanel getPSelection() {
397
		if (pSelection == null) {
398
			pSelection = new JPanel();
399
			pSelection.setLayout(new BorderLayout());
400
			pSelection.setPreferredSize(new java.awt.Dimension(wPanel, 120));
401
			pSelection.add(getTSelection(), BorderLayout.CENTER);
402

  
284 403
		}
285
		return selectionPanel;
404
		return pSelection;
286 405
	}
287 406

  
288 407
	/**
408
	 * Obtiene la tabla de selecci?n de bandas
409
	 * @return Tabla de selecci?n de bandas
410
	 */
411
	public TableContainer getTSelection() {
412
		if (tSelection == null) {
413
			String[] columnNames = {PluginServices.getText(this, "bandas"), PluginServices.getText(this, "nombre")};
414
			int[] columnWidths = {75, 305};
415
			tSelection = new TableContainer(columnNames, columnWidths);
416
			tSelection.setModel("CheckBoxModel");
417
			tSelection.setControlVisible(false);
418
			tSelection.initialize();
419
		}
420

  
421
		return tSelection;
422
	}
423

  
424
	/**
289 425
	 * This method initializes jOptions
290 426
	 *
291 427
	 * @return javax.swing.JPanel
292 428
	 */
293
	public CuttingOptionsPanel getOptionsPanel() {
294
		if (optionsPanel == null) {
295
			optionsPanel = new CuttingOptionsPanel();
429
	private JPanel getJOptions() {
430
		if (jOptions == null) {
431
			jOptions = new JPanel();
432
			jOptions.setLayout(new GridBagLayout());
433
			jOptions.add(getJPNameFile(), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
434
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
435
					new Insets(0, 0, 5, 5), 0, 0));
436
			jOptions.add(getCbOneLyrPerBand(), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
437
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
438
					new Insets(0, 0, 5, 5), 0, 0));
439
			jOptions.add(getCbLoadLayerInToc(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
440
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
441
					new Insets(0, 0, 5, 5), 0, 0));
442
			jOptions.add(getCbSaveFile(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0,
443
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
444
					new Insets(0, 0, 5, 5), 0, 0));
445
			jOptions.add(getJPNameDirectory(), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0,
446
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
447
					new Insets(0, 0, 5, 5), 0, 0));
448
			jOptions.setPreferredSize(new java.awt.Dimension(wPanel, 135));
296 449
		}
297
		return optionsPanel;
450
		return jOptions;
298 451
	}
299 452

  
300 453
	/**
454
	 * This method initializes jPNameFile
455
	 *
456
	 * @return javax.swing.JPanel
457
	 */
458
	private JPanel getJPNameFile() {
459
		if (jPNameFile == null) {
460
			jPNameFile = new JPanel();
461
			jPNameFile.add(new JLabel(PluginServices.getText(this, "nombre_capas") + ":"));
462
			jPNameFile.add(getFilenameTextField());
463
		}
464
		return jPNameFile;
465
	}
466

  
467
	private JButton getJBChooseDirectory() {
468
		if (jBChooseDirectory == null) {
469
			jBChooseDirectory = new JButton(PluginServices.getText(this, "cambiar_ruta"));
470
			jBChooseDirectory.setEnabled(false);
471
		}
472
		return jBChooseDirectory;
473
	}
474
	/**
475
	 * This method initializes jPNameFile
476
	 *
477
	 * @return javax.swing.JPanel
478
	 */
479
	private JPanel getJPNameDirectory() {
480
		if (jPNameDirectory == null) {
481
			jPNameDirectory = new JPanel();
482
			jPNameDirectory.add(getJLabelDirectory());
483
			jPNameDirectory.add(getDirectoryTextField());
484
			jPNameDirectory.add(getJBChooseDirectory());
485
			getJBChooseDirectory().addActionListener(this);
486
		}
487
		return jPNameDirectory;
488
	}
489

  
490
	private JLabel getJLabelDirectory() {
491
		if (jLabelDirectory == null) {
492
			jLabelDirectory = new JLabel(PluginServices.getText(this, "ruta") + ":");
493
			jLabelDirectory.setEnabled(false);
494
		}
495
		return jLabelDirectory;
496
	}
497

  
498
	/**
499
	 * This method initializes filenameTextField
500
	 *
501
	 * @return javax.swing.JTextField
502
	 */
503
	public JTextField getFilenameTextField() {
504
		if (filenameTextField == null) {
505
			filenameTextField = new JTextField();
506
			filenameTextField.setPreferredSize(new Dimension(150, filenameTextField.getPreferredSize().height));
507
		}
508
		return filenameTextField;
509
	}
510

  
511
	/**
512
	 * This method initializes filenameTextField
513
	 *
514
	 * @return javax.swing.JTextField
515
	 */
516
	public JTextField getDirectoryTextField() {
517
		if (directoryTextField == null) {
518
			directoryTextField = new JTextField();
519
			directoryTextField.setText(FileOpenWizard.getLastPath());
520
			directoryTextField.setEditable(false);
521
			directoryTextField.setEnabled(false);
522
			directoryTextField.setPreferredSize(new Dimension(200, directoryTextField.getPreferredSize().height));
523
		}
524
		return directoryTextField;
525
	}
526

  
527
	/**
528
	 * This method initializes jCheckSaveFile
529
	 *
530
	 * @return javax.swing.JCheckBox
531
	 */
532
	public JCheckBox getCbSaveFile() {
533
		if (jCheckSaveFile == null) {
534
			jCheckSaveFile = new JCheckBox();
535
			jCheckSaveFile.setText(PluginServices.getText(this, "guardar_en_disco"));
536
			jCheckSaveFile.addItemListener(this);
537
		}
538
		return jCheckSaveFile;
539
	}
540

  
541
	/**
542
	 * This method initializes jCheckBox
543
	 *
544
	 * @return javax.swing.JCheckBox
545
	 */
546
	public JCheckBox getCbOneLyrPerBand() {
547
		if (jCheckBox == null) {
548
			jCheckBox = new JCheckBox();
549
			jCheckBox.setText(PluginServices.getText(this, "crear_1_capa_por_banda"));
550
		}
551
		return jCheckBox;
552
	}
553

  
554
	/**
555
	 * This method initializes jCheckLoadLayerInToc
556
	 *
557
	 * @return javax.swing.JCheckBox
558
	 */
559
	public JCheckBox getCbLoadLayerInToc() {
560
		if (jCheckLoadLayerInToc == null) {
561
			jCheckLoadLayerInToc = new JCheckBox();
562
			jCheckLoadLayerInToc.setText(PluginServices.getText(this, "cargar_en_toc"));
563
			jCheckLoadLayerInToc.setSelected(true);
564
			jCheckLoadLayerInToc.setEnabled(false);
565
			jCheckLoadLayerInToc.addItemListener(this);
566
		}
567
		return jCheckLoadLayerInToc;
568
	}
569

  
570
	/**
301 571
	 * Asigna el valor del campo "Ancho" a partir del double que lo representa
302 572
	 * y con el n?mero de decimales que se especifica en el par?metro dec
303 573
	 * @param width Ancho
......
305 575
	 */
306 576
	public void setWidthText(double width, int dec) {
307 577
		realWidth = width;
308
		getResolutionPanel().setWidthText(width, dec);
578
		getPResolution().setWidthText(width, dec);
309 579
	}
310 580

  
311 581
	/**
......
324 594
	 */
325 595
	public void setHeightText(double height, int dec) {
326 596
		realHeight = height;
327
		getResolutionPanel().setHeightText(height, dec);
597
		getPResolution().setHeightText(height, dec);
328 598
	}
329 599

  
330 600
	/**
......
334 604
	 * @param dec N?mero de decimales
335 605
	 */
336 606
	public void setCellSizeText(double cellSize, int dec) {
337
		getResolutionPanel().setCellSizeText(cellSize, dec);
607
		getPResolution().setCellSizeText(cellSize, dec);
338 608
	}
339 609

  
340 610
	/**
......
350 620
		wcUly = uly;
351 621
		wcLrx = lrx;
352 622
		wcLry = lry;
353
 		getCoordinatesPanel().setCoordReal(getCoord(ulx, uly, lrx, lry, dec));
623
 		setCoordReal(getCoord(ulx, uly, lrx, lry, dec));
354 624
	}
355 625

  
356 626
	/**
......
391 661
	}
392 662

  
393 663
	/**
664
	 * Asigna los valores de las coordenadas reales.
665
	 * @param values
666
	 */
667
	private void setCoordReal(String[] values) {
668
		getCoordinatesReales().setValues(values);
669
	}
670

  
671
	/**
394 672
	 * Asigna las coordenadas pixel a partir de n?meros en coma flotante.
395 673
	 * @param minx coordenada m?nima de X
396 674
	 * @param miny coordenada m?nima de Y
......
403 681
		pxMinY = miny;
404 682
		pxMaxX = maxx;
405 683
		pxMaxY = maxy;
406
		getCoordinatesPanel().setCoordPixel(getCoord(minx, miny, maxx, maxy, dec));
684
		setCoordPixel(getCoord(minx, miny, maxx, maxy, dec));
407 685
	}
408 686

  
409 687
	/**
688
	 * Asigna los valores de las coordenadas p?xel.
689
	 * @return
690
	 */
691
	private void setCoordPixel(String[] values) {
692
		getCoordinatesPixel().setValues(values);
693
	}
694

  
695
	/**
410 696
	 * Asigna la relaci?n entre el ancho y alto de la imagen de salida
411 697
	 * @param rel
412 698
	 */
......
517 803
	public double getHeightText() {
518 804
		return realHeight;
519 805
	}
520
	
521
	
522
	double textWidth, textHeight, cellSize;
523
	public void saveStatusText() {
524
		textWidth = getWidthText();
525
		textHeight = getHeightText();
526
		cellSize = getResolutionPanel().getCellSizeText();
806

  
807
	/**
808
	 * Cada vez que cambia un checkbox de cargar en toc o guardar en fichero, nos
809
	 * aseguramos de que no pueden estar las dos opciones desmarcadas
810
	 */
811
	public void itemStateChanged(ItemEvent e) {
812
		getCbLoadLayerInToc().setEnabled(true);
813
		getCbSaveFile().setEnabled(true);
814
		if (getCbLoadLayerInToc().isSelected() && !getCbSaveFile().isSelected())
815
			getCbLoadLayerInToc().setEnabled(false);
816
		if (!getCbLoadLayerInToc().isSelected() && getCbSaveFile().isSelected())
817
			getCbSaveFile().setEnabled(false);
818

  
819
		getJBChooseDirectory().setEnabled(getCbSaveFile().isSelected());
820
		getDirectoryTextField().setEnabled(getCbSaveFile().isSelected());
821
		getJLabelDirectory().setEnabled(getCbSaveFile().isSelected());
527 822
	}
528
	
529
	public void restoreStatusText() {
530
    setWidthText(textWidth, 0);
531
    setHeightText(textHeight, 0);
532
		getResolutionPanel().setCellSizeText(cellSize, 4);
823

  
824
	/**
825
	 * Accion que sucede cuando se pulsa el boton de cambiar directorio
826
	 */
827
	public void actionPerformed(ActionEvent e) {
828

  
829
		JFileChooser chooser = new JFileChooser(FileOpenWizard.getLastPath());
830
		chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
831
		chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_directorio"));
832

  
833
		if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)
834
			return;
835
		String path = chooser.getSelectedFile().toString();
836
		FileOpenWizard.setLastPath(path);
837
		getDirectoryTextField().setText(path);
533 838
	}
534 839
}

Also available in: Unified diff