root / tags / v1_0_1_RELEASE / extensions / extRasterTools / src / org / gvsig / rasterTools / brightnessContrast / toc / BrightnessContrastTocMenuEntry.java @ 9531
History | View | Annotate | Download (5.49 KB)
1 | 5497 | maquerol | /* 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 | 5159 | nacho | package org.gvsig.rasterTools.brightnessContrast.toc; |
21 | |||
22 | 5982 | nacho | import org.cresques.filter.IStackManager; |
23 | import org.cresques.filter.RasterFilter; |
||
24 | import org.cresques.filter.RasterFilterStackManager; |
||
25 | 9056 | nacho | import org.cresques.ui.filter.FilterRasterDialogPanel; |
26 | 5159 | nacho | import org.gvsig.rasterTools.brightnessContrast.filter.BrightnessContrastStackManager; |
27 | import org.gvsig.rasterTools.brightnessContrast.ui.EnhancedBrightnessContrastPanel; |
||
28 | |||
29 | 5497 | maquerol | import com.iver.andami.PluginServices; |
30 | 5159 | nacho | import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
31 | 6138 | jmvivo | import com.iver.cit.gvsig.gui.panels.IRasterPropertiesRegistrable; |
32 | import com.iver.cit.gvsig.gui.panels.PropertiesRasterDialog; |
||
33 | 8765 | jjdelcerro | import com.iver.cit.gvsig.project.documents.view.toc.gui.FLyrRasterAdjustPropertiesTocMenuEntry; |
34 | 5159 | nacho | |
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 | 5358 | maquerol | EnhancedBrightnessContrastPanel panel = null;
|
48 | BrightnessContrastStackManager bcManager = null;
|
||
49 | 5159 | nacho | |
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 | 5353 | nacho | EnhancedBrightnessContrastPanel bcPanel = (EnhancedBrightnessContrastPanel)((FilterRasterDialogPanel)propsDialog.getContentPane()).getPanelByClassName("EnhancedBrightnessContrastPanel");
|
63 | bcPanel.setPropertiesDialog(propsDialog); |
||
64 | 5358 | maquerol | |
65 | 5159 | nacho | 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 | 5247 | nacho | bcPanel.getLabelSliderText().setTextValue(String.valueOf(incr));
|
75 | 5159 | nacho | } |
76 | } |
||
77 | |||
78 | 5358 | maquerol | if(stackManager.isActive(stackManager.getTypeFilter("contrast"))){ |
79 | 5159 | nacho | 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 | 5247 | nacho | bcPanel.getLabelSliderText1().setTextValue(String.valueOf(incr));
|
88 | 5159 | nacho | } |
89 | } |
||
90 | |||
91 | 5247 | nacho | 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 | 5159 | nacho | } |
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 | 5497 | maquerol | menu.getPropertiesDialog().addTab(PluginServices.getText(this, "realces"), panel); |
126 | 5159 | nacho | |
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 | 5358 | maquerol | * Asigna el gestor de pila de filtros generico al gestor de pila de brillo, contraste y realce.
|
137 | 5159 | nacho | */
|
138 | public void setStackManager(RasterFilterStackManager stackManager) { |
||
139 | panel = new EnhancedBrightnessContrastPanel();
|
||
140 | bcManager = (BrightnessContrastStackManager)stackManager.getManagerByClass(BrightnessContrastStackManager.class); |
||
141 | panel.setBrightnessContrastStackManager(bcManager); |
||
142 | } |
||
143 | |||
144 | } |