Statistics
| Revision:

root / trunk / extensions / extgvSIGPiloto-Raster / src / com / iver / cit / gvsig / gui / toc / WMSPaletteTocMenuEntry.java @ 10002

History | View | Annotate | Download (4.21 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 javax.swing.JMenuItem;
44

    
45
import org.cresques.filter.RasterFilterStackManager;
46
import org.cresques.filter.bands.PaletteFilter;
47
import org.cresques.filter.bands.PaletteStackManager;
48

    
49
import com.iver.andami.PluginServices;
50
import com.iver.cit.gvsig.fmap.layers.FLayer;
51
import com.iver.cit.gvsig.fmap.layers.FLyrWMS;
52
import com.iver.cit.gvsig.project.documents.view.gui.dialogs.PaletteDialog;
53
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
54
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
55

    
56
/**
57
 * Entrada del men? contextual para el histograma
58
 * @author Nacho Brodin (brodin_ign@gva.es)
59
 */
60
public class WMSPaletteTocMenuEntry  extends AbstractTocContextMenuAction {
61
        private JMenuItem                                         propsMenuItem;
62
        private FLayer                                                 lyr = null;
63
        private PaletteDialog                                paletteDialog = null;
64
        private RasterFilterStackManager        stackManager = null;
65
        private int                                                 width = 408;
66
        private int                                                 height = 420;
67

    
68
        public String getGroup() {
69
                return "RasterTools"; 
70
        }
71

    
72
        public int getGroupOrder() {
73
                return 80;
74
        }
75

    
76
        public int getOrder() {
77
                return 1;
78
        }
79

    
80
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
81
                return selectedItems.length == 1;
82
        }
83

    
84
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
85
                if (isTocItemBranch(item)) {
86
                        lyr = getNodeLayer(item);
87
            if ((lyr instanceof FLyrWMS)) {
88
                    return true;
89
            }
90
                }
91
                return false;
92
        }
93
        
94
        /* (non-Javadoc)
95
         * @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
96
         */
97
        public void execute(ITocItem item, FLayer[] selectedItems) {
98
               lyr = getNodeLayer(item);
99
        
100
                if(lyr instanceof FLyrWMS && ((FLyrWMS)lyr).getPxRaster()!=null){
101

    
102
                        FLyrWMS layer = (FLyrWMS) lyr;
103
                        stackManager = new RasterFilterStackManager(layer.getFilterStack());
104

    
105
                    paletteDialog = new PaletteDialog((FLyrWMS)lyr, stackManager, width, height);
106
                        PaletteFilter pf = (PaletteFilter)layer.getFilterStack().getByType(PaletteStackManager.palette);
107
                        
108
                        //Si hay en la pila alguna paleta la carga en el dialogo
109
                        if(pf != null && pf.getPalette() != null){
110
                                paletteDialog.getPPalette().loadPanelFromPalette(pf.getPalette());
111
                                if(pf.isExec())
112
                                        paletteDialog.getPPalette().getCActive().setSelected(true);
113
                                else
114
                                        paletteDialog.getPPalette().getCActive().setSelected(false);
115
                                
116
                                if(pf.isInterpolate())
117
                                        paletteDialog.getPPalette().getCbInterpolar().setSelected(true);
118
                                else
119
                                        paletteDialog.getPPalette().getCbInterpolar().setSelected(false);
120
                        }
121
                        
122
                        //No se puede modificar la paleta de un WMS ya que esta se recarga cada 
123
                        //vez que se hace un zoom. Habr?a que llevar un control de cambios para cada
124
                        //entrada de la tabla y volver a aplicarlo al siguiente zoom
125
                        paletteDialog.getPPalette().getBAccept().setEnabled(false);
126
                        paletteDialog.getPPalette().getBApply().setEnabled(false);
127
                                                                      
128
                       PluginServices.getMDIManager().addWindow(paletteDialog);                    
129
                }
130
        }
131

    
132
        public String getText() {
133
                return PluginServices.getText(this, "paleta");
134
        }
135
}