svn-gvsig-desktop / tags / v1_0_RELEASE / extensions / extWMS / src / com / iver / cit / gvsig / gui / toc / WMSRasterPropsTocMenuEntry.java @ 9167
History | View | Annotate | Download (9.1 KB)
1 | 3746 | jaume | /* 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 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | package com.iver.cit.gvsig.gui.toc; |
||
42 | |||
43 | import java.awt.event.ActionEvent; |
||
44 | 4222 | jaume | import java.util.ArrayList; |
45 | 3746 | jaume | |
46 | import javax.swing.JMenuItem; |
||
47 | |||
48 | 5981 | nacho | import org.cresques.filter.RasterFilter; |
49 | import org.cresques.filter.RasterFilterStackManager; |
||
50 | 3746 | jaume | import org.cresques.io.GeoRasterFile; |
51 | import org.cresques.px.PxRaster; |
||
52 | 5534 | nacho | import org.cresques.ui.BrightnessContrast.EnhancedBrightnessContrastPanel; |
53 | 9056 | nacho | import org.cresques.ui.filter.FilterRasterDialogPanel; |
54 | import org.cresques.ui.filter.RasterTransparencyPanel; |
||
55 | 3746 | jaume | import org.cresques.ui.raster.BandSetupPanel; |
56 | 6223 | maquerol | import org.cresques.ui.raster.InfoPanel; |
57 | 3746 | jaume | |
58 | import com.iver.andami.PluginServices; |
||
59 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
60 | 5534 | nacho | import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
61 | 3746 | jaume | import com.iver.cit.gvsig.fmap.layers.FLyrWMS; |
62 | import com.iver.cit.gvsig.gui.dialogs.WMSRasterPropsDialog; |
||
63 | 8765 | jjdelcerro | import com.iver.cit.gvsig.project.documents.view.toc.TocMenuEntry; |
64 | import com.iver.cit.gvsig.project.documents.view.toc.gui.FPopupMenu; |
||
65 | 3746 | jaume | |
66 | /**
|
||
67 | *
|
||
68 | * @author Nacho Brodin (brodin_ign@gva.es)
|
||
69 | */
|
||
70 | public class WMSRasterPropsTocMenuEntry extends TocMenuEntry { |
||
71 | private JMenuItem propsMenuItem; |
||
72 | FLayer lyr = null;
|
||
73 | private WMSRasterPropsDialog propsDialog = null; |
||
74 | private BandSetupPanel bandSetup = null; |
||
75 | |||
76 | public void initialize(FPopupMenu m) { |
||
77 | super.initialize(m);
|
||
78 | |||
79 | if (isTocItemBranch()) {
|
||
80 | lyr = getNodeLayer(); |
||
81 | // Opcciones para capas WCS
|
||
82 | if ((lyr instanceof FLyrWMS)) { |
||
83 | propsMenuItem = new JMenuItem(PluginServices.getText(this, "propiedades_raster")); |
||
84 | getMenu().add( propsMenuItem ); |
||
85 | propsMenuItem.setFont(FPopupMenu.theFont); |
||
86 | getMenu().setEnabled(true);
|
||
87 | //getMenu().addSeparator();
|
||
88 | //Cambio color
|
||
89 | propsMenuItem.addActionListener(this);
|
||
90 | } |
||
91 | } |
||
92 | } |
||
93 | 4222 | jaume | |
94 | /**
|
||
95 | * Selecciona las bandas activas en el panel de bandas a partir
|
||
96 | * del los filtros contenidos en el FilterStack
|
||
97 | * @param stackManager RasterFilterStackManager
|
||
98 | * @param posR posici?n de la banda R en el selector
|
||
99 | * @param posG posici?n de la banda G en el selector
|
||
100 | * @param posB posici?n de la banda B en el selector
|
||
101 | */
|
||
102 | private void bandSelector(RasterFilterStackManager stackManager, int posR, int posG, int posB){ |
||
103 | ArrayList stackList = stackManager.getStringsFromStack();
|
||
104 | String hideBands = null; |
||
105 | for(int i=0;i<stackList.size();i++){ |
||
106 | if(((String)stackList.get(i)).startsWith("filter.removebands.bands")) |
||
107 | hideBands = stackManager.getValue((String)stackList.get(i));
|
||
108 | } |
||
109 | |||
110 | //Selecci?n de 1, 2 o 3 bandas para visualizar
|
||
111 | if(hideBands != null){ |
||
112 | int pos = 2; |
||
113 | if(hideBands.length() == 1) |
||
114 | pos = 1;
|
||
115 | else if(hideBands.length() == 2) |
||
116 | pos = 0;
|
||
117 | bandSetup.getFileList().getJComboBox().setSelectedIndex(pos); |
||
118 | |||
119 | //Reseteamos los controles de la tabla
|
||
120 | |||
121 | for(int i=0;i<bandSetup.getRGBTable().getModel().getRowCount();i++) |
||
122 | for(int j=0;j<3;j++) |
||
123 | bandSetup.getRGBTable().getModel().setValueAt(new Boolean(false), i, j); |
||
124 | |||
125 | if(hideBands.equals("GB") || hideBands.equals("G") || hideBands.equals("B") ) |
||
126 | bandSetup.getRGBTable().getModel().setValueAt(new Boolean(true), posR, 0); |
||
127 | |||
128 | if(hideBands.equals("RB") || hideBands.equals("R") || hideBands.equals("B") ) |
||
129 | bandSetup.getRGBTable().getModel().setValueAt(new Boolean(true), posG, 1); |
||
130 | |||
131 | if(hideBands.equals("RG") || hideBands.equals("R") || hideBands.equals("G") ) |
||
132 | bandSetup.getRGBTable().getModel().setValueAt(new Boolean(true), posB, 2); |
||
133 | } |
||
134 | } |
||
135 | |||
136 | 3746 | jaume | /* (non-Javadoc)
|
137 | * @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
|
||
138 | */
|
||
139 | public void actionPerformed(ActionEvent e) { |
||
140 | lyr = getNodeLayer(); |
||
141 | |||
142 | if(lyr instanceof FLyrWMS && ((FLyrWMS)lyr).getPxRaster()!=null){ |
||
143 | RasterFilterStackManager stackManager = null;
|
||
144 | |||
145 | FLyrWMS layer = (FLyrWMS)lyr; |
||
146 | |||
147 | stackManager = new RasterFilterStackManager(layer.getFilterStack());
|
||
148 | |||
149 | 4378 | nacho | propsDialog = new WMSRasterPropsDialog(layer, stackManager.getTransparencyRGB());
|
150 | 3746 | jaume | |
151 | int alpha = layer.getPxRaster().getAlpha();
|
||
152 | |||
153 | 4578 | nacho | bandSetup = (BandSetupPanel)((FilterRasterDialogPanel)propsDialog.getContentPane()).getPanelByClassName("BandSetupPanel");
|
154 | 3746 | jaume | GeoRasterFile[] files = layer.getPxRaster().getFiles();
|
155 | bandSetup.addFiles(files); |
||
156 | for(int i=0; i< files.length;i++) |
||
157 | propsDialog.addNumBands(files[i].getBandCount()); |
||
158 | |||
159 | PxRaster px = layer.getPxRaster(); |
||
160 | int posR = 0, posG = 0, posB = 0; |
||
161 | |||
162 | for(int i=0;i<px.getPosFile(GeoRasterFile.RED_BAND);i++) |
||
163 | posR += files[i].getBandCount(); |
||
164 | posR += px.getBand(GeoRasterFile.RED_BAND); |
||
165 | |||
166 | for(int i=0;i<px.getPosFile(GeoRasterFile.GREEN_BAND);i++) |
||
167 | posG += files[i].getBandCount(); |
||
168 | posG += px.getBand(GeoRasterFile.GREEN_BAND); |
||
169 | |||
170 | for(int i=0;i<px.getPosFile(GeoRasterFile.BLUE_BAND);i++) |
||
171 | posB += files[i].getBandCount(); |
||
172 | posB += px.getBand(GeoRasterFile.BLUE_BAND); |
||
173 | |||
174 | |||
175 | bandSetup.assignBand(posR, GeoRasterFile.RED_BAND); |
||
176 | bandSetup.assignBand(posG, GeoRasterFile.GREEN_BAND); |
||
177 | bandSetup.assignBand(posB, GeoRasterFile.BLUE_BAND); |
||
178 | 6223 | maquerol | |
179 | InfoPanel pInfo = (InfoPanel)this.propsDialog.getPanelByClassName("InfoPanel"); |
||
180 | pInfo.setBands(posR, posG, posB); |
||
181 | pInfo.addFiles(files); |
||
182 | 3746 | jaume | |
183 | //Asignaci?n del alpha actual de la imagen al dialogo
|
||
184 | 4578 | nacho | RasterTransparencyPanel rasterTrans = (RasterTransparencyPanel)((FilterRasterDialogPanel)propsDialog.getContentPane()).getPanelByClassName("RasterTransparencyPanel");
|
185 | 3746 | jaume | rasterTrans.setOpacity(alpha); |
186 | |||
187 | propsDialog.setRasterFilterStackManager(stackManager); |
||
188 | 4222 | jaume | bandSelector(stackManager, posR, posG, posB); |
189 | 3746 | jaume | propsDialog.readStat(); |
190 | 5534 | nacho | actionPerformed(stackManager, propsDialog, null);
|
191 | 3746 | jaume | |
192 | 6880 | cesar | PluginServices.getMDIManager().addWindow(propsDialog); |
193 | 3746 | jaume | } |
194 | } |
||
195 | 5534 | nacho | |
196 | /**
|
||
197 | * Modificaci?n del estado de los controles del panel de brillo y contraste
|
||
198 | */
|
||
199 | public void actionPerformed(RasterFilterStackManager stackManager, WMSRasterPropsDialog propsDialog, FLyrRaster fLayer) { |
||
200 | EnhancedBrightnessContrastPanel bcPanel = (EnhancedBrightnessContrastPanel)((FilterRasterDialogPanel)propsDialog.getContentPane()).getPanelByClassName("EnhancedBrightnessContrastPanel");
|
||
201 | //bcPanel.setPropertiesDialog(propsDialog);
|
||
202 | |||
203 | if(stackManager.isActive(stackManager.getTypeFilter("brightness"))){ |
||
204 | bcPanel.getCBrightC().setSelected(true);
|
||
205 | bcPanel.setBCControlEnabled(true);
|
||
206 | |||
207 | RasterFilter bright = stackManager.getFilter("brightness");
|
||
208 | |||
209 | if(bright.getParam("incrBrillo") != null){ |
||
210 | int incr = ((Integer)bright.getParam("incrBrillo")).intValue(); |
||
211 | bcPanel.getLabelSliderText().setSliderValue(incr); |
||
212 | bcPanel.getLabelSliderText().setTextValue(String.valueOf(incr));
|
||
213 | } |
||
214 | } |
||
215 | |||
216 | if(stackManager.isActive(stackManager.getTypeFilter("contrast"))){ |
||
217 | bcPanel.getCBrightC().setSelected(true);
|
||
218 | bcPanel.setBCControlEnabled(true);
|
||
219 | |||
220 | RasterFilter cont = stackManager.getFilter("contrast");
|
||
221 | |||
222 | if(cont.getParam("incrContraste") != null){ |
||
223 | int incr = ((Integer)cont.getParam("incrContraste")).intValue(); |
||
224 | bcPanel.getLabelSliderText1().setSliderValue(incr); |
||
225 | bcPanel.getLabelSliderText1().setTextValue(String.valueOf(incr));
|
||
226 | } |
||
227 | } |
||
228 | |||
229 | if(stackManager.isActive(stackManager.getTypeFilter("enhanced"))){ |
||
230 | bcPanel.getCEnhanced().setSelected(true);
|
||
231 | bcPanel.setEControlEnabled(true);
|
||
232 | |||
233 | RasterFilter enhan = stackManager.getFilter("enhanced");
|
||
234 | RasterFilter tail = stackManager.getFilter("tail");
|
||
235 | |||
236 | |||
237 | boolean rem = ((Boolean)enhan.getParam("remove")).booleanValue(); |
||
238 | bcPanel.getJCheckBox().setSelected(rem); |
||
239 | |||
240 | if(stackManager.isActive(stackManager.getTypeFilter("tail"))){ |
||
241 | double percent = (stackManager.getStackStats().tailPercent)*100; |
||
242 | bcPanel.getCheckSliderText().setTextValue(String.valueOf(percent));
|
||
243 | bcPanel.getCheckSliderText().setSliderValue((int)percent);
|
||
244 | bcPanel.getCheckSliderText().setSelected(true);
|
||
245 | bcPanel.getCheckSliderText().setControlEnabled(true);
|
||
246 | boolean remove = ((Boolean)tail.getParam("remove")).booleanValue(); |
||
247 | if((remove == true) || (rem == true)) |
||
248 | bcPanel.getJCheckBox().setSelected(true);
|
||
249 | else
|
||
250 | bcPanel.getJCheckBox().setSelected(false);
|
||
251 | |||
252 | } |
||
253 | } |
||
254 | } |
||
255 | 3746 | jaume | } |