svn-gvsig-desktop / tags / v1_0_2_Build_905 / extensions / extWMS / src / com / iver / cit / gvsig / gui / dialogs / WMSRasterPropsDialog.java @ 10767
History | View | Annotate | Download (30.5 KB)
1 |
/*
|
---|---|
2 |
* Creado el 7-marzo-2005
|
3 |
*/
|
4 |
package com.iver.cit.gvsig.gui.dialogs; |
5 |
|
6 |
import java.awt.Container; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.awt.event.KeyEvent; |
10 |
import java.awt.event.KeyListener; |
11 |
import java.awt.event.MouseEvent; |
12 |
import java.awt.event.MouseListener; |
13 |
import java.awt.geom.Rectangle2D; |
14 |
import java.io.File; |
15 |
import java.util.ArrayList; |
16 |
import java.util.Vector; |
17 |
|
18 |
import javax.swing.JFileChooser; |
19 |
import javax.swing.JOptionPane; |
20 |
import javax.swing.JPanel; |
21 |
import javax.swing.filechooser.FileFilter; |
22 |
|
23 |
import org.cresques.cts.IProjection; |
24 |
import org.cresques.filter.RasterFilterStackManager; |
25 |
import org.cresques.filter.enhancement.BrightnessContrastStackManager; |
26 |
import org.cresques.io.GeoRasterFile; |
27 |
import org.cresques.px.Extent; |
28 |
import org.cresques.px.PxRaster; |
29 |
import org.cresques.ui.BrightnessContrast.EnhancedBrightnessContrastPanel; |
30 |
import org.cresques.ui.filter.FilterRasterDialogPanel; |
31 |
import org.cresques.ui.filter.RasterTransparencyPanel; |
32 |
import org.cresques.ui.raster.BandSetupPanel; |
33 |
import org.cresques.ui.raster.InfoPanel; |
34 |
|
35 |
import com.hardcode.driverManager.Driver; |
36 |
import com.hardcode.driverManager.DriverLoadException; |
37 |
import com.iver.andami.PluginServices; |
38 |
import com.iver.andami.messages.NotificationManager; |
39 |
import com.iver.andami.ui.mdiManager.IWindow; |
40 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
41 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
42 |
import com.iver.cit.gvsig.fmap.layers.FLyrWMS; |
43 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
44 |
import com.iver.cit.gvsig.fmap.layers.StatusLayerRaster; |
45 |
|
46 |
/**
|
47 |
* <P>
|
48 |
* Dialog for the properties of a WMS layer. It manages the avants and aplies
|
49 |
* filters to the raster through the filter stack manager according to the user's
|
50 |
* selection. This dialog contains some panels.
|
51 |
* </P>
|
52 |
* <UL>
|
53 |
* <LI>Propierties</LI>
|
54 |
* <LI>Band selection</LI>
|
55 |
* <LI>Transparency</LI>
|
56 |
* <LI>Enhancement</LI>
|
57 |
* </UL>
|
58 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
59 |
*/
|
60 |
public class WMSRasterPropsDialog extends FilterRasterDialogPanel implements IWindow, MouseListener, KeyListener, ActionListener{ |
61 |
|
62 |
private FilterRasterDialogPanel contentPane = null; |
63 |
private JPanel propPanel = null; |
64 |
private IProjection currentProjection = null; |
65 |
private FLyrWMS fLayer = null; |
66 |
private static final int nprops = 13; |
67 |
private Object[][] props = null; |
68 |
private RasterFilterStackManager stackManager = null; |
69 |
private Status status = null; |
70 |
private StatusLayerRaster rasterStatus = null; |
71 |
private JFileChooser fileChooser = null; |
72 |
private String lastPath = new String("./"); |
73 |
private PxRaster px = null; |
74 |
private GeoRasterFile grf = null; |
75 |
|
76 |
/**
|
77 |
* Class that holds the dialog state and restores the initial state if it
|
78 |
* is cancelled.
|
79 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
80 |
*/
|
81 |
class Status{ |
82 |
public String inicAlpha; |
83 |
public int bandR; |
84 |
public int bandG; |
85 |
public int bandB; |
86 |
private ArrayList filters = new ArrayList(); |
87 |
|
88 |
public Status(String alpha, int bandR, int bandG, int bandB){ |
89 |
this.inicAlpha = alpha;
|
90 |
this.bandR = bandR;
|
91 |
this.bandG = bandG;
|
92 |
this.bandB = bandB;
|
93 |
filters = stackManager.getStringsFromStack(); |
94 |
} |
95 |
|
96 |
/**
|
97 |
* Restaura el Estado salvado
|
98 |
* @param status Estado
|
99 |
*/
|
100 |
public void restoreStatus(WMSRasterPropsDialog props){ |
101 |
//Devolvemos la pila de filtros al estado inicial
|
102 |
/*if(stackManager != null)
|
103 |
stackManager.deleteTempFilters();*/
|
104 |
|
105 |
//Devolvemos el alpha al estado inicial
|
106 |
int opac = Integer.parseInt(status.inicAlpha); |
107 |
opac = (int)((opac*255)/100); |
108 |
fLayer.setTransparency(255-opac);
|
109 |
|
110 |
if (fLayer != null) { |
111 |
fLayer.setBandR(bandR); |
112 |
fLayer.setBandG(bandG); |
113 |
fLayer.setBandB(bandB); |
114 |
} |
115 |
|
116 |
//Restauramos los filtros
|
117 |
if(filters!=null) |
118 |
stackManager.createStackFromStrings(filters); |
119 |
|
120 |
fLayer.getMapContext().invalidate(); |
121 |
|
122 |
} |
123 |
} |
124 |
|
125 |
public class DriverFileFilter extends FileFilter{ |
126 |
|
127 |
private Driver driver; |
128 |
|
129 |
public DriverFileFilter(String driverName) throws DriverLoadException{ |
130 |
driver = LayerFactory.getDM().getDriver(driverName); |
131 |
} |
132 |
|
133 |
/**
|
134 |
* @see javax.swing.filechooser.FileFilter#accept(java.io.File)
|
135 |
*/
|
136 |
public boolean accept(File f) { |
137 |
if (f.isDirectory()) return true; |
138 |
if (driver instanceof RasterDriver){ |
139 |
return ((RasterDriver) driver).fileAccepted(f);
|
140 |
}else{
|
141 |
throw new RuntimeException("Tipo no reconocido"); |
142 |
} |
143 |
} |
144 |
|
145 |
/**
|
146 |
* @see javax.swing.filechooser.FileFilter#getDescription()
|
147 |
*/
|
148 |
public String getDescription() { |
149 |
return ((Driver) driver).getName(); |
150 |
} |
151 |
} |
152 |
|
153 |
/**
|
154 |
* Dialog window constructor.
|
155 |
*
|
156 |
* @param app
|
157 |
*/
|
158 |
public WMSRasterPropsDialog(FLyrWMS layer, ArrayList ranges){ |
159 |
super();
|
160 |
fLayer = layer; |
161 |
this.px = layer.getPxRaster();
|
162 |
this.grf = layer.getGeoRasterFile();
|
163 |
if(fLayer.getStatus()==null){ |
164 |
rasterStatus = new StatusLayerRaster();
|
165 |
fLayer.setStatus(rasterStatus); |
166 |
}else
|
167 |
rasterStatus = (StatusLayerRaster)fLayer.getStatus(); |
168 |
init(); |
169 |
this.setRanges(ranges);
|
170 |
FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
|
171 |
BandSetupPanel bandSetup = (BandSetupPanel)fr.getPanelByClassName("BandSetupPanel");
|
172 |
bandSetup.getFileList().getJButtonAdd().setEnabled(false);
|
173 |
bandSetup.getFileList().getJButtonRemove().setEnabled(false);
|
174 |
this.setTranslation();
|
175 |
|
176 |
EnhancedBrightnessContrastPanel ep = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
177 |
ep.lstBrightness.getJSlider().addMouseListener(this);
|
178 |
ep.lstContrast.getJSlider().addMouseListener(this);
|
179 |
ep.getCheckSliderText().getJTextField().addKeyListener(this);
|
180 |
ep.getLabelSliderText().getJTextField().addActionListener(this);
|
181 |
ep.getLabelSliderText1().getJTextField().addActionListener(this);
|
182 |
} |
183 |
|
184 |
/**
|
185 |
* Asigna los textos a los paneles
|
186 |
*/
|
187 |
private void setTranslation(){ |
188 |
FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
|
189 |
BandSetupPanel bandSetup = (BandSetupPanel)fr.getPanelByClassName("BandSetupPanel");
|
190 |
bandSetup.getFileList().getJButtonAdd().setText(PluginServices.getText(this,"add")); |
191 |
bandSetup.getFileList().getJButtonRemove().setText(PluginServices.getText(this,"remove")); |
192 |
bandSetup.getFileList().lbandasVisibles.setText(PluginServices.getText(this,"bands")); |
193 |
|
194 |
RasterTransparencyPanel tpan = (RasterTransparencyPanel)fr.getPanelByClassName("RasterTransparencyPanel");
|
195 |
|
196 |
tpan.getTransparencyCheck().setText(PluginServices.getText(this,"transparencia")); |
197 |
tpan.getOpacityCheck().setText(PluginServices.getText(this,"opacidad")); |
198 |
|
199 |
EnhancedBrightnessContrastPanel ep = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
200 |
|
201 |
ep.lLineal.setText(PluginServices.getText(this, "lineal_directo")); |
202 |
ep.lRemove.setText(PluginServices.getText(this, "eliminar_extremos")); |
203 |
ep.cstEnhanced.setName(PluginServices.getText(this, "recorte_colas")+" ( % )"); |
204 |
ep.lBrightC.setText(PluginServices.getText(this, "brillo_y_contraste")); |
205 |
ep.lstBrightness.setName(PluginServices.getText(this, "brillo")); |
206 |
ep.lstContrast.setName(PluginServices.getText(this, "contraste")); |
207 |
ep.lpreview.setText(PluginServices.getText(this, "previsualizacion")); |
208 |
ep.getPBrightCont().setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1), (PluginServices.getText(this, "brillo_y_contraste")), javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.black)); |
209 |
ep.getPEnhanced().setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1), (PluginServices.getText(this, "realce")), javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.black)); |
210 |
|
211 |
|
212 |
InfoPanel ip = (InfoPanel)super.getPanelByClassName("InfoPanel"); |
213 |
|
214 |
ip.cabInfo = new String(PluginServices.getText(this, "Informacion")); |
215 |
ip.cabCoord = new String(PluginServices.getText(this, "coor_geograficas")); |
216 |
ip.cabProy = new String(PluginServices.getText(this, "Proyecciones")); |
217 |
ip.cabOrig = new String(PluginServices.getText(this, "origen_de_datos")); |
218 |
ip.cabMeta = new String(PluginServices.getText(this, "metadatos")); |
219 |
ip.refresh(); |
220 |
|
221 |
|
222 |
//Recorremos los Tab y traducimos el nombre
|
223 |
for(int i=0;i<this.getTab().getTabCount();i++){ |
224 |
if(this.getTab().getTitleAt(i).equals("Info")) |
225 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"info")); |
226 |
if(this.getTab().getTitleAt(i).equals("Transparencia")) |
227 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"transparencia")); |
228 |
if(this.getTab().getTitleAt(i).equals("Bands")) |
229 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"bands")); |
230 |
if(this.getTab().getTitleAt(i).equals("Realce")) |
231 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"realce")); |
232 |
} |
233 |
|
234 |
this.getAcceptButton().setText(PluginServices.getText(this,"ok")); |
235 |
this.getApplyButton().setText(PluginServices.getText(this,"apply")); |
236 |
this.getCancelButton().setText(PluginServices.getText(this,"cancel")); |
237 |
} |
238 |
|
239 |
/**
|
240 |
* Assigns a FLayerRaster
|
241 |
* @param layer capa a asignar
|
242 |
*/
|
243 |
public void setFLyrWMS(FLyrWMS layer){ |
244 |
fLayer = layer; |
245 |
} |
246 |
|
247 |
/**
|
248 |
* Dialog window constructor.
|
249 |
*/
|
250 |
public WMSRasterPropsDialog() {
|
251 |
init(); |
252 |
} |
253 |
|
254 |
/**
|
255 |
* Loads the info panel data.
|
256 |
*/
|
257 |
private void loadInfoData(){ |
258 |
Rectangle2D r = fLayer.getFullExtent();
|
259 |
if(fLayer != null){ |
260 |
props = new Object[nprops][2]; |
261 |
props[0][0] = new String(PluginServices.getText(this,"Fichero")+":"); |
262 |
props[0][1] = fLayer.getHost(); |
263 |
props[1][0] = new String(PluginServices.getText(this,"tamano")+":"); |
264 |
props[1][1] = ""; |
265 |
props[2][0] = new String(PluginServices.getText(this,"ancho_alto")+":"); |
266 |
props[2][1] = fLayer.getWidth()+" , "+fLayer.getHeight(); |
267 |
props[3][0] = new String(PluginServices.getText(this,"formato")+":"); |
268 |
props[3][1] = "WMS"; |
269 |
props[4][0] = new String(PluginServices.getText(this,"tipo_dato")+":"); |
270 |
String type = null; |
271 |
switch(grf.getDataType()){
|
272 |
case 0: type = new String("BYTE");break; |
273 |
case 1: type = new String("USHORT");break; |
274 |
case 2: type = new String("SHORT");break; |
275 |
case 3: type = new String("INT");break; |
276 |
case 4: type = new String("FLOAT");break; |
277 |
case 5: type = new String("DOUBLE");break; |
278 |
default: type = new String("UNDEFINED");break; |
279 |
} |
280 |
props[4][1] = type; |
281 |
props[4][0] = new String(PluginServices.getText(this, "georeferenciado")+":"); |
282 |
props[4][1] = new String(PluginServices.getText(this, "si")); |
283 |
props[5][0] = new String(PluginServices.getText(this,"num_bandas")+":"); |
284 |
props[5][1] = new String(String.valueOf(grf.getBandCount())); |
285 |
props[6][0] = new String(PluginServices.getText(this,"coor_geograficas")); |
286 |
props[7][0] = new String(PluginServices.getText(this,"xmin")+":"); |
287 |
props[7][1] = String.valueOf(fLayer.getMinX()); |
288 |
props[8][0] = new String(PluginServices.getText(this,"ymin")+":"); |
289 |
props[8][1] = String.valueOf(fLayer.getMinY()); |
290 |
props[9][0] = new String(PluginServices.getText(this,"xmax")+":"); |
291 |
props[9][1] = String.valueOf(fLayer.getMaxX()); |
292 |
props[10][0] = new String(PluginServices.getText(this,"ymax")+":"); |
293 |
props[10][1] = String.valueOf(fLayer.getMaxY()); |
294 |
|
295 |
double tamRealX = fLayer.getMaxX()-fLayer.getMinX();
|
296 |
double tamRealY = fLayer.getMaxY()-fLayer.getMinY();
|
297 |
double tamX = Math.round((tamRealX/fLayer.getWidth())*10000000); |
298 |
double tamY = Math.round((tamRealY/fLayer.getHeight())*10000000); |
299 |
|
300 |
String tamPixX = String.valueOf(tamX/10000000); |
301 |
String tamPixY = String.valueOf(tamY/10000000); |
302 |
|
303 |
props[11][0] = new String(PluginServices.getText(this, "tamPixX")); |
304 |
props[11][1] = tamPixX + " " + new String(PluginServices.getText(this, "m/pixel")); |
305 |
props[12][0] = new String(PluginServices.getText(this, "tamPixY")); |
306 |
props[12][1] = tamPixY + " " + new String(PluginServices.getText(this, "m/pixel")); |
307 |
|
308 |
}else{
|
309 |
props = new Object[1][2]; |
310 |
props[0][0] = new String("No props"); |
311 |
props[0][1] = new String("-"); |
312 |
} |
313 |
|
314 |
} |
315 |
|
316 |
/**
|
317 |
* A?ade bandas al contador de bandas del FilterRasterDialogPanel
|
318 |
* @param numBands N?mero de bandas a a?adir
|
319 |
*/
|
320 |
public void addNumBands(int numBands){ |
321 |
nbands += numBands; |
322 |
FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
|
323 |
RasterTransparencyPanel rasterTrans = (RasterTransparencyPanel)fr.getPanelByClassName("RasterTransparencyPanel");
|
324 |
if(rasterTrans != null && rasterTrans.getPTranspByPixel().isControlEnabled()) |
325 |
rasterTrans.setActiveTransparencyControl(true);
|
326 |
} |
327 |
|
328 |
/**
|
329 |
* Inits the jDialog
|
330 |
*/
|
331 |
public void init() { |
332 |
|
333 |
//this.setLayout(new FlowLayout());
|
334 |
|
335 |
setName("filterRaster");
|
336 |
|
337 |
this.loadInfoData();
|
338 |
super.init(props);
|
339 |
this.setTabVisible("Pansharpening", false); |
340 |
|
341 |
//this.add(getContentPane());
|
342 |
|
343 |
this.setSize(486, 360); |
344 |
|
345 |
//contentPane.getAcceptButton().setEnabled(false);
|
346 |
this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() { |
347 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
348 |
acceptButtonActionPerformed(evt); |
349 |
closeJDialog(); |
350 |
} |
351 |
}); |
352 |
this.getCancelButton().addActionListener(new java.awt.event.ActionListener() { |
353 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
354 |
cancelButtonActionPerformed(evt); |
355 |
closeJDialog(); |
356 |
} |
357 |
}); |
358 |
this.getApplyButton().addActionListener(new java.awt.event.ActionListener() { |
359 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
360 |
acceptButtonActionPerformed(evt); |
361 |
} |
362 |
}); |
363 |
BandSetupPanel bandSetup = (BandSetupPanel)((FilterRasterDialogPanel)this.getContentPane()).getPanelByClassName("BandSetupPanel"); |
364 |
bandSetup.getFileList().getJButtonAdd().addActionListener(new java.awt.event.ActionListener() {
|
365 |
public void actionPerformed(java.awt.event.ActionEvent evt){ |
366 |
addFileBand(evt); |
367 |
|
368 |
} |
369 |
}); |
370 |
bandSetup.getFileList().getJButtonRemove().addActionListener(new java.awt.event.ActionListener() {
|
371 |
public void actionPerformed(java.awt.event.ActionEvent evt){ |
372 |
delFileBand(evt); |
373 |
} |
374 |
}); |
375 |
|
376 |
|
377 |
} |
378 |
|
379 |
/**
|
380 |
* Saves the initial state to restore it if cancel.
|
381 |
*/
|
382 |
public void readStat(){ |
383 |
FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
|
384 |
RasterTransparencyPanel rasterTrans = (RasterTransparencyPanel)fr.getPanelByClassName("RasterTransparencyPanel");
|
385 |
status = new Status(rasterTrans.getOpacityText().getText(),
|
386 |
getAssignedBand(GeoRasterFile.RED_BAND), |
387 |
getAssignedBand(GeoRasterFile.GREEN_BAND), |
388 |
getAssignedBand(GeoRasterFile.BLUE_BAND) |
389 |
); |
390 |
} |
391 |
|
392 |
/**
|
393 |
* This method initializes jContentPane
|
394 |
*/
|
395 |
public Container getContentPane() { |
396 |
return this; |
397 |
} |
398 |
|
399 |
/**
|
400 |
* Sets a projection.
|
401 |
*
|
402 |
* @param prj
|
403 |
*/
|
404 |
public void setProjection(IProjection prj) { |
405 |
this.currentProjection = prj;
|
406 |
} |
407 |
|
408 |
|
409 |
|
410 |
public void closeJDialog() { |
411 |
PluginServices.getMDIManager().closeWindow(WMSRasterPropsDialog.this); |
412 |
} |
413 |
|
414 |
/**
|
415 |
* Sets the RasterFilterStackManager
|
416 |
* @param stackManager
|
417 |
*/
|
418 |
public void setRasterFilterStackManager(RasterFilterStackManager stackManager){ |
419 |
this.stackManager = stackManager;
|
420 |
stackManager.resetTempFilters(); |
421 |
} |
422 |
|
423 |
/**
|
424 |
*
|
425 |
* @param flag
|
426 |
* @return
|
427 |
*/
|
428 |
public int getAssignedBand(int flag) { |
429 |
BandSetupPanel bandSetup = (BandSetupPanel)((FilterRasterDialogPanel)this.getContentPane()).getPanelByClassName("BandSetupPanel"); |
430 |
return bandSetup.getAssignedBand(flag);
|
431 |
} |
432 |
|
433 |
/**
|
434 |
* Pressing OK with the bands panel selected makes its values to be
|
435 |
* processed.
|
436 |
*
|
437 |
* @return true if the bands panel was selected and the action is processed, false it
|
438 |
* was not selected.
|
439 |
*/
|
440 |
public boolean processBandPanel(){ |
441 |
fLayer.setBandR(getAssignedBand(GeoRasterFile.RED_BAND)); |
442 |
fLayer.setBandG(getAssignedBand(GeoRasterFile.GREEN_BAND)); |
443 |
fLayer.setBandB(getAssignedBand(GeoRasterFile.BLUE_BAND)); |
444 |
rasterStatus.bandR = getAssignedBand(GeoRasterFile.RED_BAND); |
445 |
rasterStatus.bandG = getAssignedBand(GeoRasterFile.GREEN_BAND); |
446 |
rasterStatus.bandB = getAssignedBand(GeoRasterFile.BLUE_BAND); |
447 |
|
448 |
//Comprobamos si hay alguna banda que no est? asignada y aplicamos el filtro
|
449 |
StringBuffer sb = new StringBuffer(); |
450 |
if(getAssignedBand(GeoRasterFile.RED_BAND) == -1) |
451 |
sb.append("R");
|
452 |
if(getAssignedBand(GeoRasterFile.GREEN_BAND) == -1) |
453 |
sb.append("G");
|
454 |
if(getAssignedBand(GeoRasterFile.BLUE_BAND) == -1) |
455 |
sb.append("B");
|
456 |
|
457 |
if(!sb.toString().equals("")) |
458 |
stackManager.addRemoveBands(sb.toString()); |
459 |
else
|
460 |
stackManager.removeFilter(stackManager.getTypeFilter("removebands"));
|
461 |
|
462 |
fLayer.getMapContext().invalidate(); |
463 |
|
464 |
InfoPanel pInfo = (InfoPanel)super.getPanelByClassName("InfoPanel"); |
465 |
pInfo.setBands(getAssignedBand(GeoRasterFile.RED_BAND),getAssignedBand(GeoRasterFile.GREEN_BAND),getAssignedBand(GeoRasterFile.BLUE_BAND)); |
466 |
|
467 |
return true; |
468 |
} |
469 |
|
470 |
/**
|
471 |
* Pressing OK with the transparency panel selected makes its values to be processed.
|
472 |
* @return true if the transparency panel was selected and the action is processed, false it
|
473 |
* was not selected.
|
474 |
*/
|
475 |
public boolean processTransparencyPanel(){ |
476 |
//OPACIDAD
|
477 |
RasterTransparencyPanel tpan = (RasterTransparencyPanel)((FilterRasterDialogPanel)this.getContentPane()).getPanelByClassName("RasterTransparencyPanel"); |
478 |
String sOpac = tpan.getOpacityText().getText();
|
479 |
if(!sOpac.equals("") && tpan.getOpacityCheck().isSelected()){ |
480 |
int opac = Integer.parseInt(sOpac); |
481 |
opac = (int)((opac*255)/100); |
482 |
px.setTransparency(true);
|
483 |
//px.setTransparency(255-opac);
|
484 |
fLayer.setTransparency(255-opac);
|
485 |
rasterStatus.transparency = 255-opac;
|
486 |
}else{
|
487 |
px.setTransparency(false);
|
488 |
fLayer.setTransparency(0);
|
489 |
rasterStatus.transparency = 0;
|
490 |
} |
491 |
|
492 |
//TRANSPARENCIA
|
493 |
if( tpan.getTransparencyCheck().isSelected()){
|
494 |
|
495 |
stackManager.addTransparencyFilter( tpan.getPTranspByPixel().getEntries(), |
496 |
0x10, //Transparencia |
497 |
0xff, //Color Transparencia R |
498 |
0xff, //Color Transparencia G |
499 |
0xff); //Color Transparencia B |
500 |
|
501 |
}else
|
502 |
px.filterStack.removeFilter(stackManager.getTypeFilter("transparency"));
|
503 |
|
504 |
fLayer.getMapContext().invalidate(); |
505 |
return true; |
506 |
} |
507 |
|
508 |
/**
|
509 |
* Pressing OK with the BrightnessContrastPanel selected makes its values to be processed.
|
510 |
* @return true if the BrightnessContrastPanel was selected and the action is processed, false it
|
511 |
* was not selected.
|
512 |
*/
|
513 |
private void processBrightnessContrastPanel(){ |
514 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
515 |
// Si est? activo el panel de brillo y contraste tomamos los valores y cargamos un filtro de
|
516 |
// brillo y contraste
|
517 |
|
518 |
BrightnessContrastStackManager bcStackManager = (BrightnessContrastStackManager)stackManager.getManagerByClass(BrightnessContrastStackManager.class); |
519 |
if(ebcPanel.getCBrightC().isSelected()){
|
520 |
int incrBrillo = (int)Math.round(Double.valueOf(ebcPanel.lstBrightness.getTextValue()).doubleValue()); |
521 |
int incrContraste = (int)Math.round(Double.valueOf(ebcPanel.lstContrast.getTextValue()).doubleValue()); |
522 |
bcStackManager.addBrightnessFilter(incrBrillo); |
523 |
bcStackManager.addContrastFilter(incrContraste); |
524 |
}else{
|
525 |
stackManager.removeFilter(bcStackManager.brightness); |
526 |
stackManager.removeFilter(bcStackManager.contrast); |
527 |
} |
528 |
fLayer.getMapContext().invalidate(); |
529 |
} |
530 |
|
531 |
/**
|
532 |
* Pulsar aceptar con el panel de realce seleccionado hace que se procesen los valores
|
533 |
* introducidos en este.
|
534 |
* @return true si estaba seleccionado el panel de realce y se ha procesado la
|
535 |
* acci?n y false si no lo estaba.
|
536 |
*/
|
537 |
public void processEnhancedPanel(){ |
538 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
539 |
|
540 |
//Filtro de realce lineal seleccionado
|
541 |
if(ebcPanel.getCEnhanced().isSelected()){
|
542 |
if((ebcPanel.getJCheckBox().isSelected()) && (!ebcPanel.getCheckSliderText().getJCheckBox().isSelected()))
|
543 |
stackManager.addEnhancedFilter(true);
|
544 |
else
|
545 |
stackManager.addEnhancedFilter(false);
|
546 |
|
547 |
//Recorte de colas seleccionado
|
548 |
if(ebcPanel.getCheckSliderText().getJCheckBox().isSelected()){
|
549 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
550 |
double recorte = Double.parseDouble(ebcPanel.getCheckSliderText().getTextValue())/100; |
551 |
if(ebcPanel.getJCheckBox().isSelected())
|
552 |
stackManager.addTailFilter(recorte, 0D, true); |
553 |
else
|
554 |
stackManager.addTailFilter(recorte, 0D, false); |
555 |
}else{
|
556 |
stackManager.removeFilter(stackManager.getTypeFilter("tail"));
|
557 |
stackManager.addComputeMinMaxFilter(); |
558 |
} |
559 |
|
560 |
} |
561 |
// Sin filtro lineal seleccionado
|
562 |
if(!ebcPanel.getCEnhanced().isSelected()){
|
563 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
564 |
stackManager.removeFilter(stackManager.getTypeFilter("tail"));
|
565 |
stackManager.removeFilter(stackManager.getTypeFilter("enhanced"));
|
566 |
} |
567 |
fLayer.getMapContext().invalidate(); |
568 |
} |
569 |
|
570 |
/**
|
571 |
* Pressing OK with the enhancement panel selected makes its values to be processed.
|
572 |
* @return true if the enhancement panel was selected and the action is processed, false it
|
573 |
* was not selected.
|
574 |
*/
|
575 |
/*public boolean processEnhancedPanel(){
|
576 |
//Filtro lineal seleccionado
|
577 |
EnhancedPanel ep = (EnhancedPanel)((FilterRasterDialogPanel)this.getContentPane()).getPanelByClassName("EnhancedPanel");
|
578 |
if( ep.getLinealDirectoRadioButton().isSelected()){
|
579 |
if( ep.getRemoveCheck().isSelected() &&
|
580 |
!ep.getTailCheck().isSelected())
|
581 |
stackManager.addEnhancedFilter(true);
|
582 |
else
|
583 |
stackManager.addEnhancedFilter(false);
|
584 |
|
585 |
//Recorte de colas seleccionado
|
586 |
if(ep.getTailCheck().isSelected()){
|
587 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
588 |
double recorte = Double.parseDouble(ep.getTailText().getText())/100;
|
589 |
if(ep.getRemoveCheck().isSelected())
|
590 |
stackManager.addTailFilter( recorte, 0D, true);
|
591 |
else
|
592 |
stackManager.addTailFilter( recorte, 0D, false);
|
593 |
}else{
|
594 |
stackManager.removeFilter(stackManager.getTypeFilter("tail"));
|
595 |
stackManager.addComputeMinMaxFilter();
|
596 |
}
|
597 |
}
|
598 |
|
599 |
//Sin filtro lineal seleccionado
|
600 |
if(ep.getSinRealceRadioButton().isSelected()){
|
601 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
602 |
stackManager.removeFilter(stackManager.getTypeFilter("tail"));
|
603 |
stackManager.removeFilter(stackManager.getTypeFilter("enhanced"));
|
604 |
}
|
605 |
fLayer.getFMap().invalidate();
|
606 |
|
607 |
return true;
|
608 |
}*/
|
609 |
|
610 |
/**
|
611 |
* Manages the action perfomed when Apply/OK is pressed or Apply at the raster
|
612 |
* properties control.
|
613 |
* @param e
|
614 |
*/
|
615 |
private void acceptButtonActionPerformed(ActionEvent e) { |
616 |
processBandPanel(); |
617 |
processTransparencyPanel(); |
618 |
processEnhancedPanel(); |
619 |
processBrightnessContrastPanel(); |
620 |
} |
621 |
|
622 |
/**
|
623 |
* Adds a band to the raster.
|
624 |
* @param e
|
625 |
*/
|
626 |
private void addFileBand(ActionEvent e){ |
627 |
String[] driverNames = null; |
628 |
String rasterDriver = null; |
629 |
|
630 |
//Creaci?n del dialogo para selecci?n de ficheros
|
631 |
|
632 |
fileChooser = new JFileChooser(lastPath); |
633 |
fileChooser.setMultiSelectionEnabled(true);
|
634 |
fileChooser.setAcceptAllFileFilterUsed(false);
|
635 |
try {
|
636 |
driverNames = LayerFactory.getDM().getDriverNames(); |
637 |
FileFilter defaultFileFilter = null, auxF; |
638 |
for (int i = 0; i < driverNames.length; i++) { |
639 |
|
640 |
if (driverNames[i].endsWith("gvSIG Image Driver")){ |
641 |
rasterDriver = driverNames[i]; |
642 |
auxF = new DriverFileFilter(driverNames[i]);
|
643 |
fileChooser.addChoosableFileFilter(auxF); |
644 |
defaultFileFilter = auxF; |
645 |
} |
646 |
} |
647 |
} catch (DriverLoadException e1) {
|
648 |
NotificationManager.addError("No se pudo acceder a los drivers", e1);
|
649 |
} |
650 |
int result = fileChooser.showOpenDialog(WMSRasterPropsDialog.this);
|
651 |
|
652 |
if(result == JFileChooser.APPROVE_OPTION){ |
653 |
File[] files = fileChooser.getSelectedFiles(); |
654 |
FileFilter filter = fileChooser.getFileFilter();
|
655 |
BandSetupPanel bandSetup = (BandSetupPanel)((FilterRasterDialogPanel)this.getContentPane()).getPanelByClassName("BandSetupPanel"); |
656 |
lastPath = files[0].getPath();
|
657 |
|
658 |
//Lo a?adimos a la capa si no esta
|
659 |
|
660 |
Vector v = new Vector(); |
661 |
for(int i=0;i<files.length;i++){ |
662 |
boolean exist = false; |
663 |
for(int j=0;j<px.getFiles().length;j++){ |
664 |
if(px.getFiles()[j].getName().endsWith(files[i].getName()))
|
665 |
exist = true;
|
666 |
} |
667 |
if(!exist){
|
668 |
try{
|
669 |
Rectangle2D extentOrigin = fLayer.getFullExtent();
|
670 |
|
671 |
Extent extentNewFile = GeoRasterFile.openFile(fLayer.getProjection(), files[i].getAbsolutePath()).getExtent(); |
672 |
|
673 |
//Comprobamos que el extent y tama?o del fichero a?adido sea igual al
|
674 |
//fichero original. Si no es as? no abrimos la capa y mostramos un aviso
|
675 |
|
676 |
double widthNewFile = (extentNewFile.getMax().getX()-extentNewFile.getMin().getX());
|
677 |
double heightNewFile = (extentNewFile.getMax().getY()-extentNewFile.getMin().getY());
|
678 |
|
679 |
if( (widthNewFile-extentOrigin.getWidth()) > 1.0 || |
680 |
(widthNewFile-extentOrigin.getWidth()) < -1.0 ||
|
681 |
(heightNewFile-extentOrigin.getHeight()) > 1.0 ||
|
682 |
(heightNewFile-extentOrigin.getHeight()) < -1.0){
|
683 |
JOptionPane.showMessageDialog( null, |
684 |
PluginServices.getText(this, "extents_no_coincidentes"), |
685 |
"",
|
686 |
JOptionPane.ERROR_MESSAGE);
|
687 |
return;
|
688 |
} |
689 |
|
690 |
if( (extentNewFile.getMax().getX()-extentNewFile.getMin().getX())!=extentOrigin.getWidth() ||
|
691 |
(extentNewFile.getMax().getY()-extentNewFile.getMin().getY())!=extentOrigin.getHeight() ){ |
692 |
JOptionPane.showMessageDialog(null, |
693 |
PluginServices.getText(this, "extents_no_coincidentes"), "", JOptionPane.ERROR_MESSAGE); |
694 |
return;
|
695 |
} |
696 |
|
697 |
}catch(Exception exc){ |
698 |
exc.printStackTrace(); |
699 |
} |
700 |
|
701 |
//Lo a?adimos a la capa
|
702 |
px.addFile(files[i].getAbsolutePath()); |
703 |
|
704 |
}else{
|
705 |
JOptionPane.showMessageDialog(null, |
706 |
PluginServices.getText(this, "fichero_existe")+" "+files[i].getAbsolutePath(), "", JOptionPane.ERROR_MESSAGE); |
707 |
} |
708 |
} |
709 |
|
710 |
//A?adimos los georasterfile a la tabla del Panel
|
711 |
|
712 |
v = new Vector(); |
713 |
Vector vInfo = new Vector(); |
714 |
for(int i=0;i<px.getFiles().length;i++){ |
715 |
boolean exist = false; |
716 |
for(int j=0;j<bandSetup.getNBands();j++){ |
717 |
if(px.getFiles()[i].getName().endsWith(bandSetup.getBandName(j)))
|
718 |
exist = true;
|
719 |
} |
720 |
if(!exist){
|
721 |
v.add(px.getFiles()[i]); |
722 |
vInfo.add(px.getFiles()[i]); |
723 |
} |
724 |
} |
725 |
|
726 |
GeoRasterFile[] grf = new GeoRasterFile[v.size()]; |
727 |
for(int i=0;i<grf.length;i++){ |
728 |
grf[i] = (GeoRasterFile)v.get(i); |
729 |
} |
730 |
GeoRasterFile[] infoGrf = new GeoRasterFile[vInfo.size()]; |
731 |
for(int i = 0; i<infoGrf.length ; i++){ |
732 |
infoGrf[i] = (GeoRasterFile)vInfo.get(i); |
733 |
} |
734 |
bandSetup.addFiles(grf); |
735 |
this.addInfoFiles(infoGrf);
|
736 |
} |
737 |
} |
738 |
|
739 |
/**
|
740 |
* Deletes a band from the raster. If there is only a file or no band is
|
741 |
* selected then it does nothing.
|
742 |
*
|
743 |
* @param e
|
744 |
*/
|
745 |
private void delFileBand(ActionEvent e){ |
746 |
BandSetupPanel bandSetup = (BandSetupPanel)((FilterRasterDialogPanel)this.getContentPane()).getPanelByClassName("BandSetupPanel"); |
747 |
|
748 |
if( bandSetup.getFileList().getJList().getSelectedValue()!=null && |
749 |
bandSetup.getFileList().getNFiles() > 1){
|
750 |
String pathName = bandSetup.getFileList().getJList().getSelectedValue().toString();
|
751 |
px.delFile(pathName); |
752 |
String file = pathName.substring(pathName.lastIndexOf("/")+1); |
753 |
file = file.substring(file.lastIndexOf("\\")+1); |
754 |
bandSetup.removeFile(file); |
755 |
|
756 |
} |
757 |
Vector vInfo = new Vector(); |
758 |
for(int i=0;i<px.getFiles().length;i++){ |
759 |
vInfo.add(px.getFiles()[i]); |
760 |
} |
761 |
|
762 |
GeoRasterFile[] infoGrf = new GeoRasterFile[vInfo.size()]; |
763 |
for(int i = 0; i<infoGrf.length ; i++){ |
764 |
infoGrf[i] = (GeoRasterFile)vInfo.get(i); |
765 |
} |
766 |
|
767 |
this.addInfoFiles(infoGrf);
|
768 |
} |
769 |
|
770 |
/**
|
771 |
* The cancel button restores the previous state to the loading of this dialog
|
772 |
* @param e Evento
|
773 |
*/
|
774 |
private void cancelButtonActionPerformed(ActionEvent e) { |
775 |
this.status.restoreStatus(this); |
776 |
fLayer.getMapContext().invalidate(); |
777 |
} |
778 |
|
779 |
/**
|
780 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
781 |
*/
|
782 |
public WindowInfo getWindowInfo() {
|
783 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
784 |
m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_raster")); |
785 |
return m_viewinfo;
|
786 |
} |
787 |
|
788 |
//********************************************************************
|
789 |
//***********************EVENTOS DE RAT?N*****************************
|
790 |
|
791 |
public void mouseClicked(MouseEvent e) { |
792 |
// TODO Auto-generated method stub
|
793 |
|
794 |
} |
795 |
|
796 |
public void mouseEntered(MouseEvent e) { |
797 |
// TODO Auto-generated method stub
|
798 |
|
799 |
} |
800 |
|
801 |
public void mouseExited(MouseEvent e) { |
802 |
// TODO Auto-generated method stub
|
803 |
|
804 |
} |
805 |
|
806 |
public void mousePressed(MouseEvent e) { |
807 |
// TODO Auto-generated method stub
|
808 |
|
809 |
} |
810 |
|
811 |
public void mouseReleased(MouseEvent e) { |
812 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
813 |
if (((e.getSource() == ebcPanel.lstBrightness.getJSlider()) || (e.getSource() == ebcPanel.lstContrast.getJSlider())) &&
|
814 |
(ebcPanel.getJCheckBox1().isSelected() == true))
|
815 |
processBrightnessContrastPanel(); |
816 |
} |
817 |
|
818 |
public void keyPressed(KeyEvent e) { |
819 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
820 |
/*if(e.getSource() == ebcPanel.getCheckSliderText().getJTextField()){
|
821 |
ebcPanel.getCheckSliderText().getJSlider().setValue((int) Math.round(Double.valueOf(ebcPanel.getCheckSliderText().getTextValue()).doubleValue()));
|
822 |
}*/
|
823 |
|
824 |
} |
825 |
|
826 |
public void keyReleased(KeyEvent e) { |
827 |
// TODO Auto-generated method stub
|
828 |
|
829 |
} |
830 |
|
831 |
public void keyTyped(KeyEvent e) { |
832 |
// TODO Auto-generated method stub
|
833 |
|
834 |
} |
835 |
|
836 |
public void actionPerformed(ActionEvent e){ |
837 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
838 |
if((e.getSource() == ebcPanel.getLabelSliderText().getJTextField()) ||
|
839 |
(e.getSource() == ebcPanel.getLabelSliderText1().getJTextField())){ |
840 |
|
841 |
if(ebcPanel.getJCheckBox1().isSelected()){
|
842 |
processBrightnessContrastPanel(); |
843 |
} |
844 |
|
845 |
} |
846 |
} |
847 |
|
848 |
} |