Statistics
| Revision:

gvsig-raster / org.gvsig.raster.tools / branches / org.gvsig.raster.tools_dataaccess_refactoring / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / properties / panel / EnhancedPanel.java @ 2340

History | View | Annotate | Download (4.04 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

    
63
        public void initializeUI() {
64
        }
65

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

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

    
88
        public void accept() {
89
                enhancedControl.accept();
90
        }
91

    
92
        public void apply() {
93
                enhancedControl.apply();
94
        }
95

    
96
        public void cancel() {
97
                enhancedControl.cancel();
98
        }
99

    
100
        public void setReference(Object ref) {
101
                super.setReference(ref);
102

    
103
                if (!(ref instanceof FLyrRaster))
104
                        return;
105

    
106
                fLayer = (FLyrRaster) ref;
107

    
108
                actionEnabled();
109
                RasterFilterList rfl  = fLayer.getRender().getFilterList();
110

    
111
                enhancedControl = new EnhancedControl(getPanelGroup(), this, fLayer, rfl);
112
        }
113

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

    
119
                if (!actions.isActionEnabled(IRasterLayerActions.BRIGHTNESSCONTRAST))
120
                        StatusComponent.setDisabled(getBrightnessContrastPanel());
121

    
122
                if (!actions.isActionEnabled(IRasterLayerActions.ENHANCED))
123
                        StatusComponent.setDisabled(getEnhancedWithTrimPanel());
124
                
125
                if (actions.isActionEnabled(IRasterLayerActions.ENHANCED) && 
126
                        !actions.isActionEnabled(IRasterLayerActions.TAILTRIM)) {
127
                        getEnhancedWithTrimPanel().getTrimSlider().setVisible(false);
128
                        getEnhancedWithTrimPanel().getTrimCheck().setVisible(false);
129
                }
130

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

    
138
        public void selected() {
139
        }
140
}