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 / EnhancedPanel.java @ 4171

History | View | Annotate | Download (4.06 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.Dimension;
25
import java.awt.GridLayout;
26

    
27
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList;
28
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
29
import org.gvsig.gui.util.StatusComponent;
30
import org.gvsig.i18n.Messages;
31
import org.gvsig.raster.fmap.layers.FLyrRaster;
32
import org.gvsig.raster.fmap.layers.IRasterLayerActions;
33
import org.gvsig.raster.tools.app.basic.tool.properties.control.EnhancedControl;
34

    
35
/**
36
 * Panel para los controles de brillo y contrase .
37
 *
38
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 */
40
public class EnhancedPanel extends AbstractPanel {
41
        private final static long               serialVersionUID = 0;
42
        private EnhancedBrightnessContrastPanel contrastPanel     = null;
43
        private EnhancedWithTrimPanel           trimPanel         = null;
44
        private EnhancedControl                 enhancedControl   = null;
45
        private FLyrRaster                      fLayer            = null;
46

    
47
        /**
48
         * Contructor
49
         */
50
        public EnhancedPanel() {
51
                setLabel(Messages.getText("realce"));
52
                initialize();
53
        }
54

    
55

    
56
        protected void initialize() {
57
                setLayout(new GridLayout(1, 2));
58
                add(getBrightnessContrastPanel());
59
                add(getEnhancedWithTrimPanel());
60
                this.setPreferredSize(new Dimension(100, 80));
61

    
62
                this.setPriority(60);
63
        }
64

    
65
        public void initializeUI() {
66
        }
67

    
68
        /**
69
         * Obtiene el panel de brillo y contraste
70
         * @return EnhancedBrightnessContrastPanel
71
         */
72
        public EnhancedBrightnessContrastPanel getBrightnessContrastPanel() {
73
                if (contrastPanel == null) {
74
                        contrastPanel = new EnhancedBrightnessContrastPanel();
75
                }
76
                return contrastPanel;
77
        }
78

    
79
        /**
80
         * Obtiene el panel de realce con recorte de colas
81
         * @return EnhancedWithTrimPanel
82
         */
83
        public EnhancedWithTrimPanel getEnhancedWithTrimPanel() {
84
                if (trimPanel == null) {
85
                        trimPanel = new EnhancedWithTrimPanel();
86
                }
87
                return trimPanel;
88
        }
89

    
90
        public void accept() {
91
                enhancedControl.accept();
92
        }
93

    
94
        public void apply() {
95
                enhancedControl.apply();
96
        }
97

    
98
        public void cancel() {
99
                enhancedControl.cancel();
100
        }
101

    
102
        public void setReference(Object ref) {
103
                super.setReference(ref);
104

    
105
                if (!(ref instanceof FLyrRaster))
106
                        return;
107

    
108
                fLayer = (FLyrRaster) ref;
109

    
110
                actionEnabled();
111
                RasterFilterList rfl  = fLayer.getRender().getFilterList();
112

    
113
                enhancedControl = new EnhancedControl(getPanelGroup(), this, fLayer, rfl);
114
        }
115

    
116
        private void actionEnabled() {
117
                IRasterLayerActions actions = null;
118
                if(fLayer instanceof IRasterLayerActions)
119
                        actions = ((IRasterLayerActions) fLayer);
120

    
121
                if (!actions.isActionEnabled(IRasterLayerActions.BRIGHTNESSCONTRAST))
122
                        StatusComponent.setDisabled(getBrightnessContrastPanel());
123

    
124
                if (!actions.isActionEnabled(IRasterLayerActions.ENHANCED))
125
                        StatusComponent.setDisabled(getEnhancedWithTrimPanel());
126

    
127
                if (actions.isActionEnabled(IRasterLayerActions.ENHANCED) &&
128
                        !actions.isActionEnabled(IRasterLayerActions.TAILTRIM)) {
129
                        getEnhancedWithTrimPanel().getTrimSlider().setVisible(false);
130
                        getEnhancedWithTrimPanel().getTrimCheck().setVisible(false);
131
                }
132

    
133
                if (!actions.isActionEnabled(IRasterLayerActions.BRIGHTNESSCONTRAST) &&
134
                                !actions.isActionEnabled(IRasterLayerActions.ENHANCED))
135
                        setVisible(false);
136
                else
137
                        setVisible(true);
138
        }
139

    
140
        public void selected() {
141
        }
142
}