gvsig-3d / 2.1 / branches / org.gvsig.view3d_vector_and_extrusion_2.3 / org.gvsig.view3d / org.gvsig.view3d / org.gvsig.view3d.app / org.gvsig.view3d.app.common / src / main / java / org / gvsig / view3d / app / mainplugin / SynchronizeViewPort3DExtension.java @ 708
History | View | Annotate | Download (2.71 KB)
1 |
package org.gvsig.view3d.app.mainplugin; |
---|---|
2 |
|
3 |
import java.util.List; |
4 |
|
5 |
import org.gvsig.andami.IconThemeHelper; |
6 |
import org.gvsig.andami.plugins.Extension; |
7 |
import org.gvsig.app.ApplicationLocator; |
8 |
import org.gvsig.app.ApplicationManager; |
9 |
import org.gvsig.app.project.documents.view.ViewDocument; |
10 |
import org.gvsig.app.project.documents.view.gui.IView; |
11 |
import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesSupport; |
12 |
import org.gvsig.view3d.swing.api.MapControl3D; |
13 |
import org.gvsig.view3d.swing.api.View3DSwingLocator; |
14 |
import org.gvsig.view3d.swing.api.View3DSwingManager; |
15 |
import org.gvsig.view3d.swing.api.View3DSwingManager.TYPE; |
16 |
|
17 |
|
18 |
/**
|
19 |
* Extension that synchronizes the 3d view with the bounds of the gvSIG map view.
|
20 |
*/
|
21 |
public class SynchronizeViewPort3DExtension extends Extension { |
22 |
|
23 |
private static final String SYNCHRONIZE_VIEWPORT_3D = "synchronize-viewport-3d"; |
24 |
|
25 |
public void initialize() { |
26 |
registerIcons(); |
27 |
} |
28 |
|
29 |
private void registerIcons() { |
30 |
IconThemeHelper.registerIcon("view3d", SYNCHRONIZE_VIEWPORT_3D, this); |
31 |
} |
32 |
|
33 |
public void execute(String actionCommand) { |
34 |
|
35 |
if (SYNCHRONIZE_VIEWPORT_3D.equals(actionCommand)) {
|
36 |
IView view = getActiveView(); |
37 |
|
38 |
View3DSwingManager manager = View3DSwingLocator.getManager(); |
39 |
MapControl3D mapControl3DFlat = |
40 |
manager.getMapControl3D( |
41 |
(ExtendedPropertiesSupport) view.getViewDocument(), |
42 |
TYPE.FLAT); |
43 |
if (mapControl3DFlat != null) { |
44 |
mapControl3DFlat.synchronizeViewPorts(); |
45 |
} |
46 |
|
47 |
MapControl3D mapControl3DSphere = |
48 |
manager.getMapControl3D( |
49 |
(ExtendedPropertiesSupport) view.getViewDocument(), |
50 |
TYPE.SPHERE); |
51 |
if (mapControl3DSphere != null) { |
52 |
mapControl3DSphere.synchronizeViewPorts(); |
53 |
} |
54 |
} |
55 |
} |
56 |
|
57 |
public boolean isEnabled() { |
58 |
IView view = getActiveView(); |
59 |
if (view != null) { |
60 |
View3DSwingManager manager = View3DSwingLocator.getManager(); |
61 |
List<MapControl3D> mapControls3D =
|
62 |
manager.getMapControl3D((ExtendedPropertiesSupport) view |
63 |
.getViewDocument()); |
64 |
if (mapControls3D.size() > 0) { |
65 |
return true; |
66 |
} |
67 |
} |
68 |
return false; |
69 |
} |
70 |
|
71 |
public boolean isVisible() { |
72 |
IView view = getActiveView(); |
73 |
if (view != null) { |
74 |
return true; |
75 |
} |
76 |
return false; |
77 |
} |
78 |
|
79 |
private IView getActiveView() {
|
80 |
ApplicationManager application = ApplicationLocator.getManager(); |
81 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
82 |
return view;
|
83 |
} |
84 |
|
85 |
} |