svn-gvsig-desktop / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / toc / WCSPropsRaster.java @ 4578
History | View | Annotate | Download (5.03 KB)
1 | 2017 | igbrotru | /* 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 | |||
45 | import javax.swing.JMenuItem; |
||
46 | |||
47 | import org.cresques.io.GeoRasterFile; |
||
48 | import org.cresques.io.raster.RasterFilterStackManager; |
||
49 | import org.cresques.px.PxRaster; |
||
50 | import org.cresques.ui.raster.BandSetupPanel; |
||
51 | import org.cresques.ui.raster.EnhancedPanel; |
||
52 | import org.cresques.ui.raster.FilterRasterDialogPanel; |
||
53 | import org.cresques.ui.raster.RasterTransparencyPanel; |
||
54 | |||
55 | import com.iver.andami.PluginServices; |
||
56 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
57 | import com.iver.cit.gvsig.fmap.layers.FLyrWCS; |
||
58 | 4505 | jaume | import com.iver.cit.gvsig.gui.dialog.WCSRasterPropsDialog; |
59 | 2017 | igbrotru | |
60 | /**
|
||
61 | *
|
||
62 | 2260 | igbrotru | * @author Nacho Brodin (brodin_ign@gva.es)
|
63 | 2017 | igbrotru | */
|
64 | public class WCSPropsRaster extends TocMenuEntry { |
||
65 | private JMenuItem propsMenuItem; |
||
66 | FLayer lyr = null;
|
||
67 | 4505 | jaume | private WCSRasterPropsDialog propsDialog = null; |
68 | 2017 | igbrotru | private BandSetupPanel bandSetup = null; |
69 | |||
70 | public void initialize(FPopupMenu m) { |
||
71 | super.initialize(m);
|
||
72 | |||
73 | if (isTocItemBranch()) {
|
||
74 | lyr = getNodeLayer(); |
||
75 | // Opcciones para capas WCS
|
||
76 | if ((lyr instanceof FLyrWCS)) { |
||
77 | propsMenuItem = new JMenuItem(PluginServices.getText(this, "propiedades_raster")); |
||
78 | getMenu().add( propsMenuItem ); |
||
79 | propsMenuItem.setFont(FPopupMenu.theFont); |
||
80 | getMenu().setEnabled(true);
|
||
81 | //getMenu().addSeparator();
|
||
82 | //Cambio color
|
||
83 | propsMenuItem.addActionListener(this);
|
||
84 | } |
||
85 | } |
||
86 | } |
||
87 | /* (non-Javadoc)
|
||
88 | * @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
|
||
89 | */
|
||
90 | public void actionPerformed(ActionEvent e) { |
||
91 | lyr = getNodeLayer(); |
||
92 | |||
93 | 4505 | jaume | if(lyr instanceof FLyrWCS && ((FLyrWCS) lyr).getPxRaster()!=null){ |
94 | 2017 | igbrotru | RasterFilterStackManager stackManager = null;
|
95 | |||
96 | 4472 | jaume | FLyrWCS layer = (FLyrWCS) lyr; |
97 | 2038 | igbrotru | |
98 | 4356 | jaume | stackManager = new RasterFilterStackManager(layer.getFilterStack());
|
99 | 2032 | igbrotru | |
100 | 4514 | nacho | propsDialog = new WCSRasterPropsDialog(layer, stackManager.getTransparencyRGB());
|
101 | 4399 | jaume | |
102 | 4356 | jaume | int alpha = layer.getPxRaster().getAlpha();
|
103 | 2017 | igbrotru | |
104 | 4578 | nacho | FilterRasterDialogPanel filterPanel = ((FilterRasterDialogPanel)propsDialog.getContentPane()); |
105 | |||
106 | bandSetup = (BandSetupPanel)filterPanel.getPanelByClassName("BandSetupPanel");
|
||
107 | 4356 | jaume | GeoRasterFile[] files = layer.getPxRaster().getFiles();
|
108 | 2017 | igbrotru | bandSetup.addFiles(files); |
109 | 2260 | igbrotru | for(int i=0; i< files.length;i++) |
110 | propsDialog.addNumBands(files[i].getBandCount()); |
||
111 | |||
112 | 4356 | jaume | PxRaster px = layer.getPxRaster(); |
113 | 2017 | igbrotru | int posR = 0, posG = 0, posB = 0; |
114 | |||
115 | for(int i=0;i<px.getPosFile(GeoRasterFile.RED_BAND);i++) |
||
116 | posR += files[i].getBandCount(); |
||
117 | posR += px.getBand(GeoRasterFile.RED_BAND); |
||
118 | |||
119 | for(int i=0;i<px.getPosFile(GeoRasterFile.GREEN_BAND);i++) |
||
120 | posG += files[i].getBandCount(); |
||
121 | posG += px.getBand(GeoRasterFile.GREEN_BAND); |
||
122 | |||
123 | for(int i=0;i<px.getPosFile(GeoRasterFile.BLUE_BAND);i++) |
||
124 | posB += files[i].getBandCount(); |
||
125 | posB += px.getBand(GeoRasterFile.BLUE_BAND); |
||
126 | |||
127 | |||
128 | bandSetup.assignBand(posR, GeoRasterFile.RED_BAND); |
||
129 | bandSetup.assignBand(posG, GeoRasterFile.GREEN_BAND); |
||
130 | bandSetup.assignBand(posB, GeoRasterFile.BLUE_BAND); |
||
131 | |||
132 | //Asignaci?n del alpha actual de la imagen al dialogo
|
||
133 | 4578 | nacho | RasterTransparencyPanel rasterTrans = (RasterTransparencyPanel)filterPanel.getPanelByClassName("RasterTransparencyPanel");
|
134 | 2017 | igbrotru | rasterTrans.setOpacity(alpha); |
135 | |||
136 | //Asignaci?n del porcentaje de recorte actual de la imagen al dialogo
|
||
137 | 4578 | nacho | EnhancedPanel pEnhan = (EnhancedPanel)filterPanel.getPanelByClassName("EnhancedPanel");
|
138 | |||
139 | 2017 | igbrotru | propsDialog.setRasterFilterStackManager(stackManager); |
140 | int tail = 0; |
||
141 | if( pEnhan != null && |
||
142 | stackManager.getStackStats() != null){
|
||
143 | tail = (int)(stackManager.getStackStats().tailPercent*200); |
||
144 | pEnhan.setPercentTail(tail); |
||
145 | } |
||
146 | if(stackManager.isActive(stackManager.getTypeFilter("enhanced"))) |
||
147 | pEnhan.setSelectedFilter(1);
|
||
148 | else
|
||
149 | pEnhan.setSelectedFilter(0);
|
||
150 | |||
151 | propsDialog.readStat(); |
||
152 | |||
153 | PluginServices.getMDIManager().addView(propsDialog); |
||
154 | } |
||
155 | } |
||
156 | } |