Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / toc / WCSPropsRaster.java @ 4389

History | View | Annotate | Download (4.94 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
* 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
import com.iver.cit.gvsig.gui.panels.PropertiesWCSDialog;
59

    
60
/**
61
 * 
62
 * @author Nacho Brodin (brodin_ign@gva.es)
63
 */
64
public class WCSPropsRaster  extends TocMenuEntry {
65
        private JMenuItem propsMenuItem;
66
        FLayer lyr = null;
67
        private PropertiesWCSDialog        propsDialog = null;
68
        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
                if(lyr instanceof FLyrWCS && ((FLyrWCS)lyr).getPxRaster()!=null){
94
                        RasterFilterStackManager         stackManager = null;
95
                        
96
                        FLyrWCS layer = (FLyrWCS)lyr;
97

    
98
                        stackManager = new RasterFilterStackManager(layer.getFilterStack());
99
                        
100
                        propsDialog = new PropertiesWCSDialog(layer, stackManager.getTransparencyRGB());
101
                                               
102
                        int alpha = layer.getPxRaster().getAlpha();
103
                        
104
                        bandSetup = ((FilterRasterDialogPanel)propsDialog.getContentPane()).getBandSetup();
105
                        GeoRasterFile[] files = layer.getPxRaster().getFiles();
106
                        bandSetup.addFiles(files);
107
                        for(int i=0; i< files.length;i++)
108
                                propsDialog.addNumBands(files[i].getBandCount());
109
                                
110
                        PxRaster px = layer.getPxRaster();
111
                        int posR = 0, posG = 0, posB = 0;
112
                        
113
                        for(int i=0;i<px.getPosFile(GeoRasterFile.RED_BAND);i++)
114
                                posR += files[i].getBandCount();
115
                        posR += px.getBand(GeoRasterFile.RED_BAND);
116
                        
117
                        for(int i=0;i<px.getPosFile(GeoRasterFile.GREEN_BAND);i++)
118
                                posG += files[i].getBandCount();
119
                        posG += px.getBand(GeoRasterFile.GREEN_BAND);
120
                        
121
                        for(int i=0;i<px.getPosFile(GeoRasterFile.BLUE_BAND);i++)
122
                                posB += files[i].getBandCount();
123
                        posB += px.getBand(GeoRasterFile.BLUE_BAND);
124
                        
125
                                        
126
                        bandSetup.assignBand(posR, GeoRasterFile.RED_BAND);
127
                        bandSetup.assignBand(posG, GeoRasterFile.GREEN_BAND);
128
                        bandSetup.assignBand(posB, GeoRasterFile.BLUE_BAND);        
129
                                                                        
130
                        //Asignaci?n del alpha actual de la imagen al dialogo
131
                        RasterTransparencyPanel rasterTrans = ((FilterRasterDialogPanel)propsDialog.getContentPane()).getTransparencyPanel();
132
                        rasterTrans.setOpacity(alpha);
133
                                
134
                        //Asignaci?n del porcentaje de recorte actual de la imagen al dialogo
135
                        EnhancedPanel pEnhan =  ((FilterRasterDialogPanel)propsDialog.getContentPane()).getEnhancedPanel();
136
                        
137
                        propsDialog.setRasterFilterStackManager(stackManager);
138
                        int tail = 0;
139
                        if(        pEnhan != null &&
140
                                stackManager.getStackStats() != null){
141
                                tail = (int)(stackManager.getStackStats().tailPercent*200);
142
                                pEnhan.setPercentTail(tail);
143
                        }
144
                        if(stackManager.isActive(stackManager.getTypeFilter("enhanced")))
145
                                pEnhan.setSelectedFilter(1);
146
                        else
147
                                pEnhan.setSelectedFilter(0);
148
                                                        
149
                        propsDialog.readStat();
150
                        
151
                        PluginServices.getMDIManager().addView(propsDialog);               
152
                }
153
        }
154
}