Revision 470 2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.app/org.gvsig.view3d.app.common/src/main/java/org/gvsig/view3d/app/mainplugin/View3DExtension.java
View3DExtension.java | ||
---|---|---|
30 | 30 |
import org.gvsig.app.ApplicationManager; |
31 | 31 |
import org.gvsig.app.project.documents.view.ViewDocument; |
32 | 32 |
import org.gvsig.app.project.documents.view.gui.IView; |
33 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
34 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
33 | 35 |
import org.gvsig.view3d.swing.api.View3DPanel; |
34 | 36 |
import org.gvsig.view3d.swing.api.View3DSwingLocator; |
35 | 37 |
import org.gvsig.view3d.swing.api.View3DSwingManager; |
36 | 38 |
import org.gvsig.view3d.swing.api.View3DSwingManager.TYPE; |
37 | 39 |
|
38 |
|
|
39 | 40 |
/** |
40 | 41 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
41 | 42 |
* |
... | ... | |
52 | 53 |
} |
53 | 54 |
|
54 | 55 |
public void execute(String actionCommand) { |
55 |
|
|
56 |
TYPE type = null; |
|
57 |
if("sphere-view-3d".equals(actionCommand)){ |
|
58 |
type = TYPE.SPHERE; |
|
59 |
} else if("flat-view-3d".equals(actionCommand)){ |
|
60 |
type = TYPE.FLAT; |
|
61 |
} else { |
|
62 |
return; |
|
63 |
} |
|
64 |
|
|
56 |
|
|
57 |
TYPE type = getType(actionCommand); |
|
58 |
|
|
65 | 59 |
IView view = getActiveView(); |
66 |
|
|
67 |
if(view != null){
|
|
60 |
|
|
61 |
if (view != null) {
|
|
68 | 62 |
View3DSwingManager manager = View3DSwingLocator.getManager(); |
69 |
View3DPanel createView3DPanel = |
|
70 |
manager.createView3DPanel(view.getMapControl().getMapContext(), |
|
63 |
|
|
64 |
View3DPanel viewPanel3D = |
|
65 |
manager.getViewPanel3D(view.getMapControl().getMapContext(), |
|
71 | 66 |
type); |
72 |
createView3DPanel.show(); |
|
67 |
if (viewPanel3D == null |
|
68 |
|| viewPanel3D.getMapControl3D().getType() != type) { |
|
69 |
View3DPanel view3DPanel = |
|
70 |
manager.createView3DPanel(view.getMapControl() |
|
71 |
.getMapContext(), type); |
|
72 |
view3DPanel.show(); |
|
73 |
} |
|
73 | 74 |
} |
74 |
|
|
75 | 75 |
} |
76 | 76 |
|
77 |
private TYPE getType(String actionCommand) { |
|
78 |
if ("sphere-view-3d".equals(actionCommand)) { |
|
79 |
return TYPE.SPHERE; |
|
80 |
} else if ("flat-view-3d".equals(actionCommand)) { |
|
81 |
return TYPE.FLAT; |
|
82 |
} |
|
83 |
return null; |
|
84 |
} |
|
85 |
|
|
77 | 86 |
public boolean isEnabled() { |
78 | 87 |
return true; |
79 | 88 |
} |
80 |
|
|
89 |
|
|
81 | 90 |
public boolean isVisible() { |
82 | 91 |
return true; |
83 | 92 |
} |
84 |
|
|
93 |
|
|
85 | 94 |
@Override |
86 | 95 |
public boolean isEnabled(String actionCommand) { |
87 | 96 |
|
88 | 97 |
IView view = getActiveView(); |
89 |
if(view != null){ |
|
90 |
if("sphere-view-3d".equals(actionCommand)){ |
|
98 |
if (view != null |
|
99 |
&& ("sphere-view-3d".equals(actionCommand) || "flat-view-3d" |
|
100 |
.equals(actionCommand))) { |
|
101 |
|
|
102 |
View3DSwingManager manager = View3DSwingLocator.getManager(); |
|
103 |
MapContext mapContext = view.getMapControl().getMapContext(); |
|
104 |
|
|
105 |
View3DPanel viewPanel3D = |
|
106 |
manager.getViewPanel3D(mapContext, getType(actionCommand)); |
|
107 |
|
|
108 |
FLayers layers = mapContext.getLayers(); |
|
109 |
|
|
110 |
boolean isEPSG4326 = |
|
111 |
mapContext.getProjection().getAbrev().equals("EPSG:4326"); |
|
112 |
|
|
113 |
if (viewPanel3D == null && layers.getLayersCount() > 0 |
|
114 |
&& isEPSG4326) { |
|
91 | 115 |
return true; |
92 |
// TODO ckeck if active view already has one sphere view |
|
93 |
} else if("flat-view-3d".equals(actionCommand)){ |
|
94 |
// TODO ckeck if active view already has one flat view |
|
95 |
return true; |
|
96 |
} |
|
116 |
} |
|
97 | 117 |
} |
98 | 118 |
return false; |
99 | 119 |
} |
100 |
|
|
120 |
|
|
101 | 121 |
@Override |
102 | 122 |
public boolean isVisible(String actionCommand) { |
103 | 123 |
IView view = getActiveView(); |
104 |
if(view != null){
|
|
124 |
if (view != null) {
|
|
105 | 125 |
return true; |
106 | 126 |
} |
107 | 127 |
return false; |
108 | 128 |
} |
109 |
|
|
110 |
|
|
129 |
|
|
111 | 130 |
private IView getActiveView() { |
112 | 131 |
ApplicationManager application = ApplicationLocator.getManager(); |
113 | 132 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
114 | 133 |
return view; |
115 | 134 |
} |
116 |
|
|
135 |
|
|
117 | 136 |
@Override |
118 | 137 |
public boolean canQueryByAction() { |
119 | 138 |
return true; |
Also available in: Unified diff