Statistics
| Revision:

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

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
                }
324
                return bSave;
325
        }
326

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

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

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

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

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

    
425
        /***************************Metodos***************************/
426

    
427

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

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

446
                }
447

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

    
459

    
460
        }
461

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
677
        }
678

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

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

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

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

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

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

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

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

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