Revision 15422 import/ext3D/branches/ext3D_v1.1/extAnimationGUI/src/com/iver/ai2/animationgui/gui/MenuAnimation3D.java
MenuAnimation3D.java | ||
---|---|---|
4 | 4 |
import java.util.ArrayList; |
5 | 5 |
import java.util.List; |
6 | 6 |
|
7 |
import com.iver.ai2.gvsig3d.camera.ProjectCamera; |
|
8 |
import com.iver.ai2.gvsig3d.gui.View3D; |
|
7 | 9 |
import com.iver.andami.PluginServices; |
8 | 10 |
import com.iver.andami.plugins.Extension; |
9 | 11 |
import com.iver.andami.plugins.IExtension; |
10 | 12 |
import com.iver.andami.ui.mdiManager.IWindow; |
11 | 13 |
import com.iver.cit.gvsig.ProjectExtension; |
12 | 14 |
import com.iver.cit.gvsig.animation.AnimationContainer; |
15 |
import com.iver.cit.gvsig.animation.AnimationLayer2D; |
|
16 |
import com.iver.cit.gvsig.animation.AnimationLayer3DFlat; |
|
13 | 17 |
import com.iver.cit.gvsig.animation.AnimationPlayer; |
18 |
import com.iver.cit.gvsig.animation.AnimationTypeFactoryLayer2D; |
|
19 |
import com.iver.cit.gvsig.animation.Interpolator2D; |
|
20 |
import com.iver.cit.gvsig.animation.Interpolator3DFlat; |
|
21 |
import com.iver.cit.gvsig.animation.KeyFrame2D; |
|
22 |
import com.iver.cit.gvsig.animation.KeyFrame3DFlat; |
|
14 | 23 |
import com.iver.cit.gvsig.animation.interval.AnimationKeyFrameInterval; |
15 |
import com.iver.cit.gvsig.animation.test.AnimationLayer2D; |
|
16 |
import com.iver.cit.gvsig.animation.test.AnimationTypeFactoryLayer2D; |
|
17 |
import com.iver.cit.gvsig.animation.test.Interpolator2D; |
|
18 |
import com.iver.cit.gvsig.animation.test.KeyFrame2D; |
|
19 | 24 |
import com.iver.cit.gvsig.animation.traks.AnimationTimeTrack; |
25 |
import com.iver.cit.gvsig.animation.traks.IAnimationTrack; |
|
20 | 26 |
import com.iver.cit.gvsig.fmap.MapControl; |
21 | 27 |
import com.iver.cit.gvsig.project.Project; |
22 | 28 |
import com.iver.cit.gvsig.project.ProjectExtent; |
... | ... | |
27 | 33 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
28 | 34 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
29 | 35 |
|
36 |
import es.upv.ai2.libjosg.viewer.Camera; |
|
37 |
|
|
30 | 38 |
/** |
31 | 39 |
* @author |
32 | 40 |
* @since 1.1 |
... | ... | |
66 | 74 |
System.out.println("pulsado boton de capturar encuadres!!!"); |
67 | 75 |
|
68 | 76 |
String name = "Animation-" + cont++; |
77 |
List keyFrameList = null; |
|
78 |
|
|
79 |
// Getting the active windows |
|
69 | 80 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
70 |
BaseView view = (BaseView) w; |
|
71 |
MapControl mapa = view.getMapControl(); |
|
72 |
ProjectExtent extent = ProjectFactory.createExtent(); |
|
73 |
extent.setDescription(name); |
|
74 |
extent.setExtent(mapa.getViewPort().getExtent()); |
|
75 |
project.addExtent(extent); |
|
76 |
|
|
81 |
|
|
77 | 82 |
// crear track sino existe |
78 | 83 |
ac = this.getAnimationContainer(); |
79 | 84 |
animationTimeTrack = this.getAnimationTimeTrack( |
... | ... | |
86 | 91 |
AKFinterval.setEndTime(1.0); |
87 | 92 |
} |
88 | 93 |
|
89 |
// generar lista de keyframes |
|
94 |
// If the w is instance of View |
|
95 |
if (w instanceof View) { |
|
90 | 96 |
|
91 |
ProjectExtent[] extentsList = project.getExtents(); |
|
92 |
List keyFrameList = new ArrayList(); |
|
93 |
for (int i = 0; i < extentsList.length; i++) { |
|
94 |
ProjectExtent projectExtent = extentsList[i]; |
|
95 |
KeyFrame2D kf2D = new KeyFrame2D(); |
|
96 |
double fin = AKFinterval.getEndTime(); |
|
97 |
double ini = AKFinterval.getInitialTime(); |
|
98 |
double size = extentsList.length; |
|
99 |
// Calcular el tiempo de insercion |
|
100 |
double tiempo = 0.0; |
|
101 |
if (i != 0) |
|
102 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
|
103 |
// (AKFinterval.getEndTime() - AKFinterval |
|
104 |
// .getInitialTime()) / extentsList.length); |
|
105 |
kf2D.setTime(tiempo); |
|
106 |
// hacer funcion de insercion o adapter |
|
107 |
// kf2D.CapturesProperties(projectExtent); |
|
108 |
kf2D.setAnimatedObject(projectExtent); |
|
109 |
keyFrameList.add(kf2D); |
|
97 |
BaseView view = (BaseView) w; |
|
98 |
MapControl mapa = view.getMapControl(); |
|
99 |
ProjectExtent extent = ProjectFactory.createExtent(); |
|
100 |
extent.setDescription(name); |
|
101 |
extent.setExtent(mapa.getViewPort().getExtent()); |
|
102 |
project.addExtent(extent); |
|
110 | 103 |
|
104 |
// generar lista de keyframes |
|
105 |
|
|
106 |
ProjectExtent[] extentsList = project.getExtents(); |
|
107 |
keyFrameList = new ArrayList(); |
|
108 |
for (int i = 0; i < extentsList.length; i++) { |
|
109 |
ProjectExtent projectExtent = extentsList[i]; |
|
110 |
KeyFrame2D kf2D = new KeyFrame2D(); |
|
111 |
double fin = AKFinterval.getEndTime(); |
|
112 |
double ini = AKFinterval.getInitialTime(); |
|
113 |
double size = extentsList.length; |
|
114 |
// Calcular el tiempo de insercion |
|
115 |
double tiempo = 0.0; |
|
116 |
if (i != 0) |
|
117 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
|
118 |
// (AKFinterval.getEndTime() - AKFinterval |
|
119 |
// .getInitialTime()) / extentsList.length); |
|
120 |
kf2D.setTime(tiempo); |
|
121 |
// hacer funcion de insercion o adapter |
|
122 |
// kf2D.CapturesProperties(projectExtent); |
|
123 |
kf2D.setAnimatedObject(projectExtent); |
|
124 |
keyFrameList.add(kf2D); |
|
125 |
|
|
126 |
} |
|
111 | 127 |
} |
128 |
|
|
129 |
if (w instanceof View3D) { |
|
130 |
|
|
131 |
View3D view = (View3D) w; |
|
132 |
Camera ca = view.getCamera(); |
|
133 |
|
|
134 |
ProjectCamera camera = new ProjectCamera(); |
|
135 |
camera.setDescription(name); |
|
136 |
camera.setCamera(ca); |
|
137 |
|
|
138 |
Object[] l = project.getCameras(); |
|
139 |
|
|
140 |
|
|
141 |
project.addCamera(camera); |
|
142 |
|
|
143 |
|
|
144 |
// generar lista de keyframes |
|
145 |
|
|
146 |
Object[] extentsList = project.getCameras(); |
|
147 |
keyFrameList = new ArrayList(); |
|
148 |
for (int i = 0; i < extentsList.length; i++) { |
|
149 |
ProjectCamera projectCamera = (ProjectCamera) extentsList[i]; |
|
150 |
KeyFrame3DFlat kf2D = new KeyFrame3DFlat(); |
|
151 |
double fin = AKFinterval.getEndTime(); |
|
152 |
double ini = AKFinterval.getInitialTime(); |
|
153 |
double size = extentsList.length; |
|
154 |
// Calcular el tiempo de insercion |
|
155 |
double tiempo = 0.0; |
|
156 |
if (i != 0) |
|
157 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
|
158 |
// (AKFinterval.getEndTime() - AKFinterval |
|
159 |
// .getInitialTime()) / extentsList.length); |
|
160 |
kf2D.setTime(tiempo); |
|
161 |
// hacer funcion de insercion o adapter |
|
162 |
// kf2D.CapturesProperties(projectExtent); |
|
163 |
kf2D.setAnimatedObject(projectCamera); |
|
164 |
keyFrameList.add(kf2D); |
|
165 |
|
|
166 |
} |
|
167 |
} |
|
168 |
|
|
169 |
|
|
112 | 170 |
AKFinterval.setKeyFrameList(keyFrameList); |
113 | 171 |
|
114 | 172 |
System.out.println(ac); |
... | ... | |
123 | 181 |
private AnimationTimeTrack getAnimationTimeTrack(String name, |
124 | 182 |
AnimationContainer ac) { |
125 | 183 |
AnimationTimeTrack at = this.animationTimeTrack; |
126 |
if (ac.findTrack(name) == null) { |
|
184 |
IAnimationTrack aa = ac.findTrack(name); |
|
185 |
if (aa == null) { |
|
127 | 186 |
|
128 | 187 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
129 | 188 |
.getInstance(); |
130 | 189 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
131 | 190 |
.get("Animation")); |
191 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
|
192 |
.getMDIManager().getActiveWindow(); |
|
193 |
if (f instanceof View) { |
|
132 | 194 |
AnimationLayer2D animationLayer2D = null; |
133 | 195 |
try { |
134 | 196 |
animationLayer2D = (AnimationLayer2D) extPoint |
... | ... | |
142 | 204 |
} |
143 | 205 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animationLayer2D); |
144 | 206 |
at.setName(name); |
145 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
|
146 |
.getMDIManager().getActiveWindow(); |
|
147 |
View view = (View) f; |
|
148 |
at.setAnimatedObject(view); |
|
149 |
Interpolator2D inter2D = new Interpolator2D(); |
|
150 |
inter2D.setAnimatedObject(view); |
|
151 |
animationLayer2D.setInterpolator(inter2D); |
|
152 |
at.setAnimationType(animationLayer2D); |
|
153 |
animationLayer2D.setAnimatedObject(view); |
|
207 |
View view = (View) f; |
|
208 |
at.setAnimatedObject(view); |
|
209 |
Interpolator2D inter2D = new Interpolator2D(); |
|
210 |
inter2D.setAnimatedObject(view); |
|
211 |
animationLayer2D.setInterpolator(inter2D); |
|
212 |
at.setAnimationType(animationLayer2D); |
|
213 |
animationLayer2D.setAnimatedObject(view); |
|
214 |
} |
|
215 |
if (f instanceof View3D) { |
|
216 |
AnimationLayer3DFlat animationLayer3DFlat = null; |
|
217 |
try { |
|
218 |
animationLayer3DFlat = (AnimationLayer3DFlat) extPoint |
|
219 |
.create("AnimationLayer3DFlat"); |
|
220 |
} catch (InstantiationException e) { |
|
221 |
// TODO Auto-generated catch block |
|
222 |
e.printStackTrace(); |
|
223 |
} catch (IllegalAccessException e) { |
|
224 |
e.printStackTrace(); |
|
225 |
} |
|
226 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animationLayer3DFlat); |
|
227 |
at.setName(name); |
|
228 |
BaseView view = (BaseView) f; |
|
229 |
at.setAnimatedObject(view); |
|
230 |
Interpolator3DFlat inter3DFlat = new Interpolator3DFlat(); |
|
231 |
inter3DFlat.setAnimatedObject(view); |
|
232 |
animationLayer3DFlat.setInterpolator(inter3DFlat); |
|
233 |
at.setAnimationType(animationLayer3DFlat); |
|
234 |
animationLayer3DFlat.setAnimatedObject(view); |
|
235 |
} |
|
154 | 236 |
} |
155 | 237 |
return at; |
156 | 238 |
|
... | ... | |
171 | 253 |
|
172 | 254 |
// Register types |
173 | 255 |
AnimationTypeFactoryLayer2D.register(); |
256 |
// AnimationTypeFactoryLayer3DFlat.register(); |
|
174 | 257 |
} |
175 | 258 |
|
176 | 259 |
public boolean isEnabled() { |
Also available in: Unified diff