Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_Build_1015 / libraries / libCq_CMS_praster / src / org / cresques / ui / raster / CutRasterPanel.java @ 13679

History | View | Annotate | Download (22.1 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 = 570, hPanel = 600;
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();
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
                        pCoordPixel.setPreferredSize(new java.awt.Dimension(550,70));
187
                }
188
                return pCoordPixel;
189
        }
190

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

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

    
225
                }
226
                return pResize;
227
        }
228

    
229

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

    
244
        /**
245
         * This method initializes jPanel1
246
         *
247
         * @return javax.swing.JPanel
248
         */
249
        private JPanel getPSelection() {
250
                if (pSelection == null) {
251
                        pSelection = new JPanel();
252
                        pSelection.setLayout(new FlowLayout());
253
                        pSelection.setPreferredSize(new java.awt.Dimension(550,160));
254
                        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));
255
                        pSelection.add(getTSelection(), null);
256

    
257
                }
258
                return pSelection;
259
        }
260

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

    
273
                return tSelection;
274
        }
275

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

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

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

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

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

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

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

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

    
426
        /***************************Metodos***************************/
427

    
428

    
429
        public void setComponentSize(int w, int h){
430
                /*wPanel = w; hPanel = h;
431
                wComp = wPanel - 6; hComp = hPanel - 40;
432
                hTable = hComp - 412;
433
                wTable = wComp - 10;
434

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

447
                }
448

449
                pCoordPixel.setComponentSize(wTable, 90);
450
                pCoordReal.setComponentSize(wTable, 90);
451
                pResize.setPreferredSize(new java.awt.Dimension(wTable - 4,32));
452
                pResolution.setPreferredSize(new java.awt.Dimension(wTable,120));
453
                pResolution.setComponentSize(wTable,120);
454
                pSelection.setPreferredSize(new java.awt.Dimension(wTable,hTable));
455
                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));
456
                tSelection.setComponentSize(wTable - 20, hTable - 40);
457
                pCheck.setPreferredSize(new java.awt.Dimension(wTable,30));
458
                pButtons.setPreferredSize(new java.awt.Dimension(wTable,30));*/
459

    
460

    
461
        }
462

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

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

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

    
491
        /**
492
         * Asigna los valores de las coordenadas reales.
493
         * @return
494
         */
495
        private void setCoordReal(String[] values){
496
                this.pCoordReal.setValues(values);
497
        }
498

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

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

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

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

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

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

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

    
609
        /**
610
         * Obtiene la relaci?n entre el ancho y alto de la imagen
611
         * @return
612
         */
613
        public double getRelWidthHeight(){
614
                return relWidthHeight;
615
        }
616

    
617
        /**
618
         * Devuelve el valor del campo "tama?o de celda"
619
         * @return
620
         */
621
        public double getCellSizeText(){
622
                return realCellSize;
623
        }
624

    
625
        /**
626
         * Devuelve el valor del campo "tama?o de celda"
627
         * @return
628
         */
629
        public double getWidthText(){
630
                return realWidth;
631
        }
632

    
633
        /**
634
         * Devuelve el valor del campo "tama?o de celda"
635
         * @return
636
         */
637
        public double getHeightText(){
638
                return realHeight;
639
        }
640

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

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

    
678
        }
679

    
680
        /**
681
         * Obtiene la coordenada de m?xima X en pixel.
682
         * @return Coordenada de m?xima X en pixel
683
         */
684
        public double getPxMaxX() {
685
                return pxMaxX;
686
        }
687

    
688
        /**
689
         * Obtiene la coordenada de m?xima Y en pixel.
690
         * @return Coordenada de m?xima Y en pixel
691
         */
692
        public double getPxMaxY() {
693
                return pxMaxY;
694
        }
695

    
696
        /**
697
         * Obtiene la coordenada de m?nima X en pixel.
698
         * @return Coordenada de m?nima X en pixel
699
         */
700
        public double getPxMinX() {
701
                return pxMinX;
702
        }
703

    
704
        /**
705
         * Obtiene la coordenada de m?nima Y en pixel.
706
         * @return Coordenada de m?nima Y en pixel
707
         */
708
        public double getPxMinY() {
709
                return pxMinY;
710
        }
711

    
712
        /**
713
         * Obtiene la coordenada de m?xima X real.
714
         * @return Coordenada de m?xima X real.
715
         */
716
        public double getWcMaxX() {
717
                return wcMaxX;
718
        }
719

    
720
        /**
721
         * Obtiene la coordenada de m?xima Y real.
722
         * @return Coordenada de m?xima Y real
723
         */
724
        public double getWcMaxY() {
725
                return wcMaxY;
726
        }
727

    
728
        /**
729
         * Obtiene la coordenada de m?nima X real.
730
         * @return Coordenada de m?nima X real
731
         */
732
        public double getWcMinX() {
733
                return wcMinX;
734
        }
735

    
736
        /**
737
         * Obtiene la coordenada de m?nima Y real.
738
         * @return Coordenada de m?nima Y real
739
         */
740
        public double getWcMinY() {
741
                return wcMinY;
742
        }
743

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