gvsig-3d / 2.1 / trunk / org.gvsig.view3d / org.gvsig.view3d.app / org.gvsig.view3d.app.common / src / main / java / org / gvsig / view3d / app / mainplugin / SynchronizeView3DExtension.java @ 773
History | View | Annotate | Download (3.51 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright ? 2007-2017 gvSIG Association
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.view3d.app.mainplugin; |
25 |
|
26 |
import java.util.List; |
27 |
|
28 |
import org.gvsig.andami.IconThemeHelper; |
29 |
import org.gvsig.andami.plugins.Extension; |
30 |
import org.gvsig.app.ApplicationLocator; |
31 |
import org.gvsig.app.ApplicationManager; |
32 |
import org.gvsig.app.project.documents.view.ViewDocument; |
33 |
import org.gvsig.app.project.documents.view.gui.IView; |
34 |
import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesSupport; |
35 |
import org.gvsig.view3d.swing.api.MapControl3D; |
36 |
import org.gvsig.view3d.swing.api.View3DSwingLocator; |
37 |
import org.gvsig.view3d.swing.api.View3DSwingManager; |
38 |
import org.gvsig.view3d.swing.api.View3DSwingManager.TYPE; |
39 |
|
40 |
/**
|
41 |
*
|
42 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
|
43 |
*
|
44 |
*/
|
45 |
public class SynchronizeView3DExtension extends Extension { |
46 |
|
47 |
public void initialize() { |
48 |
registerIcons(); |
49 |
} |
50 |
|
51 |
private void registerIcons() { |
52 |
IconThemeHelper.registerIcon("view3d", "synchronize-view-3d", this); |
53 |
} |
54 |
|
55 |
public void execute(String actionCommand) { |
56 |
|
57 |
if ("synchronize-view-3d".equals(actionCommand)) { |
58 |
IView view = getActiveView(); |
59 |
|
60 |
View3DSwingManager manager = View3DSwingLocator.getManager(); |
61 |
MapControl3D mapControl3DFlat = |
62 |
manager.getMapControl3D( |
63 |
(ExtendedPropertiesSupport) view.getViewDocument(), |
64 |
TYPE.FLAT); |
65 |
if (mapControl3DFlat != null) { |
66 |
mapControl3DFlat.reloadLayers(); |
67 |
} |
68 |
|
69 |
MapControl3D mapControl3DSphere = |
70 |
manager.getMapControl3D( |
71 |
(ExtendedPropertiesSupport) view.getViewDocument(), |
72 |
TYPE.SPHERE); |
73 |
if (mapControl3DSphere != null) { |
74 |
mapControl3DSphere.reloadLayers(); |
75 |
} |
76 |
} |
77 |
} |
78 |
|
79 |
public boolean isEnabled() { |
80 |
IView view = getActiveView(); |
81 |
if (view != null) { |
82 |
View3DSwingManager manager = View3DSwingLocator.getManager(); |
83 |
List<MapControl3D> mapControls3D =
|
84 |
manager.getMapControl3D((ExtendedPropertiesSupport) view |
85 |
.getViewDocument()); |
86 |
if (mapControls3D.size() > 0) { |
87 |
return true; |
88 |
} |
89 |
} |
90 |
return false; |
91 |
} |
92 |
|
93 |
public boolean isVisible() { |
94 |
IView view = getActiveView(); |
95 |
if (view != null) { |
96 |
return true; |
97 |
} |
98 |
return false; |
99 |
} |
100 |
|
101 |
private IView getActiveView() {
|
102 |
ApplicationManager application = ApplicationLocator.getManager(); |
103 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
104 |
return view;
|
105 |
} |
106 |
|
107 |
} |