Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libCq_CMS_praster / src / org / cresques / ui / raster / CutRasterPanel.java @ 12822

History | View | Annotate | Download (22 KB)

1
/*
2
 * Created on 22-ago-2006
3
 *
4
 */
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 */
23
package org.cresques.ui.raster;
24

    
25
import java.awt.BorderLayout;
26
import java.awt.FlowLayout;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.geom.Rectangle2D;
30

    
31
import javax.swing.ImageIcon;
32
import javax.swing.JButton;
33
import javax.swing.JCheckBox;
34
import javax.swing.JLabel;
35
import javax.swing.JPanel;
36

    
37
import org.cresques.io.data.ICutRaster;
38
import org.cresques.ui.raster.listener.CutRasterListener;
39
import org.gvsig.gui.beans.buttonBar.ButtonBarContainer;
40
import org.gvsig.gui.beans.coordDataInput.CoordDataInputContainer;
41
import org.gvsig.gui.beans.table.TableContainer;
42
import org.gvsig.i18n.Messages;
43
import java.awt.Dimension;
44

    
45
public class CutRasterPanel extends BaseComponent{
46

    
47
        private int                                                wPanel = 420, hPanel = 534;
48
        private int                                                wComp = wPanel - 6, hComp = hPanel - 40;
49
        private int                                                wTable = wComp - 10;
50
        private int                                                hTable = hComp - 370 ;
51

    
52
        private JPanel                                         pTailImage = null;
53
        private CoordDataInputContainer pCoordPixel = null;
54
        private CoordDataInputContainer pCoordReal = null;
55
        private ButtonBarContainer                 pResize = null;
56
        private JButton                                 jButton = null;
57

    
58
        private ResolutionPanel                 pResolution = null;
59

    
60
        private JPanel                                         pSelection = null;
61
        private TableContainer                         tSelection = null;
62
        private String[]                                 columnNames = {Messages.getText("bandas"), Messages.getText("nombre")};
63
        private int[]                                         columnWidths = {75, 305};
64
        private boolean                                 contract = true;
65

    
66
        private JPanel                                         pCheck = null;
67
        private JCheckBox                                 jCheckBox = null;
68
        private JLabel                                         jLabel = null;
69
        private JPanel                                         pButtons = null;
70
        private JPanel                                         pAccept = null;
71
        private JButton                                 bSave = null;
72
        private JButton                                 bAccept = null;
73
        private JButton                                 bCancel = null;
74
        private JPanel                                         pBorder = null;
75
        private CutRasterListener                 tailImageListener = null;
76
        /**
77
         * Valores reales para el ancho, alto y tama?o de celda. Esto es necesario porque
78
         * en la caja de texto se guardan con decimales recortados y cuando se pide el valor
79
         * se devuelven completos.
80
         */
81
        private double                                         realWidth, realHeight, realCellSize;
82
        /**
83
         * Relaci?n entre el ancho y alto en pixeles de la imagen
84
         */
85
        private double                                        relWidthHeight = 0;
86
        /**
87
         * Clase que instancia a esta y que implemente ITailRaster.
88
         */
89
        private ICutRaster                                parent = null;
90

    
91
        /**
92
         * Extensi?n de la capa.
93
         */
94
        private Rectangle2D                         extent = null;
95

    
96
        private int                                         widthPx = 0;
97
        private int                                         heightPx = 0;
98

    
99

    
100
        /**
101
         * Valores reales para el tama?o de la ventana. Esto es necesario porque
102
         * en la caja de texto se guardan con decimales recortados y cuando se pide el valor
103
         * se devuelven completos.
104
         */
105
        private double                                        wcMinX, wcMinY, wcMaxX, wcMaxY;
106
        private double                                        pxMinX, pxMinY, pxMaxX, pxMaxY;
107

    
108

    
109

    
110
        /**
111
         * This is the default constructor
112
         */
113
        public CutRasterPanel(Rectangle2D extent, int widthPx, int heightPx, ICutRaster parent) {
114
                super();
115
                this.parent = parent;
116
                this.extent = extent;
117
                this.widthPx = widthPx;
118
                this.heightPx = heightPx;
119
                initialize();
120
                tailImageListener = new CutRasterListener(this, extent, widthPx, heightPx, parent);
121
                this.selectLayerFullExtend();
122
        }
123

    
124
        /**
125
         * This method initializes this
126
         *
127
         * @return void
128
         */
129
        private void initialize() {
130
                FlowLayout flowLayout = new FlowLayout();
131
                flowLayout.setHgap(0);
132
                flowLayout.setVgap(0);
133
                this.setLayout(flowLayout);
134
                this.add(getPTailImage(), null);
135
                this.setSize(wPanel, hPanel);
136
                if(contract){
137
                        this.getPResolution().setVisible(false);
138
                        this.getPSelection().setVisible(false);
139
                        this.getPCheck().setVisible(false);
140
                        this.setSize(wPanel, hPanel - hTable - 120 - 30);
141
                        this.getPTailImage().setPreferredSize(new java.awt.Dimension(wPanel, hPanel - hTable - 120 - 30));
142
                        this.getPBorder().setSize(wComp, hComp - hTable - 120 - 30);
143
                        this.getPBorder().setPreferredSize(new java.awt.Dimension(wComp, hComp - hTable - 120 - 30));
144
                }
145
        }
146

    
147
        /**
148
         * This method initializes jPanel
149
         *
150
         * @return javax.swing.JPanel
151
         */
152
        private JPanel getPTailImage() {
153
                if (pTailImage == null) {
154
                        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
155
                        gridBagConstraints5.gridx = 0;
156
                        gridBagConstraints5.gridy = 0;
157
                        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
158
                        gridBagConstraints8.gridx = 0;
159
                        gridBagConstraints8.gridy = 6;
160
                        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
161
                        gridBagConstraints7.gridx = 0;
162
                        gridBagConstraints7.gridy = 6;
163
                        pTailImage = new JPanel();
164
                        pTailImage.setLayout(new GridBagLayout());
165
                        pTailImage.setPreferredSize(new java.awt.Dimension(wPanel,hPanel));
166
                        pTailImage.add(getPButtons(), gridBagConstraints8);
167
                        pTailImage.add(getPBorder(), gridBagConstraints5);
168
                }
169
                return pTailImage;
170
        }
171

    
172
        /**
173
         * This method initializes jPanel
174
         *
175
         * @return javax.swing.JPanel
176
         */
177
        public CoordDataInputContainer getPCoordPixel() {
178
                if (pCoordPixel == null) {
179
                        pCoordPixel = new CoordDataInputContainer(wTable, 90);
180
                        pCoordPixel.setParameters(Messages.getText("coordenadas_pixel"),
181
                                                                                Messages.getText("sup_izq"),
182
                                                                                "X" ,"Y",
183
                                                                                Messages.getText("inf_der"),
184
                                                                                "X", "Y");
185
                        pCoordPixel.setDecimalValues(true);
186
                }
187
                return pCoordPixel;
188
        }
189

    
190
        /**
191
         * This method initializes jPanel1
192
         *
193
         * @return javax.swing.JPanel
194
         */
195
        public CoordDataInputContainer getPCoordReal() {
196
                if (pCoordReal == null) {
197
                        pCoordReal = new CoordDataInputContainer(wTable, 90);
198
                        pCoordReal.setParameters(Messages.getText("coordenadas_reales"),
199
                                                                                Messages.getText("sup_izq"),
200
                                                                                "X" ,"Y",
201
                                                                                Messages.getText("inf_der"),
202
                                                                                "X", "Y");
203
                        pCoordReal.setDecimalValues(true);
204
                }
205
                return pCoordReal;
206
        }
207

    
208
        /**
209
         * This method initializes jPanel
210
         *
211
         * @return javax.swing.JPanel
212
         */
213
        public ButtonBarContainer getPResize() {
214
                if (pResize == null) {
215
                        pResize = new ButtonBarContainer();
216
                        pResize.setPreferredSize(new java.awt.Dimension(wTable - 4, 32));
217
                        pResize.addButton("fullExtent.png", Messages.getText("fullExtent"), 0);
218
                        pResize.addButton("selectTool.png", Messages.getText("select_tool"), 1);
219
                        pResize.addButton("down.png", Messages.getText("expandir"), 2);
220
                        pResize.setButtonAlignment("right");
221
                        pResize.setComponentBorder(true);
222

    
223
                }
224
                return pResize;
225
        }
226

    
227

    
228
        /**
229
         * This method initializes jPanel
230
         *
231
         * @return javax.swing.JPanel
232
         */
233
        public ResolutionPanel getPResolution() {
234
                if (pResolution == null) {
235
                        pResolution = new ResolutionPanel();
236
                        pResolution.setPreferredSize(new java.awt.Dimension(wTable,120));
237
                        pResolution.setComponentSize(wTable,120);
238
                }
239
                return pResolution;
240
        }
241

    
242
        /**
243
         * This method initializes jPanel1
244
         *
245
         * @return javax.swing.JPanel
246
         */
247
        private JPanel getPSelection() {
248
                if (pSelection == null) {
249
                        pSelection = new JPanel();
250
                        pSelection.setLayout(new FlowLayout());
251
                        pSelection.setPreferredSize(new java.awt.Dimension(wTable,hTable));
252
                        pSelection.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Messages.getText("seleccion_bandas"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10), null));
253
                        pSelection.add(getTSelection(), null);
254

    
255
                }
256
                return pSelection;
257
        }
258

    
259
        /**
260
         * Obtiene la tabla de selecci?n de bandas
261
         * @return Tabla de selecci?n de bandas
262
         */
263
        public TableContainer getTSelection(){
264
                if (tSelection == null) {
265
                        tSelection = new TableContainer(wTable - 20, hTable - 40, columnNames, columnWidths);
266
                        tSelection.setModel("CheckBoxModel");
267
                        tSelection.setControlVisible(false);
268
                        tSelection.initialize();
269
                }
270

    
271
                return tSelection;
272
        }
273

    
274
        /**
275
         * This method initializes jPanel
276
         *
277
         * @return javax.swing.JPanel
278
         */
279
        private JPanel getPButtons() {
280
                if (pButtons == null) {
281
                        pButtons = new JPanel();
282
                        pButtons.setLayout(new BorderLayout());
283
                        pButtons.setPreferredSize(new java.awt.Dimension(wTable,30));
284
                        pButtons.add(getPAccept(), java.awt.BorderLayout.EAST);
285
                }
286
                return pButtons;
287
        }
288

    
289
        /**
290
         * This method initializes jPanel
291
         *
292
         * @return javax.swing.JPanel
293
         */
294
        private JPanel getPAccept() {
295
                if (pAccept == null) {
296
                        FlowLayout flowLayout1 = new FlowLayout();
297
                        flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
298
                        flowLayout1.setVgap(5);
299
                        flowLayout1.setHgap(2);
300
                        pAccept = new JPanel();
301
                        pAccept.setLayout(flowLayout1);
302
                        pAccept.setPreferredSize(new java.awt.Dimension(350,30));
303
                        pAccept.add(getBSave(), null);
304
                        pAccept.add(getBAccept(), null);
305
                        pAccept.add(getBCancel(), null);
306
                }
307
                return pAccept;
308
        }
309

    
310
        /**
311
         * This method initializes getBAccept
312
         *
313
         * @return javax.swing.JButton
314
         */
315
        public JButton getBSave() {
316
                if (bSave == null) {
317
                        bSave = new JButton();
318
                        bSave.setPreferredSize(new java.awt.Dimension(85,25));
319
                        bSave.setText(Messages.getText("salvar"));
320
                        bSave.setEnabled(false);
321
                }
322
                return bSave;
323
        }
324

    
325
        /**
326
         * This method initializes getBAccept
327
         *
328
         * @return javax.swing.JButton
329
         */
330
        public JButton getBAccept() {
331
                if (bAccept == null) {
332
                        bAccept = new JButton();
333
                        bAccept.setPreferredSize(new java.awt.Dimension(85,25));
334
                        bAccept.setText(Messages.getText("aplicar"));
335
                }
336
                return bAccept;
337
        }
338

    
339
        /**
340
         * This method initializes getBCancel
341
         *
342
         * @return javax.swing.JButton
343
         */
344
        public JButton getBCancel() {
345
                if (bCancel == null) {
346
                        bCancel = new JButton();
347
                        bCancel.setPreferredSize(new java.awt.Dimension(85,25));
348
                        bCancel.setText(Messages.getText("cerrar"));
349
                }
350
                return bCancel;
351
        }
352

    
353
        /**
354
         * This method initializes jPanel
355
         *
356
         * @return javax.swing.JPanel
357
         */
358
        private JPanel getPBorder() {
359
                if (pBorder == null) {
360
                        GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
361
                        gridBagConstraints31.gridx = 0;
362
                        gridBagConstraints31.gridy = 5;
363
                        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
364
                        gridBagConstraints3.gridx = 0;
365
                        gridBagConstraints3.gridy = 4;
366
                        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
367
                        gridBagConstraints2.gridx = 0;
368
                        gridBagConstraints2.gridy = 3;
369
                        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
370
                        gridBagConstraints4.gridx = 0;
371
                        gridBagConstraints4.gridy = 2;
372
                        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
373
                        gridBagConstraints1.gridx = 0;
374
                        gridBagConstraints1.gridy = 1;
375
                        GridBagConstraints gridBagConstraints = new GridBagConstraints();
376
                        gridBagConstraints.gridx = 0;
377
                        gridBagConstraints.gridy = 0;
378
                        pBorder = new JPanel();
379
                        pBorder.setLayout(new GridBagLayout());
380
                        pBorder.setPreferredSize(new java.awt.Dimension(wComp,hComp));
381
                        pBorder.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
382
                        pBorder.add(getPCoordPixel(), gridBagConstraints);
383
                        pBorder.add(getPCoordReal(), gridBagConstraints1);
384
                        pBorder.add(getPResize(), gridBagConstraints4);
385
                        pBorder.add(getPResolution(), gridBagConstraints2);
386
                        pBorder.add(getPSelection(), gridBagConstraints3);
387
                        pBorder.add(getPCheck(), gridBagConstraints31);
388
                }
389
                return pBorder;
390
        }
391

    
392
        /**
393
         * This method initializes jPanel
394
         *
395
         * @return javax.swing.JPanel
396
         */
397
        private JPanel getPCheck() {
398
                if (pCheck == null) {
399
                        jLabel = new JLabel();
400
                        jLabel.setText(Messages.getText("crear_1_capa_por_banda"));
401
                        pCheck = new JPanel();
402
                        pCheck.setLayout(new BorderLayout());
403
                        pCheck.setPreferredSize(new Dimension(410 - 10, 30));
404
                        pCheck.add(getCbOneLyrPerBand(), java.awt.BorderLayout.WEST);
405
                        pCheck.add(jLabel, java.awt.BorderLayout.CENTER);
406
                }
407
                return pCheck;
408
        }
409

    
410
        /**
411
         * This method initializes jCheckBox1
412
         *
413
         * @return javax.swing.JCheckBox
414
         */
415
        public JCheckBox getCbOneLyrPerBand() {
416
                if (jCheckBox == null) {
417
                        jCheckBox = new JCheckBox();
418
                }
419
                return jCheckBox;
420
        }
421

    
422
        /***************************Metodos***************************/
423

    
424

    
425
        public void setComponentSize(int w, int h){
426
                /*wPanel = w; hPanel = h;
427
                wComp = wPanel - 6; hComp = hPanel - 40;
428
                hTable = hComp - 412;
429
                wTable = wComp - 10;
430

431
                if (contract){
432
                        this.setSize(wPanel, hPanel - hTable - 120 - 30);
433
                        pTailImage.setPreferredSize(new java.awt.Dimension(wPanel, hPanel - hTable - 120 - 30));
434
                        this.getPBorder().setSize(wComp, hComp - hTable - 120 - 30);
435
                        this.getPBorder().setPreferredSize(new java.awt.Dimension(wComp, hComp - hTable - 120 - 30));
436
                }
437
                if (!contract){
438
                        this.setSize(wPanel, hPanel);
439
                        pTailImage.setPreferredSize(new java.awt.Dimension(wPanel, hPanel));
440
                        this.getPBorder().setSize(wComp, hComp);
441
                        this.getPBorder().setPreferredSize(new java.awt.Dimension(wComp, hComp));
442

443
                }
444

445
                pCoordPixel.setComponentSize(wTable, 90);
446
                pCoordReal.setComponentSize(wTable, 90);
447
                pResize.setPreferredSize(new java.awt.Dimension(wTable - 4,32));
448
                pResolution.setPreferredSize(new java.awt.Dimension(wTable,120));
449
                pResolution.setComponentSize(wTable,120);
450
                pSelection.setPreferredSize(new java.awt.Dimension(wTable,hTable));
451
                pSelection.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Messages.getText("seleccion_bandas"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10), null));
452
                tSelection.setComponentSize(wTable - 20, hTable - 40);
453
                pCheck.setPreferredSize(new java.awt.Dimension(wTable,30));
454
                pButtons.setPreferredSize(new java.awt.Dimension(wTable,30));*/
455

    
456

    
457
        }
458

    
459
        /**
460
         * Devuelve los valores de las coordenadas p?xel
461
         * introducidas por el usuario.
462
         * @return
463
         */
464
        public String[] getCoordPixel(){
465
                String[] s = {String.valueOf(pxMinX), String.valueOf(pxMinY), String.valueOf(pxMaxX), String.valueOf(pxMaxY)};
466
                return s;
467
        }
468

    
469
        /**
470
         * Asigna los valores de las coordenadas p?xel.
471
         * @return
472
         */
473
        private void setCoordPixel(String[] values){
474
                this.pCoordPixel.setValues(values);
475
        }
476

    
477
        /**
478
         * Devuelve los valores de las coordenadas reales
479
         * introducidas por el usuario.
480
         * @return
481
         */
482
        public String[] getCoordReal(){
483
                String[] s = {String.valueOf(wcMinX), String.valueOf(wcMaxY), String.valueOf(wcMaxX), String.valueOf(wcMinY)};
484
                return s;
485
        }
486

    
487
        /**
488
         * Asigna los valores de las coordenadas reales.
489
         * @return
490
         */
491
        private void setCoordReal(String[] values){
492
                this.pCoordReal.setValues(values);
493
        }
494

    
495
        /**
496
         * Asigna las coordenadas del mundo real a partir de n?meros en coma flotante.
497
         * @param minx coordenada m?nima de X
498
         * @param miny coordenada m?nima de Y
499
         * @param maxx coordenada m?xima de X
500
         * @param maxy coordenada m?xima de Y
501
         * @param dec N?mero de decimales a mostrar en la caja de texto
502
         */
503
        public void setCoorRealFromDouble(double minx, double miny, double maxx, double maxy, int dec){
504
                wcMinX = minx;
505
                wcMinY = miny;
506
                wcMaxX = maxx;
507
                wcMaxY = maxy;
508
                   setCoordReal(getCoord(minx, miny, maxx, maxy, dec));
509
        }
510

    
511
        /**
512
         * Asigna las coordenadas pixel a partir de n?meros en coma flotante.
513
         * @param minx coordenada m?nima de X
514
         * @param miny coordenada m?nima de Y
515
         * @param maxx coordenada m?xima de X
516
         * @param maxy coordenada m?xima de Y
517
         * @param dec N?mero de decimales a mostrar en la caja de texto
518
         */
519
        public void setCoorPixelFromDouble(double minx, double miny, double maxx, double maxy, int dec){
520
                pxMinX = minx;
521
                pxMinY = miny;
522
                pxMaxX = maxx;
523
                pxMaxY = maxy;
524
                   setCoordPixel(getCoord(minx, miny, maxx, maxy, dec));
525
        }
526

    
527
        /**
528
         * Obtiene un texto con las coordenadas a partir de n?meros en coma flotante.
529
         * @param minx coordenada m?nima de X
530
         * @param miny coordenada m?nima de Y
531
         * @param maxx coordenada m?xima de X
532
         * @param maxy coordenada m?xima de Y
533
         * @param dec N?mero de decimales a mostrar en la caja de texto
534
         */
535
        private String[] getCoord(double minx, double miny, double maxx, double maxy, int dec){
536
                String[] coordPx = new String[4];
537
                int indexPoint = String.valueOf(minx).indexOf('.');
538
                   try{
539
                           coordPx[0] = String.valueOf(minx).substring(0, indexPoint + dec);
540
                   }catch(StringIndexOutOfBoundsException ex){
541
                           coordPx[0] = String.valueOf(minx);
542
                   }
543
                   indexPoint = String.valueOf(miny).indexOf('.');
544
                   try{
545
                           coordPx[1] = String.valueOf(miny).substring(0, indexPoint + dec);
546
                   }catch(StringIndexOutOfBoundsException ex){
547
                           coordPx[1] = String.valueOf(miny);
548
                   }
549
                   indexPoint = String.valueOf(maxx).indexOf('.');
550
                   try{
551
                           coordPx[2] = String.valueOf(maxx).substring(0, indexPoint + dec);
552
                   }catch(StringIndexOutOfBoundsException ex){
553
                           coordPx[2] = String.valueOf(maxx);
554
                   }
555
                   indexPoint = String.valueOf(maxy).indexOf('.');
556
                   try{
557
                           coordPx[3] = String.valueOf(maxy).substring(0, indexPoint + dec);
558
                   }catch(StringIndexOutOfBoundsException ex){
559
                           coordPx[3] = String.valueOf(maxy);
560
                   }
561
                   return coordPx;
562
        }
563

    
564
        /**
565
         * Asigna el valor del campo "tama?o de celda" a partir del double que lo representa
566
         * y con el n?mero de decimales que se especifica en el par?metro dec
567
         * @param cellSize Tama?o de celda en double
568
         * @param dec N?mero de decimales
569
         */
570
        public void setCellSizeText(double cellSize, int dec){
571
                realCellSize = cellSize;
572
                pResolution.setCellSizeText(cellSize, dec);
573
        }
574

    
575
        /**
576
         * Asigna el valor del campo "Ancho" a partir del double que lo representa
577
         * y con el n?mero de decimales que se especifica en el par?metro dec
578
         * @param width Ancho
579
         * @param dec N?mero de decimales
580
         */
581
        public void setWidthText(double width, int dec){
582
                realWidth = width;
583
                pResolution.setWidthText(width, dec);
584
        }
585

    
586
        /**
587
         * Asigna el valor del campo "Alto" a partir del double que lo representa
588
         * y con el n?mero de decimales que se especifica en el par?metro dec
589
         * @param height Alto
590
         * @param dec N?mero de decimales
591
         */
592
        public void setHeightText(double height, int dec){
593
                realHeight = height;
594
                pResolution.setHeightText(height, dec);
595
        }
596

    
597
        /**
598
         * Asigna la relaci?n entre el ancho y alto de la imagen
599
         * @param rel
600
         */
601
        public void setRelWidthHeight(double rel){
602
                relWidthHeight = rel;
603
        }
604

    
605
        /**
606
         * Obtiene la relaci?n entre el ancho y alto de la imagen
607
         * @return
608
         */
609
        public double getRelWidthHeight(){
610
                return relWidthHeight;
611
        }
612

    
613
        /**
614
         * Devuelve el valor del campo "tama?o de celda"
615
         * @return
616
         */
617
        public double getCellSizeText(){
618
                return realCellSize;
619
        }
620

    
621
        /**
622
         * Devuelve el valor del campo "tama?o de celda"
623
         * @return
624
         */
625
        public double getWidthText(){
626
                return realWidth;
627
        }
628

    
629
        /**
630
         * Devuelve el valor del campo "tama?o de celda"
631
         * @return
632
         */
633
        public double getHeightText(){
634
                return realHeight;
635
        }
636

    
637
        /**
638
         * Expande o contrae el panel inferior seg?n el estado en el que se encuentre.
639
         *
640
         */
641
        public void contractExpandPanel(){
642
                boolean aux = contract;
643
                if (aux){
644
                        this.setSize(wPanel, hPanel);
645
                        pTailImage.setPreferredSize(new java.awt.Dimension(wPanel, hPanel));
646
                        this.getPBorder().setSize(wComp, hComp);
647
                        this.getPBorder().setPreferredSize(new java.awt.Dimension(wComp, hComp));
648
                        this.getPResolution().setVisible(true);
649
                        this.getPSelection().setVisible(true);
650
                        this.getPCheck().setVisible(true);
651
                }
652
                if (!aux){
653
                        this.setSize(wPanel, hPanel - hTable - 120 - 30);
654
                        pTailImage.setPreferredSize(new java.awt.Dimension(wPanel, hPanel - hTable - 120 - 30));
655
                        this.getPBorder().setSize(wComp, hComp - hTable - 120 - 30);
656
                        this.getPBorder().setPreferredSize(new java.awt.Dimension(wComp, hComp - hTable - 120 - 30));
657
                        this.getPResolution().setVisible(false);
658
                        this.getPSelection().setVisible(false);
659
                        this.getPCheck().setVisible(false);
660
                }
661
                this.validate();
662
                if (aux)        contract = false;
663
                else                contract = true;
664

    
665
                if (contract == true){
666
                        pResize.getButton(2).setToolTipText("expandir");
667
                        pResize.getButton(2).setIcon(new ImageIcon(getClass().getResource("images/down.png")));
668
                }
669
                if (contract == false){
670
                        pResize.getButton(2).setToolTipText("contraer");
671
                        pResize.getButton(2).setIcon(new ImageIcon(getClass().getResource("images/up.png")));
672
                }
673

    
674
        }
675

    
676
        /**
677
         * Obtiene la coordenada de m?xima X en pixel.
678
         * @return Coordenada de m?xima X en pixel
679
         */
680
        public double getPxMaxX() {
681
                return pxMaxX;
682
        }
683

    
684
        /**
685
         * Obtiene la coordenada de m?xima Y en pixel.
686
         * @return Coordenada de m?xima Y en pixel
687
         */
688
        public double getPxMaxY() {
689
                return pxMaxY;
690
        }
691

    
692
        /**
693
         * Obtiene la coordenada de m?nima X en pixel.
694
         * @return Coordenada de m?nima X en pixel
695
         */
696
        public double getPxMinX() {
697
                return pxMinX;
698
        }
699

    
700
        /**
701
         * Obtiene la coordenada de m?nima Y en pixel.
702
         * @return Coordenada de m?nima Y en pixel
703
         */
704
        public double getPxMinY() {
705
                return pxMinY;
706
        }
707

    
708
        /**
709
         * Obtiene la coordenada de m?xima X real.
710
         * @return Coordenada de m?xima X real.
711
         */
712
        public double getWcMaxX() {
713
                return wcMaxX;
714
        }
715

    
716
        /**
717
         * Obtiene la coordenada de m?xima Y real.
718
         * @return Coordenada de m?xima Y real
719
         */
720
        public double getWcMaxY() {
721
                return wcMaxY;
722
        }
723

    
724
        /**
725
         * Obtiene la coordenada de m?nima X real.
726
         * @return Coordenada de m?nima X real
727
         */
728
        public double getWcMinX() {
729
                return wcMinX;
730
        }
731

    
732
        /**
733
         * Obtiene la coordenada de m?nima Y real.
734
         * @return Coordenada de m?nima Y real
735
         */
736
        public double getWcMinY() {
737
                return wcMinY;
738
        }
739

    
740
        public void selectLayerFullExtend(){
741
                this.setCoorRealFromDouble(extent.getMinX(), extent.getMaxY(), extent.getMaxX(), extent.getMinY(), 6);
742
                   Rectangle2D r = org.cresques.util.Utilities.getPxRectFromMapRect(extent, widthPx, heightPx, extent);
743
                   this.setCoorPixelFromDouble(r.getMinX(), r.getMinY(), r.getMaxX(), r.getMaxY(), 3);
744
                   this.setWidthText(r.getWidth(), 0);
745
                   this.setHeightText(r.getHeight(), 0);
746
                   this.setCellSizeText((extent.getWidth() / r.getWidth()), 4);
747
                   this.setRelWidthHeight((double)(r.getWidth() / r.getHeight()));
748
                   this.parent.setInitValuesToSize(r.getWidth(), r.getHeight());
749
        }
750
}