svn-gvsig-desktop / branches / v10 / extensions / extRasterTools / src / org / gvsig / rasterTools / brightnessContrast / toc / BrightnessContrastTocMenuEntry.java @ 9056
History | View | Annotate | Download (5.49 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 |
|
20 |
package org.gvsig.rasterTools.brightnessContrast.toc; |
21 |
|
22 |
import org.cresques.filter.IStackManager; |
23 |
import org.cresques.filter.RasterFilter; |
24 |
import org.cresques.filter.RasterFilterStackManager; |
25 |
import org.cresques.ui.filter.FilterRasterDialogPanel; |
26 |
import org.gvsig.rasterTools.brightnessContrast.filter.BrightnessContrastStackManager; |
27 |
import org.gvsig.rasterTools.brightnessContrast.ui.EnhancedBrightnessContrastPanel; |
28 |
|
29 |
import com.iver.andami.PluginServices; |
30 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
31 |
import com.iver.cit.gvsig.gui.panels.IRasterPropertiesRegistrable; |
32 |
import com.iver.cit.gvsig.gui.panels.PropertiesRasterDialog; |
33 |
import com.iver.cit.gvsig.project.documents.view.toc.gui.FLyrRasterAdjustPropertiesTocMenuEntry; |
34 |
|
35 |
/**
|
36 |
* Entrada al menu TOC que contiene la parter del listener que corresponde a los
|
37 |
* filtros de brillo y contraste. El metodo actionPerformed de esta clase sera llamado
|
38 |
* por FLyrRasterAdjustPropertiesTocMenuEntry. Para ello, tiene que registrarse usando
|
39 |
* el metodo register.
|
40 |
*
|
41 |
* @author Miguel ?ngel Querol Carratal? <querol_mig@gva.es>
|
42 |
*
|
43 |
*/
|
44 |
|
45 |
public class BrightnessContrastTocMenuEntry implements IRasterPropertiesRegistrable{ |
46 |
|
47 |
EnhancedBrightnessContrastPanel panel = null;
|
48 |
BrightnessContrastStackManager bcManager = null;
|
49 |
|
50 |
/**
|
51 |
* Constructor. Se registra a si mismo en las propiedades de raster del TOC.
|
52 |
* @param menu
|
53 |
*/
|
54 |
public BrightnessContrastTocMenuEntry (FLyrRasterAdjustPropertiesTocMenuEntry menu){
|
55 |
menu.register(this);
|
56 |
} |
57 |
|
58 |
/**
|
59 |
* Modificaci?n del estado de los controles del panel de brillo y contraste
|
60 |
*/
|
61 |
public void actionPerformed(RasterFilterStackManager stackManager, PropertiesRasterDialog propsDialog, FLyrRaster fLayer) { |
62 |
EnhancedBrightnessContrastPanel bcPanel = (EnhancedBrightnessContrastPanel)((FilterRasterDialogPanel)propsDialog.getContentPane()).getPanelByClassName("EnhancedBrightnessContrastPanel");
|
63 |
bcPanel.setPropertiesDialog(propsDialog); |
64 |
|
65 |
if(stackManager.isActive(stackManager.getTypeFilter("brightness"))){ |
66 |
bcPanel.getCBrightC().setSelected(true);
|
67 |
bcPanel.setBCControlEnabled(true);
|
68 |
|
69 |
RasterFilter bright = stackManager.getFilter("brightness");
|
70 |
|
71 |
if(bright.getParam("incrBrillo") != null){ |
72 |
int incr = ((Integer)bright.getParam("incrBrillo")).intValue(); |
73 |
bcPanel.getLabelSliderText().setSliderValue(incr); |
74 |
bcPanel.getLabelSliderText().setTextValue(String.valueOf(incr));
|
75 |
} |
76 |
} |
77 |
|
78 |
if(stackManager.isActive(stackManager.getTypeFilter("contrast"))){ |
79 |
bcPanel.getCBrightC().setSelected(true);
|
80 |
bcPanel.setBCControlEnabled(true);
|
81 |
|
82 |
RasterFilter cont = stackManager.getFilter("contrast");
|
83 |
|
84 |
if(cont.getParam("incrContraste") != null){ |
85 |
int incr = ((Integer)cont.getParam("incrContraste")).intValue(); |
86 |
bcPanel.getLabelSliderText1().setSliderValue(incr); |
87 |
bcPanel.getLabelSliderText1().setTextValue(String.valueOf(incr));
|
88 |
} |
89 |
} |
90 |
|
91 |
if(stackManager.isActive(stackManager.getTypeFilter("enhanced"))){ |
92 |
bcPanel.getCEnhanced().setSelected(true);
|
93 |
bcPanel.setEControlEnabled(true);
|
94 |
|
95 |
RasterFilter enhan = stackManager.getFilter("enhanced");
|
96 |
RasterFilter tail = stackManager.getFilter("tail");
|
97 |
|
98 |
|
99 |
boolean rem = ((Boolean)enhan.getParam("remove")).booleanValue(); |
100 |
bcPanel.getJCheckBox().setSelected(rem); |
101 |
|
102 |
if(stackManager.isActive(stackManager.getTypeFilter("tail"))){ |
103 |
double percent = (stackManager.getStackStats().tailPercent)*100; |
104 |
bcPanel.getCheckSliderText().setTextValue(String.valueOf(percent));
|
105 |
bcPanel.getCheckSliderText().setSliderValue((int)percent);
|
106 |
bcPanel.getCheckSliderText().setSelected(true);
|
107 |
bcPanel.getCheckSliderText().setControlEnabled(true);
|
108 |
boolean remove = ((Boolean)tail.getParam("remove")).booleanValue(); |
109 |
if((remove == true) || (rem == true)) |
110 |
bcPanel.getJCheckBox().setSelected(true);
|
111 |
else
|
112 |
bcPanel.getJCheckBox().setSelected(false);
|
113 |
|
114 |
} |
115 |
|
116 |
|
117 |
} |
118 |
} |
119 |
/**
|
120 |
* A?ade el panel al cuadro de dialogo de propiedades de raster.
|
121 |
*/
|
122 |
public void addTabPanel(FLyrRasterAdjustPropertiesTocMenuEntry menu) { |
123 |
if(panel == null) |
124 |
panel = new EnhancedBrightnessContrastPanel();
|
125 |
menu.getPropertiesDialog().addTab(PluginServices.getText(this, "realces"), panel); |
126 |
|
127 |
} |
128 |
/**
|
129 |
* Devuelve el gestor de la pila de filtros de este panel.
|
130 |
*/
|
131 |
public IStackManager getStackManager() {
|
132 |
return this.bcManager; |
133 |
} |
134 |
|
135 |
/**
|
136 |
* Asigna el gestor de pila de filtros generico al gestor de pila de brillo, contraste y realce.
|
137 |
*/
|
138 |
public void setStackManager(RasterFilterStackManager stackManager) { |
139 |
panel = new EnhancedBrightnessContrastPanel();
|
140 |
bcManager = (BrightnessContrastStackManager)stackManager.getManagerByClass(BrightnessContrastStackManager.class); |
141 |
panel.setBrightnessContrastStackManager(bcManager); |
142 |
} |
143 |
|
144 |
} |