svn-gvsig-desktop / import / ext3D / branches / ext3D_v1.1 / ext3Dgui / src / com / iver / ai2 / gvsig3dgui / layer / MenuZoom3D.java @ 15455
History | View | Annotate | Download (4.06 KB)
1 |
package com.iver.ai2.gvsig3dgui.layer; |
---|---|
2 |
|
3 |
import java.awt.geom.Rectangle2D; |
4 |
|
5 |
import javax.swing.JOptionPane; |
6 |
|
7 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
8 |
import com.iver.ai2.gvsig3dgui.view.View3D; |
9 |
import com.iver.andami.PluginServices; |
10 |
import com.iver.andami.plugins.Extension; |
11 |
import com.iver.cit.gvsig.fmap.MapContext; |
12 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
13 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
14 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
15 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
16 |
|
17 |
public class MenuZoom3D extends Extension { |
18 |
|
19 |
|
20 |
private boolean activa = true; |
21 |
|
22 |
public void execute(String actionCommand) { |
23 |
// System.out.println("EXECUTE");
|
24 |
|
25 |
// Getting view3
|
26 |
com.iver.andami.ui.mdiManager.IWindow view = PluginServices |
27 |
.getMDIManager().getActiveWindow(); |
28 |
if (!(view instanceof View3D)) |
29 |
return;
|
30 |
// Casting to View3D
|
31 |
View3D vista3D = (View3D) view; |
32 |
IProjectView model = vista3D.getModel(); |
33 |
MapContext mapa = model.getMapContext(); |
34 |
|
35 |
// Action for ZOOM_SELECT
|
36 |
if (actionCommand.equals("ZOOM_SELECT")) { |
37 |
// Getting all selected Extent
|
38 |
FLayer[] selectedExtent = mapa.getLayers().getActives();
|
39 |
|
40 |
// If there is not one and is available
|
41 |
if (selectedExtent.length == 1 && selectedExtent[0].isAvailable() |
42 |
&& (selectedExtent[0] instanceof FLyrVect)) { |
43 |
// Getting selected layer
|
44 |
FLyrVect lyr3D = (FLyrVect) selectedExtent[0];
|
45 |
// Gettin extend
|
46 |
Rectangle2D ex = mapa.getSelectionBounds();
|
47 |
// ex = lyr3D.getFullExtent();
|
48 |
if (ex != null) |
49 |
// Doing zoom
|
50 |
mapa.zoomToExtent(ex); |
51 |
} |
52 |
|
53 |
} |
54 |
// Action for TRANSPARENCY
|
55 |
if (actionCommand.equals("TRANSPARENCY")) { |
56 |
FLayer[] selectedExtent = mapa.getLayers().getActives();
|
57 |
|
58 |
// If there is not one and is available
|
59 |
if (selectedExtent.length == 1 && selectedExtent[0].isAvailable()) { |
60 |
// // && (selectedExtent[0] instanceof FLyrVect)) {
|
61 |
FLayer lyr3D = selectedExtent[0];
|
62 |
Layer3DProps props = Layer3DProps.getLayer3DProps(lyr3D); |
63 |
if (props.getType() == Layer3DProps.layer3DImage) {
|
64 |
// Generating transparency panel
|
65 |
TransparencyPanel transparencyPanel = new TransparencyPanel(
|
66 |
vista3D.getModel()); |
67 |
// Showing it
|
68 |
PluginServices.getMDIManager().addWindow(transparencyPanel); |
69 |
} else {
|
70 |
JOptionPane.showMessageDialog(null, PluginServices.getText( |
71 |
this, "No_available")); |
72 |
} |
73 |
} |
74 |
|
75 |
} |
76 |
|
77 |
} |
78 |
|
79 |
public void initialize() { |
80 |
this.setActiva(true); |
81 |
} |
82 |
|
83 |
public boolean isEnabled() { |
84 |
View3D f = (View3D) PluginServices.getMDIManager().getActiveWindow(); |
85 |
|
86 |
if (f == null) { |
87 |
return false; |
88 |
} |
89 |
try {
|
90 |
|
91 |
// If the selected layer is instance of FlyrVect isEnable = true
|
92 |
FLayer[] selected = f.getModel().getMapContext().getLayers()
|
93 |
.getActives(); |
94 |
Layer3DProps props = Layer3DProps.getLayer3DProps(selected[0]);
|
95 |
if ((selected.length == 1) && (selected[0].isAvailable())) { |
96 |
if ((props.getType() == Layer3DProps.layer3DImage)
|
97 |
|| (props.getType() == Layer3DProps.layer3DVector)) |
98 |
return true; |
99 |
} |
100 |
} catch (Exception e) { |
101 |
return false; |
102 |
} |
103 |
|
104 |
// if (selected.length == 1 && selected[0] instanceof FLyrVect
|
105 |
// && selected[0].isAvailable()) {
|
106 |
// return true;
|
107 |
// }
|
108 |
// if (selected.length == 1 && selected[0] instanceof FLyrWMS
|
109 |
// && selected[0].isAvailable()) {
|
110 |
// return true;
|
111 |
// }
|
112 |
return false; |
113 |
// return true;
|
114 |
} |
115 |
|
116 |
public boolean isVisible() { |
117 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
118 |
.getMDIManager().getActiveWindow(); |
119 |
|
120 |
if (f == null) { |
121 |
return false; |
122 |
} |
123 |
|
124 |
// Only isVisible = true, where the view3D have layers
|
125 |
if (f instanceof View3D) { |
126 |
BaseView vista = (BaseView) f; |
127 |
IProjectView model = vista.getModel(); |
128 |
MapContext mapa = model.getMapContext(); |
129 |
|
130 |
return mapa.getLayers().getLayersCount() > 0; |
131 |
} |
132 |
return false; |
133 |
} |
134 |
|
135 |
public void terminate() { |
136 |
super.terminate();
|
137 |
} |
138 |
|
139 |
public boolean isActiva() { |
140 |
return activa;
|
141 |
} |
142 |
|
143 |
public void setActiva(boolean activa) { |
144 |
this.activa = activa;
|
145 |
} |
146 |
} |