svn-gvsig-desktop / import / ext3D / branches / ext3D_v1.1 / extAnimationGUI / src / com / iver / ai2 / animationgui / gui / MenuAnimation3D.java @ 15420
History | View | Annotate | Download (6.34 KB)
1 |
package com.iver.ai2.animationgui.gui; |
---|---|
2 |
|
3 |
//import com.iver.ai2.gvsig3d.gui.AnimationContol3D;
|
4 |
import java.util.ArrayList; |
5 |
import java.util.List; |
6 |
|
7 |
import com.iver.andami.PluginServices; |
8 |
import com.iver.andami.plugins.Extension; |
9 |
import com.iver.andami.plugins.IExtension; |
10 |
import com.iver.andami.ui.mdiManager.IWindow; |
11 |
import com.iver.cit.gvsig.ProjectExtension; |
12 |
import com.iver.cit.gvsig.animation.AnimationContainer; |
13 |
import com.iver.cit.gvsig.animation.AnimationPlayer; |
14 |
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 |
import com.iver.cit.gvsig.animation.traks.AnimationTimeTrack; |
20 |
import com.iver.cit.gvsig.fmap.MapControl; |
21 |
import com.iver.cit.gvsig.project.Project; |
22 |
import com.iver.cit.gvsig.project.ProjectExtent; |
23 |
import com.iver.cit.gvsig.project.ProjectFactory; |
24 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
25 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
26 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
27 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
28 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
29 |
|
30 |
/**
|
31 |
* @author
|
32 |
* @since 1.1
|
33 |
*
|
34 |
* Menu of animation toolbar's options.
|
35 |
*/
|
36 |
|
37 |
public class MenuAnimation3D extends Extension { |
38 |
|
39 |
private Project project;
|
40 |
private int cont = 0; |
41 |
private AnimationContainer ac;
|
42 |
private AnimationTimeTrack animationTimeTrack = null; |
43 |
private AnimationKeyFrameInterval AKFinterval;
|
44 |
|
45 |
public void execute(String actionCommand) { |
46 |
|
47 |
// TODO Auto-generated method stub
|
48 |
// if the button pressed is animation control the animation panel is
|
49 |
// created.
|
50 |
if (actionCommand.equals("CONTROLES")) { |
51 |
System.out.println("pulsado boton controles !!!"); |
52 |
|
53 |
// ProjectExtent[] ex = project.getExtents();
|
54 |
// for (int i = 0; i < ex.length; i++) {
|
55 |
// ProjectExtent projectExtent = ex[i];
|
56 |
// System.out.println(projectExtent);
|
57 |
// }
|
58 |
|
59 |
AnimationContainer ac = project.getAnimationContainer(); |
60 |
AnimationPlayer ap = ac.getAnimationPlayer(); |
61 |
ap.setAnimationContainer(ac); |
62 |
AnimationContol3D fp = new AnimationContol3D(ap);
|
63 |
PluginServices.getMDIManager().addWindow((IWindow) fp); |
64 |
} else if (actionCommand.equals("ENCUADRECAP")) {// button capture |
65 |
// snapshot pressed.
|
66 |
System.out.println("pulsado boton de capturar encuadres!!!"); |
67 |
|
68 |
String name = "Animation-" + cont++; |
69 |
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 |
|
77 |
// crear track sino existe
|
78 |
ac = this.getAnimationContainer();
|
79 |
animationTimeTrack = this.getAnimationTimeTrack(
|
80 |
"encuadrator_track", ac);
|
81 |
// generar el intervalo
|
82 |
if (AKFinterval == null) { |
83 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
84 |
.createKeyFrameInterval(); |
85 |
AKFinterval.setInitialTime(0.0);
|
86 |
AKFinterval.setEndTime(1.0);
|
87 |
} |
88 |
|
89 |
// generar lista de keyframes
|
90 |
|
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); |
110 |
|
111 |
} |
112 |
AKFinterval.setKeyFrameList(keyFrameList); |
113 |
|
114 |
System.out.println(ac);
|
115 |
|
116 |
} else if (actionCommand.equals("CAPACAP")) {// button capture layer |
117 |
// pressed.
|
118 |
System.out.println("pulsado boton de capturar capa!!!"); |
119 |
} |
120 |
|
121 |
} |
122 |
|
123 |
private AnimationTimeTrack getAnimationTimeTrack(String name, |
124 |
AnimationContainer ac) { |
125 |
AnimationTimeTrack at = this.animationTimeTrack;
|
126 |
if (ac.findTrack(name) == null) { |
127 |
|
128 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
129 |
.getInstance(); |
130 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
131 |
.get("Animation"));
|
132 |
AnimationLayer2D animationLayer2D = null;
|
133 |
try {
|
134 |
animationLayer2D = (AnimationLayer2D) extPoint |
135 |
.create("AnimationLayer2D");
|
136 |
} catch (InstantiationException e) { |
137 |
// TODO Auto-generated catch block
|
138 |
e.printStackTrace(); |
139 |
} catch (IllegalAccessException e) { |
140 |
// TODO Auto-generated catch block
|
141 |
e.printStackTrace(); |
142 |
} |
143 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animationLayer2D); |
144 |
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); |
154 |
} |
155 |
return at;
|
156 |
|
157 |
} |
158 |
|
159 |
private AnimationContainer getAnimationContainer() {
|
160 |
|
161 |
return project.getAnimationContainer();
|
162 |
} |
163 |
|
164 |
public void initialize() { |
165 |
|
166 |
// Getting the project using pluggin services
|
167 |
IExtension extension = PluginServices |
168 |
.getExtension(com.iver.cit.gvsig.ProjectExtension.class); |
169 |
ProjectExtension pe = (ProjectExtension) extension; |
170 |
project = pe.getProject(); |
171 |
|
172 |
// Register types
|
173 |
AnimationTypeFactoryLayer2D.register(); |
174 |
} |
175 |
|
176 |
public boolean isEnabled() { |
177 |
// TODO Auto-generated method stub
|
178 |
return true; |
179 |
} |
180 |
|
181 |
public boolean isVisible() { |
182 |
|
183 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
184 |
.getMDIManager().getActiveWindow(); |
185 |
|
186 |
if (f == null) { |
187 |
return false; |
188 |
} |
189 |
|
190 |
// Only isVisible = true, where the view3D have layers
|
191 |
if (f instanceof BaseView) { |
192 |
return true; |
193 |
} |
194 |
return false; |
195 |
} |
196 |
|
197 |
} |