Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / properties / panels / EnhancedPanel.java @ 29454

History | View | Annotate | Download (4.41 KB)

1 10740 nacho
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.rastertools.properties.panels;
20
21 17047 nbrodin
import java.awt.Dimension;
22 10740 nacho
import java.awt.GridLayout;
23
24 13277 nacho
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
25 13599 bsanchez
import org.gvsig.fmap.raster.layers.IRasterLayerActions;
26 15781 bsanchez
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
27 13599 bsanchez
import org.gvsig.gui.util.StatusComponent;
28 10740 nacho
import org.gvsig.raster.grid.filter.RasterFilterList;
29 12383 nacho
import org.gvsig.raster.hierarchy.IRasterDataset;
30
import org.gvsig.raster.hierarchy.IRasterProperties;
31 12166 bsanchez
import org.gvsig.rastertools.properties.control.EnhancedControl;
32 10740 nacho
33
import com.iver.andami.PluginServices;
34
import com.iver.cit.gvsig.fmap.layers.FLayer;
35
/**
36
 * Panel para los controles de brillo y contrase .
37 12553 bsanchez
 *
38 10740 nacho
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 */
40 15781 bsanchez
public class EnhancedPanel extends AbstractPanel {
41 13599 bsanchez
        final private static long serialVersionUID = 0;
42
43
        private EnhancedBrightnessContrastPanel contrastPanel   = null;
44
        private EnhancedWithTrimPanel           trimPanel       = null;
45
        private EnhancedControl                 enhancedControl = null;
46
        private FLayer                          fLayer          = null;
47 15804 bsanchez
48 10740 nacho
        /**
49
         * Contructor
50
         */
51 13599 bsanchez
        public EnhancedPanel() {
52 15781 bsanchez
                setLabel(PluginServices.getText(this, "realce"));
53 10740 nacho
                initialize();
54
        }
55 12553 bsanchez
56
57 15781 bsanchez
        protected void initialize() {
58 10740 nacho
                setLayout(new GridLayout(1, 2));
59 13599 bsanchez
                add(getBrightnessContrastPanel());
60
                add(getEnhancedWithTrimPanel());
61 17047 nbrodin
                this.setPreferredSize(new Dimension(100, 80));
62 10740 nacho
        }
63 12553 bsanchez
64 15804 bsanchez
        /*
65
         * (non-Javadoc)
66
         * @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#initializeUI()
67
         */
68 13599 bsanchez
        public void initializeUI() {
69 15804 bsanchez
        }
70 12553 bsanchez
71 10740 nacho
        /**
72
         * Obtiene el panel de brillo y contraste
73
         * @return EnhancedBrightnessContrastPanel
74
         */
75 13599 bsanchez
        public EnhancedBrightnessContrastPanel getBrightnessContrastPanel() {
76
                if (contrastPanel == null) {
77
                        contrastPanel = new EnhancedBrightnessContrastPanel();
78
                }
79
                return contrastPanel;
80 10740 nacho
        }
81 12553 bsanchez
82 10740 nacho
        /**
83
         * Obtiene el panel de realce con recorte de colas
84
         * @return EnhancedWithTrimPanel
85
         */
86 13599 bsanchez
        public EnhancedWithTrimPanel getEnhancedWithTrimPanel() {
87
                if (trimPanel == null) {
88
                        trimPanel = new EnhancedWithTrimPanel();
89
                }
90 10740 nacho
                return trimPanel;
91
        }
92 12553 bsanchez
93 10740 nacho
        /*
94
         * (non-Javadoc)
95 12553 bsanchez
         * @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#accept()
96 10740 nacho
         */
97
        public void accept() {
98
                enhancedControl.accept();
99
        }
100
101
        /*
102
         * (non-Javadoc)
103 12553 bsanchez
         * @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#apply()
104 10740 nacho
         */
105
        public void apply() {
106
                enhancedControl.apply();
107
        }
108
109
        /*
110
         * (non-Javadoc)
111 12553 bsanchez
         * @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#cancel()
112 10740 nacho
         */
113
        public void cancel() {
114
                enhancedControl.cancel();
115
        }
116
117 15781 bsanchez
        public void setReference(Object ref) {
118
                super.setReference(ref);
119 15804 bsanchez
120 15781 bsanchez
                if (!(ref instanceof FLayer))
121
                        return;
122 15804 bsanchez
123 15781 bsanchez
                FLayer lyr = (FLayer) ref;
124 10740 nacho
125 13599 bsanchez
                fLayer = lyr;
126
                actionEnabled();
127 10740 nacho
                IRasterDataset dataset = null;
128
                RasterFilterList rfl = null;
129 12553 bsanchez
130
                if (lyr instanceof IRasterDataset)
131
                        dataset = (IRasterDataset) lyr;
132
133
                if (lyr instanceof IRasterProperties)
134
                        rfl = (((IRasterProperties) lyr).getRenderFilterList());
135
136 15804 bsanchez
                enhancedControl = new EnhancedControl(getPanelGroup(), this, dataset, fLayer, rfl);
137 10740 nacho
        }
138
139 15781 bsanchez
140 13599 bsanchez
        private void actionEnabled() {
141 15804 bsanchez
                FLyrRasterSE fLyrRasterSE = ((FLyrRasterSE) fLayer);
142 13599 bsanchez
143 15804 bsanchez
                if (!fLyrRasterSE.isActionEnabled(IRasterLayerActions.BRIGHTNESSCONTRAST))
144
                        StatusComponent.setDisabled(getBrightnessContrastPanel());
145 13599 bsanchez
146 15804 bsanchez
                if (!fLyrRasterSE.isActionEnabled(IRasterLayerActions.ENHANCED))
147
                        StatusComponent.setDisabled(getEnhancedWithTrimPanel());
148
149
                if (!fLyrRasterSE.isActionEnabled(IRasterLayerActions.BRIGHTNESSCONTRAST) &&
150
                                !fLyrRasterSE.isActionEnabled(IRasterLayerActions.ENHANCED))
151
                        setVisible(false);
152
                else
153
                        setVisible(true);
154
        }
155
156 15781 bsanchez
        public void selected() {
157 10740 nacho
        }
158 12553 bsanchez
}