Statistics
| Revision:

gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / properties / panel / GeneralPanel.java @ 4171

History | View | Annotate | Download (20.5 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22
package org.gvsig.raster.tools.app.basic.tool.properties.panel;
23

    
24
import java.awt.BorderLayout;
25
import java.awt.Color;
26
import java.awt.Dimension;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.Insets;
30
import java.awt.event.ActionEvent;
31
import java.awt.event.ActionListener;
32
import java.text.NumberFormat;
33

    
34
import javax.swing.BorderFactory;
35
import javax.swing.JButton;
36
import javax.swing.JCheckBox;
37
import javax.swing.JEditorPane;
38
import javax.swing.JFormattedTextField;
39
import javax.swing.JLabel;
40
import javax.swing.JPanel;
41
import javax.swing.JScrollPane;
42
import javax.swing.border.TitledBorder;
43
import javax.swing.text.DefaultFormatterFactory;
44
import javax.swing.text.NumberFormatter;
45

    
46
import org.gvsig.andami.PluginServices;
47
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
48
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
49
import org.gvsig.i18n.Messages;
50
import org.gvsig.raster.fmap.layers.FLyrRaster;
51
import org.gvsig.raster.fmap.layers.IRasterLayerActions;
52
import org.gvsig.raster.mainplugin.properties.RasterPropertiesTocMenuEntry;
53
import org.gvsig.raster.tools.app.basic.RasterToolsUtil;
54
import org.gvsig.raster.tools.app.basic.raster.process.IProcessActions;
55
import org.gvsig.raster.tools.app.basic.raster.process.RasterProcess;
56
import org.gvsig.raster.tools.app.basic.raster.process.StatisticsProcess;
57

    
58
/**
59
 * Main panel of Properties window. This panel contains general options.
60
 *
61
 * @author Nacho Brodin (nachobrodin@gmail.com)
62
 */
63
public class GeneralPanel extends AbstractPanel implements ActionListener, IProcessActions {
64
        private static final long   serialVersionUID = -4761218260868307869L;
65
        private FLyrRaster          fLayer              = null;
66

    
67
        private JLabel              labelNotShowLayer   = null;
68
        private JLabel              labelMinim          = null;
69
        private JLabel              labelMaxim          = null;
70
        private JCheckBox           checkBoxMinim       = null;
71
        private JCheckBox           checkBoxMaxim       = null;
72
        private JFormattedTextField textFieldMinim      = null;
73
        private JFormattedTextField textFieldMaxim      = null;
74

    
75
        private NumberFormat        doubleDisplayFormat = null;
76
        private NumberFormat        doubleEditFormat    = null;
77
        private double              initMaxScale        = -1;
78
        private double              initMinScale        = -1;
79

    
80
        private JButton             calcButton          = null;
81
        private JPanel              scalePanel          = null;
82
        private JPanel              recalcStatsPanel    = null;
83
        private NoDataPanel      pNoDataPanel        = null;
84
        //private Transparency        transparency        = null;
85

    
86
        private JScrollPane         jScrollPane         = null;
87
        private JEditorPane         jEditorPane         = null;
88

    
89
        private final String        bgColor0            = "\"#FEEDD6\""; // light salmon
90
        private final String        bgColor1            = "\"#EAEAEA\""; // light grey
91
        private final String        bgColor3            = "\"#FBFFE1\""; // light yellow
92
        private final String        bgColor4            = "\"#D6D6D6\""; // Gris
93

    
94
        /**
95
         * Booleano que est? a true cuando la fila a dibujar es par y a false cuando
96
         * es impar.
97
         */
98
        private boolean             rowColor            = true;
99

    
100

    
101
        /**
102
         * Constructor del GeneralPanel
103
         */
104
        public GeneralPanel() {
105
                super();
106
                setUpFormats();
107
                initialize();
108
                translate();
109
        }
110

    
111
        /**
112
         * Create and set up number formats. These objects also parse numbers input by
113
         * user.
114
         */
115
        private void setUpFormats() {
116
                doubleDisplayFormat = NumberFormat.getNumberInstance();
117
                doubleDisplayFormat.setMinimumFractionDigits(0);
118
                doubleEditFormat = NumberFormat.getNumberInstance();
119
        }
120

    
121
        /**
122
         * Asigna todos los textos del panel en su idioma correspondiente
123
         */
124
        private void translate() {
125
                getJLabelNotShowLayer().setText(PluginServices.getText(this, "no_mostrar_la_capa_cuando_la_escala_sea") + ":");
126
                getJLabelMinim().setText("(" + PluginServices.getText(this, "escala_maxima") + ")");
127
                getJLabelMaxim().setText("(" + PluginServices.getText(this, "escala_minima") + ")");
128
                getJCheckBoxMinim().setText(PluginServices.getText(this, "mayor_de") + " 1:");
129
                getJCheckBoxMaxim().setText(PluginServices.getText(this, "menor_de") + " 1:");
130
                getScalePanel().setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this, "rango_de_escalas")));
131
                getRecalcStatsPanel().setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this, "stats")));
132
                setLabel(PluginServices.getText(this, "general"));
133
        }
134

    
135
        /**
136
         * Construye el panel
137
         */
138
        protected void initialize() {
139
                GridBagConstraints gridBagConstraints;
140
                setLayout(new GridBagLayout());
141
                gridBagConstraints = new java.awt.GridBagConstraints();
142
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
143
                gridBagConstraints.weightx = 1.0;
144
                add(getScalePanel(), gridBagConstraints);
145

    
146
                gridBagConstraints = new java.awt.GridBagConstraints();
147
                gridBagConstraints.gridx = 0;
148
                gridBagConstraints.gridy = 1;
149
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
150
                add(getNoDataPanel(), gridBagConstraints);
151

    
152
                gridBagConstraints = new java.awt.GridBagConstraints();
153
                gridBagConstraints.gridx = 0;
154
                gridBagConstraints.gridy = 2;
155
                gridBagConstraints.weighty = 1.0;
156
                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
157
                add(getRecalcStatsPanel(), gridBagConstraints);
158

    
159
                this.setPreferredSize(new Dimension(100, 80));
160

    
161
                this.setPriority(90);
162
        }
163

    
164

    
165
        private void actionEnabled() {
166
                IRasterLayerActions actions = null;
167
                if(fLayer instanceof IRasterLayerActions)
168
                        actions = ((IRasterLayerActions) fLayer);
169

    
170
                if (!actions.isActionEnabled(IRasterLayerActions.STATS))
171
                        getRecalcStatsPanel().setVisible(false);
172

    
173
                if (!actions.isActionEnabled(IRasterLayerActions.NODATA))
174
                        getNoDataPanel().setVisible(false);
175
        }
176

    
177
        /**
178
         * This method initializes TranspOpacitySliderPanel
179
         * @return javax.swing.JPanel
180
         */
181
        public NoDataPanel getNoDataPanel() {
182
                if (pNoDataPanel == null) {
183
                        pNoDataPanel = new NoDataPanel();
184
                        pNoDataPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "nodata"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
185
                }
186

    
187
                return pNoDataPanel;
188
        }
189

    
190
        public JPanel getScalePanel() {
191
                if (scalePanel == null) {
192
                        scalePanel = new JPanel();
193
                        scalePanel.setLayout(new GridBagLayout());
194

    
195
                        GridBagConstraints gridBagConstraints;
196

    
197
                        int y = 0;
198
                        gridBagConstraints = new GridBagConstraints();
199
                        gridBagConstraints.gridx = 0;
200
                        gridBagConstraints.gridy = y;
201
                        gridBagConstraints.gridwidth = 3;
202
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
203
                        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
204
                        scalePanel.add(getJLabelNotShowLayer(), gridBagConstraints);
205

    
206
                        y++;
207
                        gridBagConstraints = new GridBagConstraints();
208
                        gridBagConstraints.gridx = 0;
209
                        gridBagConstraints.gridy = y;
210
                        gridBagConstraints.insets = new Insets(2, 2, 2, 0);
211
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
212
                        scalePanel.add(getJCheckBoxMinim(), gridBagConstraints);
213

    
214
                        gridBagConstraints = new GridBagConstraints();
215
                        gridBagConstraints.gridx = 1;
216
                        gridBagConstraints.gridy = y;
217
                        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
218
                        gridBagConstraints.weightx = 1.0;
219
                        gridBagConstraints.insets = new Insets(2, 0, 2, 2);
220
                        scalePanel.add(getJTextFieldMinim(), gridBagConstraints);
221

    
222
                        gridBagConstraints = new GridBagConstraints();
223
                        gridBagConstraints.gridx = 2;
224
                        gridBagConstraints.gridy = y;
225
                        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
226
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
227
                        scalePanel.add(getJLabelMinim(), gridBagConstraints);
228

    
229
                        y++;
230
                        gridBagConstraints = new GridBagConstraints();
231
                        gridBagConstraints.gridx = 0;
232
                        gridBagConstraints.gridy = y;
233
                        gridBagConstraints.insets = new Insets(2, 2, 2, 0);
234
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
235
                        scalePanel.add(getJCheckBoxMaxim(), gridBagConstraints);
236

    
237
                        gridBagConstraints = new GridBagConstraints();
238
                        gridBagConstraints.gridx = 1;
239
                        gridBagConstraints.gridy = y;
240
                        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
241
                        gridBagConstraints.weightx = 1.0;
242
                        gridBagConstraints.insets = new Insets(2, 0, 2, 2);
243
                        scalePanel.add(getJTextFieldMaxim(), gridBagConstraints);
244

    
245
                        gridBagConstraints = new GridBagConstraints();
246
                        gridBagConstraints.gridx = 2;
247
                        gridBagConstraints.gridy = y;
248
                        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
249
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
250
                        scalePanel.add(getJLabelMaxim(), gridBagConstraints);
251

    
252
                        y++;
253
                        gridBagConstraints = new GridBagConstraints();
254
                        gridBagConstraints.gridx = 0;
255
                        gridBagConstraints.gridy = y;
256
                        gridBagConstraints.gridwidth = 3;
257
                        gridBagConstraints.fill = GridBagConstraints.BOTH;
258
                        gridBagConstraints.weightx = 1.0;
259
                        gridBagConstraints.weighty = 1.0;
260
                        JPanel emptyPanel = new JPanel();
261
                        emptyPanel.setMinimumSize(new Dimension(0, 0));
262
                        scalePanel.add(emptyPanel, gridBagConstraints);
263
                }
264
                return scalePanel;
265
        }
266

    
267
        public JPanel getRecalcStatsPanel() {
268
                if (recalcStatsPanel == null) {
269
                        recalcStatsPanel = new JPanel();
270
                        recalcStatsPanel.setLayout(new BorderLayout(5, 5));
271

    
272
                        recalcStatsPanel.add(getJScrollPane(), BorderLayout.CENTER);
273
                        recalcStatsPanel.add(getCalcStatsButton(), BorderLayout.SOUTH);
274
                }
275
                return recalcStatsPanel;
276
        }
277

    
278
        /**
279
         * Bot?n para recalcular las estadisticas.
280
         * @return JButton
281
         */
282
        public JButton getCalcStatsButton() {
283
                if(calcButton == null) {
284
                        calcButton = new JButton(RasterToolsUtil.getText(this, "recalc_stats"));
285
                        calcButton.addActionListener(this);
286
                }
287
                return calcButton;
288
        }
289

    
290
        private JLabel getJLabelNotShowLayer() {
291
                if (labelNotShowLayer == null) {
292
                        labelNotShowLayer = new JLabel();
293
                }
294
                return labelNotShowLayer;
295
        }
296

    
297
        private JFormattedTextField getJTextFieldMinim() {
298
                if (textFieldMinim == null) {
299
                        textFieldMinim = new JFormattedTextField(new DefaultFormatterFactory(
300
                                        new NumberFormatter(doubleDisplayFormat),
301
                                        new NumberFormatter(doubleDisplayFormat),
302
                                        new NumberFormatter(doubleEditFormat)));
303
                        textFieldMinim.setEnabled(false);
304
                        textFieldMinim.setBackground(getBackground());
305
                }
306
                return textFieldMinim;
307
        }
308

    
309
        private JFormattedTextField getJTextFieldMaxim() {
310
                if (textFieldMaxim == null) {
311
                        textFieldMaxim = new JFormattedTextField(new DefaultFormatterFactory(
312
                                        new NumberFormatter(doubleDisplayFormat),
313
                                        new NumberFormatter(doubleDisplayFormat),
314
                                        new NumberFormatter(doubleEditFormat)));
315
                        textFieldMaxim.setEnabled(false);
316
                        textFieldMaxim.setBackground(getBackground());
317
                }
318
                return textFieldMaxim;
319
        }
320

    
321
        private JCheckBox getJCheckBoxMinim() {
322
                if (checkBoxMinim == null) {
323
                        checkBoxMinim = new JCheckBox();
324
                        checkBoxMinim.addActionListener(this);
325
                        checkBoxMinim.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
326
                        checkBoxMinim.setMargin(new java.awt.Insets(0, 0, 0, 0));
327
                }
328
                return checkBoxMinim;
329
        }
330

    
331
        private JLabel getJLabelMinim() {
332
                if (labelMinim == null) {
333
                        labelMinim = new JLabel();
334
                        labelMinim.setEnabled(false);
335
                }
336
                return labelMinim;
337
        }
338

    
339
        private JCheckBox getJCheckBoxMaxim() {
340
                if (checkBoxMaxim == null) {
341
                        checkBoxMaxim = new JCheckBox();
342
                        checkBoxMaxim.addActionListener(this);
343
                        checkBoxMaxim.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
344
                        checkBoxMaxim.setMargin(new java.awt.Insets(0, 0, 0, 0));
345
                }
346
                return checkBoxMaxim;
347
        }
348

    
349
        private JLabel getJLabelMaxim() {
350
                if (labelMaxim == null) {
351
                        labelMaxim = new JLabel();
352
                        labelMaxim.setEnabled(false);
353
                }
354
                return labelMaxim;
355
        }
356

    
357
        /*
358
         * (non-Javadoc)
359
         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
360
         */
361
        public void actionPerformed(ActionEvent e) {
362
                if (e.getSource() == getJCheckBoxMinim()) {
363
                        boolean enabled = getJCheckBoxMinim().isSelected();
364
                        getJLabelMinim().setEnabled(enabled);
365
                        getJTextFieldMinim().setEnabled(enabled);
366
                        getJTextFieldMinim().setBackground(enabled?Color.white: getBackground());
367
                }
368

    
369
                if (e.getSource() == getCalcStatsButton()) {
370
                        RasterProcess process = new StatisticsProcess();
371
                        process.addParam("layer", fLayer);
372
                        process.addParam("force", new Boolean(true));
373
                        process.setActions(this);
374
                        process.start();
375
                }
376

    
377
                if (e.getSource() == getJCheckBoxMaxim()) {
378
                        boolean enabled = getJCheckBoxMaxim().isSelected();
379
                        getJLabelMaxim().setEnabled(enabled);
380
                        getJTextFieldMaxim().setEnabled(enabled);
381
                        getJTextFieldMaxim().setBackground(enabled?Color.white: getBackground());
382
                }
383
        }
384

    
385
        /**
386
         * Controla la alternatividad de colores en la tabla.
387
         *
388
         * @return Cadena con el color de la fila siguiente.
389
         */
390
        private String getColor() {
391
                String color = (rowColor ? bgColor0 : bgColor1);
392
                rowColor = !rowColor;
393
                return color;
394
        }
395

    
396
        /**
397
         * Obtiene una entrada de la tabla en formato HTML a partir de una propiedad,
398
         * un valor y un color.
399
         *
400
         * @param prop
401
         *          Nombre de la propiedad
402
         * @param value
403
         *          Valor
404
         * @param color
405
         *          Color
406
         *
407
         * @return Entrada HTML de la tabla
408
         */
409
        private String setHTMLBasicProperty(String prop, String value) {
410
                String content = "<tr valign=\"top\">";
411
                if (prop != null)
412
                        content += "<td bgcolor=" + bgColor4 + "align=\"right\" width=\"140\"><font face=\"Arial\" size=\"3\">" + prop + ":&nbsp;</font></td>";
413
                content += "<td bgcolor=" + getColor() + "align=\"left\"><font face=\"Arial\" size=\"3\">" + value + "</font></td>";
414
                content += "</tr>";
415

    
416
                return content;
417
        }
418

    
419
        /**
420
         * Obtiene una cabecera de tabla en formato HTML a partir de un titulo.
421
         *
422
         * @param title
423
         *          Nombre del titulo
424
         * @param colspan
425
         *          Numero de celdas que ocupara el titulo
426
         *
427
         * @return Entrada HTML del titulo
428
         */
429
        private String setHTMLTitleTable(String title, int colspan) {
430
                return
431
                        "<tr valign=\"middle\" >" +
432
                        "<td bgcolor=" + bgColor3 + " align=\"center\" colspan=\"" + colspan + "\"><font face=\"Arial\" size=\"3\"><b> " + title + "</b></font></td>" +
433
                        "</tr>";
434
        }
435

    
436
        /**
437
         * Obtiene una cabecera de tabla en formato HTML a partir de un titulo.
438
         *
439
         * @param content
440
         *          Codigo HTML de las filas que componen la tabla.
441
         *
442
         * @return Entrada HTML de la tabla completa
443
         */
444
        private String setHTMLTable(String content) {
445
                return "<table cellpadding=\"0\" cellspacing=\"0\" align=\"center\" width=\"100%\">" + content + "</table>";
446
        }
447

    
448

    
449
        /*
450
         * (non-Javadoc)
451
         * @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#setReference(java.lang.Object)
452
         */
453
        public void setReference(Object ref) {
454
                super.setReference(ref);
455

    
456
                if (!(ref instanceof FLyrRaster))
457
                        return;
458

    
459
                fLayer = (FLyrRaster) ref;
460

    
461
                actionEnabled();
462

    
463
                getNoDataPanel().setLayer(fLayer);
464

    
465
                if (fLayer.getMaxScale() != -1) {
466
                        initMaxScale = fLayer.getMaxScale();
467
                        getJTextFieldMaxim().setValue(
468
                                        Double.valueOf(fLayer.getMaxScale()));
469
                        getJCheckBoxMaxim().setSelected(true);
470
                        getJLabelMaxim().setEnabled(true);
471
                        getJTextFieldMaxim().setEnabled(true);
472
                        getJTextFieldMaxim().setBackground(Color.WHITE);
473
                }
474

    
475
                if (fLayer.getMinScale() != -1) {
476
                        initMinScale = fLayer.getMinScale();
477
                        getJTextFieldMinim().setValue(
478
                                        Double.valueOf(fLayer.getMinScale()));
479
                        getJCheckBoxMinim().setSelected(true);
480
                        getJLabelMinim().setEnabled(true);
481
                        getJTextFieldMinim().setEnabled(true);
482
                        getJTextFieldMinim().setBackground(Color.WHITE);
483
                }
484

    
485
                refreshHTMLStatistics();
486
                setValuesFromPanelToTransparency();
487
        }
488

    
489
        /**
490
         * Refresca el HTML del cuadro de texto de las estadisticas de todas las capas
491
         */
492
        private void refreshHTMLStatistics() {
493
                String html = "";
494
                Statistics statistics = null;
495
                statistics = fLayer.getDataStore().getStatistics();
496
                if(statistics == null)
497
                        return;
498

    
499
                if (statistics.isCalculated()) {
500
                        double[] maxRGB = statistics.getMaxByteUnsigned();
501
                        double[] max = statistics.getMax();
502
                        double[] minRGB = statistics.getMinByteUnsigned();
503
                        double[] min = statistics.getMin();
504
                        double[] variance = statistics.getVariance();
505
                        double[] mean = statistics.getMean();
506

    
507
                        if(max != null) {
508
                                for (int i = 0; i < max.length; i++) {
509
                                        html += setHTMLTitleTable(Messages.getText("band") + " " + (i + 1), 2);
510
                                        html += setHTMLBasicProperty(Messages.getText("minimo"), Double.valueOf(min[i]).toString());
511
                                        html += setHTMLBasicProperty(Messages.getText("maximo"), Double.valueOf(max[i]).toString());
512
                                        html += setHTMLBasicProperty(Messages.getText("minimoRGB"), Double.valueOf(minRGB[i]).toString());
513
                                        html += setHTMLBasicProperty(Messages.getText("maximoRGB"), Double.valueOf(maxRGB[i]).toString());
514
                                        html += setHTMLBasicProperty(Messages.getText("media"), Double.valueOf(mean[i]).toString());
515
                                        html += setHTMLBasicProperty(Messages.getText("varianza"), Double.valueOf(variance[i]).toString());
516
                                }
517
                        }
518
                        html = setHTMLTable(html);
519
                } else {
520
                        html += setHTMLTitleTable(Messages.getText("no_statistics_computed"), 2);
521
                        html = setHTMLTable(html);
522
                }
523
                getJEditorStatsPanel().setText(html);
524
                getJEditorStatsPanel().setCaretPosition(0);
525
        }
526

    
527
        /**
528
         * This method initializes jScrollPane
529
         *
530
         * @return javax.swing.JScrollPane
531
         */
532
        private JScrollPane getJScrollPane() {
533
                if (jScrollPane == null) {
534
                        jScrollPane = new JScrollPane();
535
                        jScrollPane.setViewportView(getJEditorStatsPanel());
536
                }
537
                return jScrollPane;
538
        }
539

    
540
        /**
541
         * This method initializes jEditorPane
542
         *
543
         * @return javax.swing.JEditorPane
544
         */
545
        private JEditorPane getJEditorStatsPanel() {
546
                if (jEditorPane == null) {
547
                        jEditorPane = new JEditorPane();
548
                        jEditorPane.setEditable(false);
549
                        jEditorPane.setContentType("text/html");
550
                }
551
                return jEditorPane;
552
        }
553

    
554
        /*
555
         * (non-Javadoc)
556
         * @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#accept()
557
         */
558
        public void accept() {
559
                onlyApply();
560
        }
561

    
562
        /**
563
         * Asigna los valores del panel a la transparencia de la capa.
564
         */
565
        private void setValuesFromPanelToTransparency() {
566
                if (fLayer == null || fLayer.getDataStore() == null)
567
                        return;
568

    
569
                fLayer.setNoDataTransparent(getNoDataPanel().getCheckBoxNoDataEnabled().isSelected());
570

    
571
                // Redibujamos
572
                fLayer.getMapContext().invalidate();
573
        }
574

    
575
        /**
576
         * Aplica el estado del panel a la capa.
577
         */
578
        public void onlyApply() {
579
                if (RasterPropertiesTocMenuEntry.enableEvents)
580
                        setValuesFromPanelToTransparency();
581

    
582
                if (fLayer == null)
583
                        return;
584

    
585
                double maxScale = -1;
586
                double minScale = -1;
587

    
588
                if (getJCheckBoxMaxim().isSelected() && getJTextFieldMaxim().getValue() != null)
589
                        maxScale = ((Number) getJTextFieldMaxim().getValue()).doubleValue();
590

    
591
                if (getJCheckBoxMinim().isSelected() && getJTextFieldMinim().getValue() != null)
592
                        minScale = ((Number) getJTextFieldMinim().getValue()).doubleValue();
593

    
594
                fLayer.setMaxScale(maxScale);
595
                fLayer.setMinScale(minScale);
596
        }
597

    
598
        /*
599
         * (non-Javadoc)
600
         * @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#apply()
601
         */
602
        public void apply() {
603
                onlyApply();
604
        }
605

    
606
        /**
607
         * Restaura los valores de la capa conforme estaba al abrir el panel
608
         */
609
        public void restoreStatus() {
610
                //fLayer.setNoDataValue(((Double) getPanelGroup().getProperties().get("nodatavalue")).doubleValue());
611

    
612
                fLayer.setMaxScale(initMaxScale);
613
                fLayer.setMinScale(initMinScale);
614
        }
615

    
616
        /*
617
         * (non-Javadoc)
618
         * @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#cancel()
619
         */
620
        public void cancel() {
621
                restoreStatus();
622
        }
623

    
624
        /*
625
         * (non-Javadoc)
626
         * @see org.gvsig.raster.IProcessActions#end(java.lang.Object)
627
         */
628
        public void end(Object param) {
629
                refreshHTMLStatistics();
630
        }
631

    
632
        public void selected() {}
633
        public void interrupted() {}
634
}