Statistics
| Revision:

gvsig-3d / 2.1 / trunk / org.gvsig.gvsig3d / org.gvsig.gvsig3d.app / org.gvsig.gvsig3d.app.commons / src / main / java / org / gvsig / gvsig3d / app / tocmenu / TocTransparencyPanel.java @ 385

History | View | Annotate | Download (4.46 KB)

1
/* gvSIG 3D extension for gvSIG
2
 *
3
 * Copyright (C) 2012 Prodevelop.
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
 *   Prodevelop, S.L.
22
 *   Pza. Don Juan de Villarrasa, 14 - 5
23
 *   46001 Valencia
24
 *   Spain
25
 *
26
 *   +34 963 510 612
27
 *   +34 963 510 968
28
 *   prode@prodevelop.es
29
 *   http://www.prodevelop.es
30
 */
31
/*
32
 * AUTHORS:
33
 * 2012 AI2 - Instituto Universitario de Automatica e Informatica Industrial.
34
 * Universitat Politecnica de Valencia (UPV)
35
 * http://www.ai2.upv.es
36
 */
37

    
38

    
39
package org.gvsig.gvsig3d.app.tocmenu;
40

    
41
import org.gvsig.andami.PluginServices;
42
import org.gvsig.andami.ui.mdiManager.IWindow;
43
import org.gvsig.app.project.documents.view.ViewDocument;
44
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
45
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction;
46
import org.gvsig.app.project.documents.view.toc.ITocItem;
47
import org.gvsig.fmap.mapcontext.MapContext;
48
import org.gvsig.fmap.mapcontext.layers.FLayer;
49
import org.gvsig.gvsig3d.app.extension.DefaultView3DPanel;
50
import org.gvsig.gvsig3d.app.gui.styling.SymbolSelector3D;
51
import org.gvsig.gvsig3d.app.layer.TransparencyPanel;
52
import org.gvsig.gvsig3d.map3d.Layer3DProps;
53

    
54

    
55
/**
56
 * @author Jesus Zarzoso- jzarzoso@ai2.upv.es
57
 * @version $Id$
58
 * 
59
 */
60
public class TocTransparencyPanel extends AbstractTocContextMenuAction {
61

    
62
        public String getGroup() {
63
                return "group6"; // FIXME
64
        }
65

    
66
        public int getGroupOrder() {
67
                return 60;
68
        }
69

    
70
        public int getOrder() {
71
                return 10;
72
        }
73

    
74
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
75
                // return selectedItems.length == 1;
76

    
77
                // return true;
78

    
79
                boolean enable = false;
80

    
81
                for (int i = 0; i < selectedItems.length; i++) {
82
                        FLayer layer = selectedItems[i];
83
                        Layer3DProps props3D = (Layer3DProps) layer.getProperty("3DLayerExtension");
84
                        int type = props3D.getType();
85
                        if (type == Layer3DProps.layer3DImage) {
86
                                enable = true;
87
                        }
88
                }
89

    
90
                return enable;
91

    
92
                // if (selectedItems.length == 1 && selectedItems[0] instanceof FLyrVect
93
                // && selectedItems[0].isAvailable()) {
94
                // return true;
95
                // }
96
                // if (selectedItems.length == 1 && selectedItems[0] instanceof FLyrWMS
97
                // && selectedItems[0].isAvailable()) {
98
                // return true;
99
                // }
100
                // return false;
101

    
102
        }
103

    
104
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
105
                IWindow f = PluginServices
106
                                .getMDIManager().getActiveWindow();
107

    
108
                if (f == null) {
109
                        return false;
110
                }
111

    
112
                if (!isTocItemBranch(item))
113
                        return false;
114

    
115
                // Only isVisible = true, where the view3D have layers
116
                if (f instanceof DefaultView3DPanel) {
117
                        AbstractViewPanel vista = (AbstractViewPanel) f;
118
                        ViewDocument model = vista.getViewDocument();
119
                        MapContext mapa = model.getMapContext();
120

    
121
//                        return mapa.getLayers().getLayersCount() > 0;
122

    
123
                        FLayer[] selectedExtent = mapa.getLayers().getActives();
124

    
125
                        // If there is not one and is available
126
                        if (selectedExtent.length == 1 && selectedExtent[0].isAvailable()) {
127
                                // // && (selectedExtent[0] instanceof FLyrVect)) {
128
                                FLayer lyr3D = selectedExtent[0];
129
                                Layer3DProps props = (Layer3DProps) lyr3D.getProperty("3DLayerExtension");
130
                                return (props.getType() == Layer3DProps.layer3DImage);
131
                        }
132

    
133
                }
134
                return false;
135
        }
136

    
137
        public void execute(ITocItem item, FLayer[] selectedItems) {
138

    
139
                // Getting view3
140
                IWindow view = PluginServices
141
                                .getMDIManager().getActiveWindow();
142
                if (!(view instanceof DefaultView3DPanel))
143
                        return;
144
                // Casting to View3D
145
                DefaultView3DPanel vista3D = (DefaultView3DPanel) view;
146
                ViewDocument model = vista3D.getViewDocument();
147

    
148
                // Generating transparency panel
149
                TransparencyPanel transparencyPanel = new TransparencyPanel(model);
150
                
151
                // Showing it
152
                PluginServices.getMDIManager().addWindow(transparencyPanel);
153
                
154

    
155
        }
156

    
157
        public String getText() {
158
                // Name that appears in toc menu
159
                return PluginServices.getText(this, "Transparency");
160
        }
161

    
162
}