Revision 20095
trunk/extensions/extAnimationGUI/.classpath | ||
---|---|---|
14 | 14 |
<classpathentry kind="lib" path="/ext3Dgui/lib/gluegen-rt-1.1.0.jar"/> |
15 | 15 |
<classpathentry kind="lib" path="/ext3Dgui/lib/jogl-1.1.0.jar"/> |
16 | 16 |
<classpathentry kind="lib" path="/ext3Dgui/lib/libNative-1.0.jar"/> |
17 |
<classpathentry kind="lib" path="/appgvSIG/lib/gvsig-animation.jar" sourcepath="/libAnimation_BACK"/> |
|
17 |
<classpathentry kind="lib" path="/appgvSIG/lib/gvsig-animation.jar" sourcepath="/libAnimation_BACK/src"/>
|
|
18 | 18 |
<classpathentry kind="lib" path="/ext3Dgui/lib/libosgvp-core-2.0.4.jar"/> |
19 | 19 |
<classpathentry kind="lib" path="/ext3Dgui/lib/libosgvp-ephemeris-2.0.4.jar"/> |
20 | 20 |
<classpathentry kind="lib" path="/ext3Dgui/lib/libosgvp-examples-2.0.4.jar"/> |
... | ... | |
22 | 22 |
<classpathentry kind="lib" path="/ext3Dgui/lib/libosgvp-manipulator-2.0.4.jar"/> |
23 | 23 |
<classpathentry kind="lib" path="/ext3Dgui/lib/libosgvp-planets-2.0.4.jar"/> |
24 | 24 |
<classpathentry kind="lib" path="/ext3Dgui/lib/libosgvp-viewer-2.0.4.jar"/> |
25 |
<classpathentry kind="lib" path="/libFMap/lib/gdbms-0.8-SNAPSHOT.jar" sourcepath="/libGDBMS"/> |
|
26 |
<classpathentry kind="lib" path="/_fwAndami/lib/org.gvsig.exceptions.jar"/> |
|
25 | 27 |
<classpathentry kind="output" path="bin"/> |
26 | 28 |
</classpath> |
trunk/extensions/extAnimationGUI/config/config.xml | ||
---|---|---|
5 | 5 |
<depends plugin-name="com.iver.ai2.animation3D" /> |
6 | 6 |
<depends plugin-name="com.iver.ai2.animation2D" /> |
7 | 7 |
<depends plugin-name="com.iver.ai2.animationCommon" /> |
8 |
<libraries library-dir="./lib"/> |
|
9 |
<resourceBundle name="text"/> |
|
8 |
<libraries library-dir="./lib" />
|
|
9 |
<resourceBundle name="text" />
|
|
10 | 10 |
<extensions> |
11 |
<extension class-name="com.iver.ai2.animationgui.gui.MenuAnimation3D" |
|
11 |
<extension class-name="com.iver.ai2.animationgui.gui.AnimationDocumentRegister" |
|
12 |
description="Shows a Animation" active="true" priority="50"> |
|
13 |
<tool-bar name="Tools3D"> |
|
14 |
<selectable-tool icon="images/camera_add.png" |
|
15 |
action-command="SHOW3D" tooltip="show_3Dview" /> |
|
16 |
</tool-bar> |
|
17 |
</extension> |
|
18 |
<extension |
|
19 |
class-name="com.iver.ai2.animationgui.gui.MenuAnimation3D" |
|
12 | 20 |
description="Extensi?n encargada de abrir el menu de animaci?n 3D." |
13 |
active="true" |
|
14 |
priority="40"> |
|
15 |
<menu text="Animacion/Borrar_animacion" action-command="BORRAR" /> |
|
16 |
<menu text="Animacion/Capturar_encuadre" action-command="ENCUADRECAP" /> |
|
17 |
<menu text="Animacion/Capturar_capa" action-command="CAPACAP" /> |
|
18 |
<menu text="Animacion/Exportar_video" action-command="EXPORTARVIDEO" /> |
|
19 |
<menu text="Animacion/Controles_de_animacion" action-command="CONTROLES" /> |
|
20 |
<tool-bar name="Animacion3D" position="6" > |
|
21 |
<action-tool icon="images/camera_link.png" action-command="ENCUADRECAP" tooltip="Capturar_encuadre" position="1"/> |
|
22 |
<action-tool icon="images/camera_add.png" action-command="CAPACAP" tooltip="Capturar_capa" position="2"/> |
|
23 |
<action-tool icon="images/camera_edit.png" action-command="CONTROLES" tooltip="Controles_de_animacion" position="3"/> |
|
21 |
active="true" priority="40"> |
|
22 |
<menu text="Animacion/Borrar_animacion" |
|
23 |
action-command="BORRAR" /> |
|
24 |
<menu text="Animacion/Capturar_encuadre" |
|
25 |
action-command="ENCUADRECAP" /> |
|
26 |
<menu text="Animacion/Capturar_capa" |
|
27 |
action-command="CAPACAP" /> |
|
28 |
<menu text="Animacion/Exportar_video" |
|
29 |
action-command="EXPORTARVIDEO" /> |
|
30 |
<menu text="Animacion/Controles_de_animacion" |
|
31 |
action-command="CONTROLES" /> |
|
32 |
<tool-bar name="Animacion3D" position="6"> |
|
33 |
<action-tool icon="images/camera_link.png" |
|
34 |
action-command="ENCUADRECAP" tooltip="Capturar_encuadre" |
|
35 |
position="1" /> |
|
36 |
<action-tool icon="images/camera_add.png" |
|
37 |
action-command="CAPACAP" tooltip="Capturar_capa" position="2" /> |
|
38 |
<action-tool icon="images/camera_edit.png" |
|
39 |
action-command="CONTROLES" tooltip="Controles_de_animacion" |
|
40 |
position="3" /> |
|
24 | 41 |
</tool-bar> |
25 |
|
|
42 |
|
|
26 | 43 |
</extension> |
27 |
<extension class-name="com.iver.ai2.animationgui.gui.MenuAnimationTransparency" |
|
44 |
<extension |
|
45 |
class-name="com.iver.ai2.animationgui.gui.MenuAnimationTransparency" |
|
28 | 46 |
description="Extensi?n encargada de abrir el menu de animaci?n 3D." |
29 |
active="true" |
|
30 |
priority="40"> |
|
31 |
<tool-bar name="Animacion3DTransparency" position="7" > |
|
32 |
<action-tool icon="images/trans6.png" action-command="CREARANIMTRANSP" tooltip="Crear_animacion_trans" position="1"/> |
|
33 |
</tool-bar> |
|
34 |
</extension> |
|
47 |
active="true" priority="40"> |
|
48 |
<tool-bar name="Animacion3DTransparency" position="7"> |
|
49 |
<action-tool icon="images/trans6.png" |
|
50 |
action-command="CREARANIMTRANSP" tooltip="Crear_animacion_trans" |
|
51 |
position="1" /> |
|
52 |
</tool-bar> |
|
53 |
</extension> |
|
35 | 54 |
</extensions> |
36 | 55 |
</plugin-config> |
trunk/extensions/extAnimationGUI/src/com/iver/ai2/animationgui/gui/MenuAnimation3D.java | ||
---|---|---|
1 | 1 |
package com.iver.ai2.animationgui.gui; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
3 |
import javax.swing.JOptionPane; |
|
5 | 4 |
|
5 |
import com.iver.ai2.animationgui.gui.document.ProjectAnimationDocument; |
|
6 | 6 |
import com.iver.ai2.animationgui.gui.toc.TocAnimationDate; |
7 |
import com.iver.ai2.animationgui.gui.util.AnimationUtils; |
|
7 | 8 |
import com.iver.ai2.gvsig3d.camera.ProjectCamera; |
8 |
import com.iver.ai2.gvsig3dgui.view.View3D; |
|
9 | 9 |
import com.iver.andami.PluginServices; |
10 | 10 |
import com.iver.andami.plugins.Extension; |
11 | 11 |
import com.iver.andami.plugins.IExtension; |
... | ... | |
13 | 13 |
import com.iver.cit.gvsig.ProjectExtension; |
14 | 14 |
import com.iver.cit.gvsig.animation.AnimationContainer; |
15 | 15 |
import com.iver.cit.gvsig.animation.AnimationPlayer; |
16 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
17 |
import com.iver.cit.gvsig.animation.animatedObject.AnimatedObjectBase; |
|
18 |
import com.iver.cit.gvsig.animation.interval.AnimationKeyFrameInterval; |
|
19 |
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame; |
|
20 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.FuntionFactory; |
|
21 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
|
22 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolatorTimeFuntion; |
|
23 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.InterpolatorFactory; |
|
24 |
import com.iver.cit.gvsig.animation.traks.AnimationTimeTrack; |
|
25 |
import com.iver.cit.gvsig.animation.traks.IAnimationTrack; |
|
26 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
27 | 16 |
import com.iver.cit.gvsig.project.Project; |
28 |
import com.iver.cit.gvsig.project.ProjectExtent; |
|
29 |
import com.iver.cit.gvsig.project.ProjectFactory; |
|
30 | 17 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
31 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
|
32 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
|
33 | 18 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
34 | 19 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
35 | 20 |
|
36 |
import es.upv.ai2.osgvp.viewer.Camera; |
|
37 |
|
|
38 | 21 |
/** |
39 | 22 |
* @author |
40 | 23 |
* @since 1.1 |
... | ... | |
44 | 27 |
|
45 | 28 |
public class MenuAnimation3D extends Extension { |
46 | 29 |
|
30 |
// private variable that contains the project |
|
47 | 31 |
private Project project; |
48 |
private int cont = 0; |
|
49 |
private AnimationContainer ac; |
|
50 |
private AnimationTimeTrack animationTimeTrack = null; |
|
51 |
private AnimationKeyFrameInterval AKFinterval; |
|
52 |
private AnimatedObjectBase object3D = new AnimatedObjectBase(); |
|
53 |
private AnimatedObjectBase object2D = new AnimatedObjectBase(); |
|
54 |
private String AnimationPrefix = "Animation-"; |
|
32 |
// It is the project Document create to create a fast animation. |
|
33 |
private ProjectAnimationDocument pad; |
|
55 | 34 |
|
56 | 35 |
public void execute(String actionCommand) { |
57 | 36 |
|
58 |
// TODO Auto-generated method stub |
|
37 |
AnimationContainer ac; |
|
38 |
String prefix = "Default-animation-document"; |
|
59 | 39 |
// if the button pressed is animation control the animation panel is |
60 | 40 |
// created. |
61 | 41 |
if (actionCommand.equals("CONTROLES")) { |
62 |
System.out.println("pulsado boton controles !!!"); |
|
42 |
// Getting the animation container. |
|
43 |
if (pad != null) { |
|
44 |
ac = pad.getAnimationContainer(); |
|
45 |
AnimationPlayer ap = ac.getAnimationPlayer(); |
|
46 |
ap.setAnimationContainer(ac); |
|
47 |
AnimationContol3D fp = new AnimationContol3D(ap); |
|
48 |
PluginServices.getMDIManager().addWindow((IWindow) fp); |
|
49 |
} else { |
|
50 |
if (AnimationUtils.exitsProject(prefix, project)){ |
|
51 |
ac = AnimationUtils.getProjectDocument(prefix, project).getAnimationContainer(); |
|
52 |
AnimationPlayer ap = ac.getAnimationPlayer(); |
|
53 |
ap.setAnimationContainer(ac); |
|
54 |
AnimationContol3D fp = new AnimationContol3D(ap); |
|
55 |
PluginServices.getMDIManager().addWindow((IWindow) fp); |
|
56 |
}else{ |
|
57 |
// Show a message that indicates why it is impossible to open |
|
58 |
// the player |
|
59 |
JOptionPane |
|
60 |
.showMessageDialog(null, |
|
61 |
"There is not any animation document. Please create one"); |
|
62 |
} |
|
63 |
} |
|
63 | 64 |
|
64 |
// ProjectExtent[] ex = project.getExtents(); |
|
65 |
// for (int i = 0; i < ex.length; i++) { |
|
66 |
// ProjectExtent projectExtent = ex[i]; |
|
67 |
// System.out.println(projectExtent); |
|
68 |
// } |
|
69 |
|
|
70 |
AnimationContainer ac = (AnimationContainer) project.getAnimationContainer(); |
|
71 |
AnimationPlayer ap = ac.getAnimationPlayer(); |
|
72 |
ap.setAnimationContainer(ac); |
|
73 |
AnimationContol3D fp = new AnimationContol3D(ap); |
|
74 |
PluginServices.getMDIManager().addWindow((IWindow) fp); |
|
75 |
|
|
76 | 65 |
} else if (actionCommand.equals("ENCUADRECAP")) {// button capture |
77 |
// snapshot pressed. |
|
78 |
System.out.println("pulsado boton de capturar encuadres!!!"); |
|
66 |
// if there is not create the default animation. we will create it. |
|
67 |
pad = AnimationUtils.createAnimationDocument(prefix, project); |
|
68 |
if (!AnimationUtils.exitsProject(prefix, project)){ |
|
69 |
project.addDocument(pad); |
|
70 |
} |
|
79 | 71 |
|
80 |
String name = AnimationPrefix + cont++; |
|
81 |
List keyFrameList = null; |
|
82 |
|
|
83 | 72 |
// Getting the active windows |
84 | 73 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
85 |
|
|
74 |
|
|
86 | 75 |
// Getting the animation container. |
87 |
ac = this.getAnimationContainer();
|
|
76 |
ac = pad.getAnimationContainer();
|
|
88 | 77 |
|
89 |
// If the window instance is View, it will manage extends 2D |
|
90 |
if (w instanceof View) { |
|
91 |
|
|
92 |
// Getting the animation extension point. |
|
93 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
94 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints.get("Animation")); |
|
95 |
|
|
96 |
// Creating new track |
|
97 |
animationTimeTrack = this.getAnimationTimeTrack( |
|
98 |
"encuadrator_track_2D", ac); |
|
99 |
// Creating the interval |
|
100 |
if (AKFinterval == null) { |
|
101 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
|
102 |
.createKeyFrameInterval(); |
|
103 |
// Setting up interval properties. |
|
104 |
AKFinterval.setInitialTime(0.0); |
|
105 |
AKFinterval.setEndTime(1.0); |
|
106 |
} |
|
107 |
|
|
108 |
// Getting the current extend and adding to project extends. |
|
109 |
BaseView view = (BaseView) w; |
|
110 |
MapControl mapa = view.getMapControl(); |
|
111 |
ProjectExtent extent = ProjectFactory.createExtent(); |
|
112 |
extent.setDescription(name); |
|
113 |
extent.setExtent(mapa.getViewPort().getExtent()); |
|
114 |
project.addExtent(extent); |
|
78 |
// Capture the new encuadrator |
|
79 |
AnimationUtils.captureEncuadrator((BaseView) w, ac, prefix); |
|
115 | 80 |
|
116 |
// Creating the keyframe list. |
|
117 |
ProjectExtent[] extentsList = project.getExtents(); |
|
118 |
keyFrameList = new ArrayList(); |
|
119 |
for (int i = 0; i < extentsList.length; i++) { |
|
120 |
ProjectExtent projectExtent = extentsList[i]; |
|
121 |
if (projectExtent.getDescription().contains(AnimationPrefix)){ |
|
122 |
IKeyFrame kf2D = null; |
|
123 |
try { |
|
124 |
kf2D = (IKeyFrame)extPoint.create("KeyFrame2D"); |
|
125 |
} catch (InstantiationException e) { |
|
126 |
//TODO stop this loop and show a advertise message. |
|
127 |
e.printStackTrace(); |
|
128 |
} catch (IllegalAccessException e) { |
|
129 |
e.printStackTrace(); |
|
130 |
} |
|
131 |
|
|
132 |
// Setting up the initial and end time interval. |
|
133 |
double fin = AKFinterval.getEndTime(); |
|
134 |
double ini = AKFinterval.getInitialTime(); |
|
135 |
double size = extentsList.length; |
|
136 |
// Calculating the insertion time. |
|
137 |
double tiempo = 0.0; |
|
138 |
if (i != 0) |
|
139 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
|
140 |
kf2D.setTime(tiempo); |
|
141 |
// hacer funcion de insercion o adapter |
|
142 |
kf2D.setAnimatedObject(projectExtent); |
|
143 |
kf2D.CapturesProperties(); |
|
144 |
keyFrameList.add(kf2D); |
|
145 |
} |
|
146 |
} |
|
147 |
} |
|
148 |
|
|
149 |
if (w instanceof View3D) { |
|
150 |
|
|
151 |
// Getting the animation extension point. |
|
152 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
153 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints.get("Animation")); |
|
154 |
|
|
155 |
// Creating new track |
|
156 |
animationTimeTrack = this.getAnimationTimeTrack( |
|
157 |
"encuadrator_track_3D", ac); |
|
158 |
|
|
159 |
// Creating the interval |
|
160 |
if (AKFinterval == null) { |
|
161 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
|
162 |
.createKeyFrameInterval(); |
|
163 |
AKFinterval.setInitialTime(0.0); |
|
164 |
AKFinterval.setEndTime(1.0); |
|
165 |
} |
|
166 |
|
|
167 |
// Getting the current camera position and insert it into project camera list. |
|
168 |
View3D view = (View3D) w; |
|
169 |
Camera ca = view.getCamera(); |
|
170 |
ProjectCamera camera = new ProjectCamera(); |
|
171 |
camera.setDescription(name); |
|
172 |
camera.setCamera(ca); |
|
173 |
project.addCamera(camera); |
|
174 |
|
|
175 |
// Creating key frame list |
|
176 |
Object[] extentsList = project.getCameras(); |
|
177 |
keyFrameList = new ArrayList(); |
|
178 |
for (int i = 0; i < extentsList.length; i++) { |
|
179 |
ProjectCamera projectCamera = (ProjectCamera) extentsList[i]; |
|
180 |
if (projectCamera.getDescription().contains(AnimationPrefix)){ |
|
181 |
IKeyFrame kf3D = null; |
|
182 |
try { |
|
183 |
kf3D = (IKeyFrame)extPoint.create("KeyFrame3DFlat"); |
|
184 |
} catch (InstantiationException e) { |
|
185 |
e.printStackTrace(); |
|
186 |
} catch (IllegalAccessException e) { |
|
187 |
e.printStackTrace(); |
|
188 |
} |
|
189 |
|
|
190 |
// Setting up the initial and end time interval. |
|
191 |
double fin = AKFinterval.getEndTime(); |
|
192 |
double ini = AKFinterval.getInitialTime(); |
|
193 |
double size = extentsList.length; |
|
194 |
// Calculating the correct time for this key frame. |
|
195 |
double tiempo = 0.0; |
|
196 |
if (i != 0) |
|
197 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
|
198 |
// Setting the time. |
|
199 |
kf3D.setTime(tiempo); |
|
200 |
// hacer funcion de insercion o adapter |
|
201 |
kf3D.setAnimatedObject(projectCamera); |
|
202 |
kf3D.CapturesProperties(); |
|
203 |
keyFrameList.add(kf3D); |
|
204 |
} |
|
205 |
} |
|
206 |
} |
|
207 |
AKFinterval.setKeyFrameList(keyFrameList); |
|
208 |
System.out.println(ac); |
|
209 | 81 |
} else if (actionCommand.equals("CAPACAP")) {// button capture layer |
210 | 82 |
// pressed. |
211 | 83 |
System.out.println("pulsado boton de capturar capa!!!"); |
212 |
} else if (actionCommand.equals("BORRAR")){ |
|
213 |
removeCameras(AnimationPrefix); |
|
214 |
AKFinterval = null; |
|
215 |
cont = 0; |
|
216 |
ac = this.getAnimationContainer(); |
|
217 |
ac.removeAllTrack();
|
|
84 |
} else if (actionCommand.equals("BORRAR")) {
|
|
85 |
// removeCameras(AnimationPrefix);
|
|
86 |
// // AKFinterval = null;
|
|
87 |
// cont = 0;
|
|
88 |
// ac = this.getAnimationContainer();
|
|
89 |
// ac.removeAllTrack();
|
|
218 | 90 |
} |
219 |
|
|
220 | 91 |
|
221 | 92 |
} |
222 |
|
|
93 |
|
|
223 | 94 |
/** |
224 |
* This method removes all the captures that there are in the encuadrator with the substring "substring" |
|
225 |
* |
|
226 |
* @param substring the method removes all the captures that contain this substring. |
|
95 |
* This method removes all the captures that there are in the encuadrator |
|
96 |
* with the substring "substring" |
|
227 | 97 |
* |
98 |
* @param substring |
|
99 |
* the method removes all the captures that contain this |
|
100 |
* substring. |
|
101 |
* |
|
228 | 102 |
*/ |
229 |
void removeCameras(String substring){ |
|
103 |
void removeCameras(String substring) {
|
|
230 | 104 |
// Remove all animation keyframe from the encuadrator. |
231 | 105 |
Object[] pcList = project.getCameras(); |
232 | 106 |
int i = 0; |
233 | 107 |
while (i < pcList.length) { |
234 | 108 |
ProjectCamera projectCamera = (ProjectCamera) pcList[i]; |
235 |
if(projectCamera.getDescription().contains(substring)){
|
|
109 |
if (projectCamera.getDescription().contains(substring)) {
|
|
236 | 110 |
project.removeCamera(i); |
237 | 111 |
pcList = project.getCameras(); |
238 | 112 |
} else { |
... | ... | |
241 | 115 |
} |
242 | 116 |
} |
243 | 117 |
|
118 |
public void postInitialize() { |
|
244 | 119 |
|
245 |
private AnimationTimeTrack getAnimationTimeTrack(String name, |
|
246 |
AnimationContainer ac) { |
|
247 |
|
|
248 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
|
249 |
.getMDIManager().getActiveWindow(); |
|
250 |
|
|
251 |
AnimationTimeTrack at = this.animationTimeTrack; |
|
252 |
IAnimationTrack aa = ac.findTrack(name); |
|
253 |
if (aa == null) { |
|
254 |
|
|
255 |
// Getting the extension point. |
|
256 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
257 |
.getInstance(); |
|
258 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
259 |
.get("Animation")); |
|
260 |
|
|
261 |
// If f is a 2D windows, it will create with 2D specific animation type. |
|
262 |
if (f instanceof View) { |
|
263 |
|
|
264 |
// Finding if there are an 3D animation track. |
|
265 |
IAnimationTrack trackAux = ac.findTrack("encuadrator_track_3D"); |
|
266 |
if (trackAux != null) { |
|
267 |
// if there are one, it will disable. |
|
268 |
trackAux.setEnabale(false); |
|
269 |
} |
|
270 |
IAnimationType animationLayer2D = null; |
|
271 |
try { |
|
272 |
animationLayer2D = (IAnimationType) extPoint |
|
273 |
.create("AnimationLayer2D"); |
|
274 |
} catch (InstantiationException e) { |
|
275 |
// TODO Auto-generated catch block |
|
276 |
e.printStackTrace(); |
|
277 |
} catch (IllegalAccessException e) { |
|
278 |
// TODO Auto-generated catch block |
|
279 |
e.printStackTrace(); |
|
280 |
} |
|
281 |
// Setting up the track properties |
|
282 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animationLayer2D); |
|
283 |
at.setName(name); |
|
284 |
at.setEnabale(true); |
|
285 |
// Setting up the animated object |
|
286 |
View view = (View) f; |
|
287 |
at.setAnimatedObject(object2D); |
|
288 |
|
|
289 |
// Getting the interpolator |
|
290 |
IInterpolator inter2D = InterpolatorFactory.createObject("Interpolator2D"); |
|
291 |
object2D.addAnimatedObject("view2D", view); |
|
292 |
// Getting the interpolator funcion |
|
293 |
IInterpolatorTimeFuntion funtion = FuntionFactory.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion"); |
|
294 |
inter2D.setFuntion(funtion); |
|
295 |
|
|
296 |
animationLayer2D.setInterpolator(inter2D); |
|
297 |
at.setAnimationType(animationLayer2D); |
|
298 |
animationLayer2D.setAnimatedObject(object2D); |
|
299 |
} |
|
300 |
if (f instanceof View3D) { |
|
301 |
// Finding if there are an 2D animation track. |
|
302 |
IAnimationTrack trackAux = ac.findTrack("encuadrator_track_2D"); |
|
303 |
if (trackAux != null) { |
|
304 |
// if there are one, it will disable. |
|
305 |
trackAux.setEnabale(false); |
|
306 |
} |
|
307 |
IAnimationType animationLayer3DFlat = null; |
|
308 |
try { |
|
309 |
animationLayer3DFlat = (IAnimationType) extPoint |
|
310 |
.create("AnimationLayer3DFlat"); |
|
311 |
} catch (InstantiationException e) { |
|
312 |
// TODO Auto-generated catch block |
|
313 |
e.printStackTrace(); |
|
314 |
} catch (IllegalAccessException e) { |
|
315 |
e.printStackTrace(); |
|
316 |
} |
|
317 |
at = (AnimationTimeTrack) ac |
|
318 |
.CreateTimeTrack(animationLayer3DFlat); |
|
319 |
|
|
320 |
at.setName(name); |
|
321 |
at.setEnabale(true); |
|
322 |
|
|
323 |
BaseView view = (BaseView) f; |
|
324 |
object3D.addAnimatedObject("view", view); |
|
325 |
at.setAnimatedObject(object3D); |
|
326 |
|
|
327 |
IInterpolator inter3DFlat = InterpolatorFactory.createObject("Interpolator3DFlat"); |
|
328 |
IInterpolatorTimeFuntion funtion = FuntionFactory.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion"); |
|
329 |
inter3DFlat.setFuntion(funtion); |
|
330 |
animationLayer3DFlat.setInterpolator(inter3DFlat); |
|
331 |
at.setAnimationType(animationLayer3DFlat); |
|
332 |
animationLayer3DFlat.setAnimatedObject(object3D); |
|
333 |
} |
|
334 |
} |
|
335 |
|
|
336 |
if (f instanceof View3D) { |
|
337 |
IAnimationTrack trackAux = ac.findTrack("encuadrator_track_2D"); |
|
338 |
if (trackAux != null) { |
|
339 |
trackAux.setEnabale(false); |
|
340 |
} |
|
341 |
} |
|
342 |
|
|
343 |
if (f instanceof View) { |
|
344 |
IAnimationTrack trackAux = ac.findTrack("encuadrator_track_3D"); |
|
345 |
if (trackAux != null) { |
|
346 |
trackAux.setEnabale(false); |
|
347 |
} |
|
348 |
} |
|
349 |
return at; |
|
350 |
|
|
351 |
} |
|
352 |
|
|
353 |
private AnimationContainer getAnimationContainer() { |
|
354 |
|
|
355 |
return (AnimationContainer) project.getAnimationContainer(); |
|
356 |
} |
|
357 |
|
|
358 |
|
|
359 |
public void postInitialize(){ |
|
360 |
|
|
361 | 120 |
IExtension extension = PluginServices |
362 |
.getExtension(com.iver.cit.gvsig.ProjectExtension.class); |
|
121 |
.getExtension(com.iver.cit.gvsig.ProjectExtension.class);
|
|
363 | 122 |
ProjectExtension pe = (ProjectExtension) extension; |
364 | 123 |
project = pe.getProject(); |
365 |
|
|
366 |
|
|
367 |
ac = (AnimationContainer) project.getAnimationContainer(); |
|
368 |
ac = this.getAnimationContainer(); |
|
369 |
if (ac == null){ |
|
370 |
ac = new AnimationContainer(); |
|
371 |
project.setAnimationContainer(ac); |
|
372 |
} |
|
373 |
|
|
124 |
|
|
374 | 125 |
PluginServices.getIconTheme().registerDefault( |
375 | 126 |
"camera-link-icon", |
376 | 127 |
this.getClass().getClassLoader().getResource( |
377 |
"images/camera_link.png")); |
|
128 |
"images/camera_link.png"));
|
|
378 | 129 |
PluginServices.getIconTheme().registerDefault( |
379 | 130 |
"camera-add-icon", |
380 | 131 |
this.getClass().getClassLoader().getResource( |
381 |
"images/camera_add.png")); |
|
132 |
"images/camera_add.png"));
|
|
382 | 133 |
PluginServices.getIconTheme().registerDefault( |
383 | 134 |
"camera-edit-icon", |
384 | 135 |
this.getClass().getClassLoader().getResource( |
385 |
"images/camera_edit.png")); |
|
386 |
|
|
136 |
"images/camera_edit.png"));
|
|
137 |
|
|
387 | 138 |
} |
388 |
|
|
389 | 139 |
|
390 | 140 |
public void initialize() { |
391 |
|
|
141 |
|
|
392 | 142 |
// Registering TOC actions |
393 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
394 |
extensionPoints.add("View_TocActions","Generar animacion temporal",new TocAnimationDate()); |
|
143 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
144 |
.getInstance(); |
|
145 |
extensionPoints.add("View_TocActions", "Generar animacion temporal", |
|
146 |
new TocAnimationDate()); |
|
395 | 147 |
} |
396 | 148 |
|
397 | 149 |
public boolean isEnabled() { |
398 |
// TODO Auto-generated method stub |
|
399 | 150 |
return true; |
400 | 151 |
} |
401 | 152 |
|
trunk/extensions/extAnimationGUI/src/com/iver/ai2/animationgui/gui/util/AnimationUtils.java | ||
---|---|---|
1 |
package com.iver.ai2.animationgui.gui.util; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import com.iver.ai2.animationgui.gui.document.ProjectAnimationDocument; |
|
8 |
import com.iver.ai2.animationgui.gui.document.ProjectAnimationDocumentFactory; |
|
9 |
import com.iver.ai2.gvsig3d.camera.ProjectCamera; |
|
10 |
import com.iver.ai2.gvsig3dgui.view.View3D; |
|
11 |
import com.iver.andami.PluginServices; |
|
12 |
import com.iver.andami.plugins.IExtension; |
|
13 |
import com.iver.cit.gvsig.ProjectExtension; |
|
14 |
import com.iver.cit.gvsig.animation.AnimationContainer; |
|
15 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
16 |
import com.iver.cit.gvsig.animation.animatedObject.AnimatedObjectBase; |
|
17 |
import com.iver.cit.gvsig.animation.animatedObject.IAnimatedObject; |
|
18 |
import com.iver.cit.gvsig.animation.interval.AnimationKeyFrameInterval; |
|
19 |
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame; |
|
20 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.FuntionFactory; |
|
21 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
|
22 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolatorTimeFuntion; |
|
23 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.InterpolatorFactory; |
|
24 |
import com.iver.cit.gvsig.animation.traks.AnimationTimeTrack; |
|
25 |
import com.iver.cit.gvsig.animation.traks.IAnimationTrack; |
|
26 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
27 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
28 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
29 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
30 |
import com.iver.cit.gvsig.project.Project; |
|
31 |
import com.iver.cit.gvsig.project.ProjectExtent; |
|
32 |
import com.iver.cit.gvsig.project.ProjectFactory; |
|
33 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
|
34 |
import com.iver.cit.gvsig.project.documents.ProjectDocumentFactory; |
|
35 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
|
36 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
|
37 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
|
38 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
|
39 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
|
40 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
41 |
|
|
42 |
import es.upv.ai2.osgvp.planets.Planet; |
|
43 |
import es.upv.ai2.osgvp.viewer.Camera; |
|
44 |
|
|
45 |
public class AnimationUtils { |
|
46 |
|
|
47 |
private static String AnimationPrefix = "Animation-"; |
|
48 |
private static int cont2D = 0; |
|
49 |
private static int cont3D = 0; |
|
50 |
private AnimationTimeTrack animationTimeTrack = null; |
|
51 |
// private AnimatedObjectBase object3D = new AnimatedObjectBase(); |
|
52 |
// private AnimatedObjectBase object2D = new AnimatedObjectBase(); |
|
53 |
private static Project project; |
|
54 |
|
|
55 |
static { |
|
56 |
IExtension extension = PluginServices |
|
57 |
.getExtension(com.iver.cit.gvsig.ProjectExtension.class); |
|
58 |
ProjectExtension pe = (ProjectExtension) extension; |
|
59 |
project = pe.getProject(); |
|
60 |
} |
|
61 |
|
|
62 |
public static void captureEncuadrator(BaseView view, AnimationContainer ac, |
|
63 |
String prefix) { |
|
64 |
// snapshot pressed. |
|
65 |
System.out.println("pulsado boton de capturar encuadres!!!"); |
|
66 |
|
|
67 |
// If the window instance is View, it will manage extends 2D |
|
68 |
if (view instanceof View) { |
|
69 |
AnimationUtils.captureEncuadrator2D((View) view, ac, prefix); |
|
70 |
} |
|
71 |
|
|
72 |
if (view instanceof View3D) { |
|
73 |
AnimationUtils.captureEncuadrator3D((View3D) view, ac, prefix); |
|
74 |
} |
|
75 |
|
|
76 |
System.out.println(ac); |
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
public static void captureEncuadrator2D(View view, AnimationContainer ac, |
|
81 |
String prefix) { |
|
82 |
|
|
83 |
AnimationTimeTrack animationTimeTrack = null; |
|
84 |
AnimationKeyFrameInterval AKFinterval = null; |
|
85 |
List<IKeyFrame> keyFrameList = null; |
|
86 |
|
|
87 |
String baseName = prefix + "-" + view.getWindowInfo().getTitle() + "-" |
|
88 |
+ AnimationPrefix; |
|
89 |
String name = baseName + cont2D++; |
|
90 |
|
|
91 |
// Getting the animation extension point. |
|
92 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
93 |
.getInstance(); |
|
94 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
95 |
.get("Animation")); |
|
96 |
|
|
97 |
// Creating new track |
|
98 |
animationTimeTrack = AnimationUtils.getAnimationTimeTrack(baseName |
|
99 |
+ "-encuadrator_track_2D", ac, view); |
|
100 |
// Creating the interval |
|
101 |
List<AnimationKeyFrameInterval> intervalList = animationTimeTrack |
|
102 |
.getIntervalList(); |
|
103 |
if (intervalList != null) { |
|
104 |
for (Iterator iterator = intervalList.iterator(); iterator |
|
105 |
.hasNext();) { |
|
106 |
AnimationKeyFrameInterval animationKeyFrameInterval = (AnimationKeyFrameInterval) iterator |
|
107 |
.next(); |
|
108 |
if (animationKeyFrameInterval != null) { |
|
109 |
AKFinterval = animationKeyFrameInterval; |
|
110 |
} |
|
111 |
} |
|
112 |
} else { |
|
113 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
|
114 |
.createKeyFrameInterval(); |
|
115 |
// Setting up interval properties. |
|
116 |
AKFinterval.setInitialTime(0.0); |
|
117 |
AKFinterval.setEndTime(1.0); |
|
118 |
} |
|
119 |
|
|
120 |
// Getting the current extend and adding to project extends. |
|
121 |
MapControl mapa = view.getMapControl(); |
|
122 |
ProjectExtent extent = ProjectFactory.createExtent(); |
|
123 |
extent.setDescription(name); |
|
124 |
extent.setExtent(mapa.getViewPort().getExtent()); |
|
125 |
project.addExtent(extent); |
|
126 |
|
|
127 |
// Creating the keyframe list. |
|
128 |
ProjectExtent[] extentsList = project.getExtents(); |
|
129 |
keyFrameList = new ArrayList<IKeyFrame>(); |
|
130 |
for (int i = 0; i < extentsList.length; i++) { |
|
131 |
ProjectExtent projectExtent = extentsList[i]; |
|
132 |
if (projectExtent.getDescription().contains(baseName)) { |
|
133 |
IKeyFrame kf2D = null; |
|
134 |
try { |
|
135 |
kf2D = (IKeyFrame) extPoint.create("KeyFrame2D"); |
|
136 |
} catch (InstantiationException e) { |
|
137 |
// TODO stop this loop and show a advertise message. |
|
138 |
e.printStackTrace(); |
|
139 |
} catch (IllegalAccessException e) { |
|
140 |
e.printStackTrace(); |
|
141 |
} |
|
142 |
|
|
143 |
// Setting up the initial and end time interval. |
|
144 |
double fin = AKFinterval.getEndTime(); |
|
145 |
double ini = AKFinterval.getInitialTime(); |
|
146 |
double size = extentsList.length; |
|
147 |
// Calculating the insertion time. |
|
148 |
double tiempo = 0.0; |
|
149 |
if (i != 0) |
|
150 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
|
151 |
kf2D.setTime(tiempo); |
|
152 |
// hacer funcion de insercion o adapter |
|
153 |
kf2D.setAnimatedObject(projectExtent); |
|
154 |
kf2D.CapturesProperties(); |
|
155 |
keyFrameList.add(kf2D); |
|
156 |
} |
|
157 |
} |
|
158 |
AKFinterval.setKeyFrameList(keyFrameList); |
|
159 |
} |
|
160 |
|
|
161 |
public static void captureEncuadrator3D(View3D view, AnimationContainer ac, |
|
162 |
String prefix) { |
|
163 |
AnimationTimeTrack animationTimeTrack = null; |
|
164 |
AnimationKeyFrameInterval AKFinterval = null; |
|
165 |
List<IKeyFrame> keyFrameList = null; |
|
166 |
|
|
167 |
String baseName = prefix + "-" + view.getWindowInfo().getTitle() + "-" |
|
168 |
+ AnimationPrefix; |
|
169 |
String name = baseName + cont3D++; |
|
170 |
|
|
171 |
// Getting the animation extension point. |
|
172 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
173 |
.getInstance(); |
|
174 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
175 |
.get("Animation")); |
|
176 |
|
|
177 |
// Creating new track |
|
178 |
animationTimeTrack = AnimationUtils.getAnimationTimeTrack(baseName |
|
179 |
+ "-encuadrator_track_3D", ac, view); |
|
180 |
|
|
181 |
// Creating the interval |
|
182 |
List<AnimationKeyFrameInterval> intervalList = animationTimeTrack |
|
183 |
.getIntervalList(); |
|
184 |
if (intervalList != null) { |
|
185 |
for (Iterator iterator = intervalList.iterator(); iterator |
|
186 |
.hasNext();) { |
|
187 |
AnimationKeyFrameInterval animationKeyFrameInterval = (AnimationKeyFrameInterval) iterator |
|
188 |
.next(); |
|
189 |
if (animationKeyFrameInterval != null) { |
|
190 |
AKFinterval = animationKeyFrameInterval; |
|
191 |
} |
|
192 |
} |
|
193 |
if (intervalList.size() == 0) { |
|
194 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
|
195 |
.createKeyFrameInterval(); |
|
196 |
// Setting up interval properties. |
|
197 |
AKFinterval.setInitialTime(0.0); |
|
198 |
AKFinterval.setEndTime(1.0); |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
202 |
// Getting the current camera position and insert it into project camera |
|
203 |
// list. |
|
204 |
Camera ca = view.getCamera(); |
|
205 |
ProjectCamera camera = new ProjectCamera(); |
|
206 |
camera.setDescription(name); |
|
207 |
camera.setCamera(ca); |
|
208 |
project.addCamera(camera); |
|
209 |
|
|
210 |
List<ProjectCamera> extentsList = filterExtendsList(baseName, project); |
|
211 |
keyFrameList = new ArrayList<IKeyFrame>(); |
|
212 |
for (int i = 0; i < extentsList.size(); i++) { |
|
213 |
ProjectCamera projectCamera = (ProjectCamera) extentsList.get(i); |
|
214 |
IKeyFrame kf3D = null; |
|
215 |
try { |
|
216 |
kf3D = (IKeyFrame) extPoint.create("KeyFrame3DFlat"); |
|
217 |
} catch (InstantiationException e) { |
|
218 |
e.printStackTrace(); |
|
219 |
} catch (IllegalAccessException e) { |
|
220 |
e.printStackTrace(); |
|
221 |
} |
|
222 |
|
|
223 |
// Setting up the initial and end time interval. |
|
224 |
double fin = AKFinterval.getEndTime(); |
|
225 |
double ini = AKFinterval.getInitialTime(); |
|
226 |
double size = extentsList.size(); |
|
227 |
// Calculating the correct time for this key frame. |
|
228 |
double tiempo = 0.0; |
|
229 |
if (i != 0) |
|
230 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
|
231 |
// Setting the time. |
|
232 |
kf3D.setTime(tiempo); |
|
233 |
// hacer funcion de insercion o adapter |
|
234 |
kf3D.setAnimatedObject(projectCamera); |
|
235 |
kf3D.CapturesProperties(); |
|
236 |
keyFrameList.add(kf3D); |
|
237 |
} |
|
238 |
AKFinterval.setKeyFrameList(keyFrameList); |
|
239 |
|
|
240 |
// Creating key frame list |
|
241 |
// Object[] extentsList = project.getCameras(); |
|
242 |
// keyFrameList = new ArrayList<IKeyFrame>(); |
|
243 |
// for (int i = 0; i < extentsList.length; i++) { |
|
244 |
// ProjectCamera projectCamera = (ProjectCamera) extentsList[i]; |
|
245 |
// if (projectCamera.getDescription().contains(baseName)) { |
|
246 |
// IKeyFrame kf3D = null; |
|
247 |
// try { |
|
248 |
// kf3D = (IKeyFrame) extPoint.create("KeyFrame3DFlat"); |
|
249 |
// } catch (InstantiationException e) { |
|
250 |
// e.printStackTrace(); |
|
251 |
// } catch (IllegalAccessException e) { |
|
252 |
// e.printStackTrace(); |
|
253 |
// } |
|
254 |
// |
|
255 |
// // Setting up the initial and end time interval. |
|
256 |
// double fin = AKFinterval.getEndTime(); |
|
257 |
// double ini = AKFinterval.getInitialTime(); |
|
258 |
// double size = extentsList.length; |
|
259 |
// // Calculating the correct time for this key frame. |
|
260 |
// double tiempo = 0.0; |
|
261 |
// if (i != 0) |
|
262 |
// tiempo = i * ((fin - ini) / (size - 1.0)); |
|
263 |
// // Setting the time. |
|
264 |
// kf3D.setTime(tiempo); |
|
265 |
// // hacer funcion de insercion o adapter |
|
266 |
// kf3D.setAnimatedObject(projectCamera); |
|
267 |
// kf3D.CapturesProperties(); |
|
268 |
// keyFrameList.add(kf3D); |
|
269 |
// } |
|
270 |
// } |
|
271 |
} |
|
272 |
|
|
273 |
private static List<ProjectCamera> filterExtendsList(String baseName, |
|
274 |
Project project2) { |
|
275 |
List<ProjectCamera> extendsList = null; |
|
276 |
Object[] extentsList = project2.getCameras(); |
|
277 |
for (int i = 0; i < extentsList.length; i++) { |
|
278 |
ProjectCamera projectCamera = (ProjectCamera) extentsList[i]; |
|
279 |
if (projectCamera.getDescription().contains(baseName)) { |
|
280 |
if (extendsList == null) |
|
281 |
extendsList = new ArrayList(); |
|
282 |
extendsList.add(projectCamera); |
|
283 |
} |
|
284 |
} |
|
285 |
return extendsList; |
|
286 |
} |
|
287 |
|
|
288 |
private static AnimationTimeTrack getAnimationTimeTrack(String name, |
|
289 |
AnimationContainer ac, BaseView view) { |
|
290 |
|
|
291 |
AnimationTimeTrack att = null; |
|
292 |
if (view instanceof View) { |
|
293 |
att = AnimationUtils.getAnimationTimeTrackForView(name, ac, |
|
294 |
(View) view); |
|
295 |
} |
|
296 |
|
|
297 |
if (view instanceof View3D) { |
|
298 |
att = AnimationUtils.getAnimationTimeTrackForView3D(name, ac, |
|
299 |
(View3D) view); |
|
300 |
} |
|
301 |
return att; |
|
302 |
} |
|
303 |
|
|
304 |
private static AnimationTimeTrack getAnimationTimeTrackForView(String name, |
|
305 |
AnimationContainer ac, View view) { |
|
306 |
|
|
307 |
AnimationTimeTrack at = null; |
|
308 |
IAnimationTrack aa = ac.findTrack(name); |
|
309 |
if (aa == null) { |
|
310 |
|
|
311 |
// Getting the extension point. |
|
312 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
313 |
.getInstance(); |
|
314 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
315 |
.get("Animation")); |
|
316 |
|
|
317 |
// If f is a 2D windows, it will create with 2D specific animation |
|
318 |
// type. |
|
319 |
|
|
320 |
// Finding if there are an 3D animation track. |
|
321 |
// IAnimationTrack trackAux = ac.findTrack("encuadrator_track_3D"); |
|
322 |
// if (trackAux != null) { |
|
323 |
// // if there are one, it will disable. |
|
324 |
// trackAux.setEnabale(false); |
|
325 |
// } |
|
326 |
IAnimationType animationLayer2D = null; |
|
327 |
try { |
|
328 |
animationLayer2D = (IAnimationType) extPoint |
|
329 |
.create("AnimationLayer2D"); |
|
330 |
} catch (InstantiationException e) { |
|
331 |
// TODO Auto-generated catch block |
|
332 |
e.printStackTrace(); |
|
333 |
} catch (IllegalAccessException e) { |
|
334 |
// TODO Auto-generated catch block |
|
335 |
e.printStackTrace(); |
|
336 |
} |
|
337 |
// Setting up the track properties |
|
338 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animationLayer2D); |
|
339 |
at.setName(name); |
|
340 |
at.setEnabale(true); |
|
341 |
// Setting up the animated object |
|
342 |
// Creating the object 2D |
|
343 |
AnimatedObjectBase object2D = new AnimatedObjectBase(); |
|
344 |
at.setAnimatedObject(object2D); |
|
345 |
|
|
346 |
// Getting the interpolator |
|
347 |
IInterpolator inter2D = InterpolatorFactory |
|
348 |
.createObject("Interpolator2D"); |
|
349 |
object2D.addAnimatedObject("view2D", view); |
|
350 |
// Getting the interpolator funcion |
|
351 |
IInterpolatorTimeFuntion funtion = FuntionFactory |
|
352 |
.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion"); |
|
353 |
inter2D.setFuntion(funtion); |
|
354 |
|
|
355 |
animationLayer2D.setInterpolator(inter2D); |
|
356 |
at.setAnimationType(animationLayer2D); |
|
357 |
animationLayer2D.setAnimatedObject(object2D); |
|
358 |
} else { |
|
359 |
at = (AnimationTimeTrack) aa; |
|
360 |
} |
|
361 |
|
|
362 |
// IAnimationTrack trackAux = ac.findTrack("encuadrator_track_3D"); |
|
363 |
// if (trackAux != null) { |
|
364 |
// trackAux.setEnabale(false); |
|
365 |
// } |
|
366 |
return at; |
|
367 |
|
|
368 |
} |
|
369 |
|
|
370 |
private static AnimationTimeTrack getAnimationTimeTrackForView3D( |
|
371 |
String name, AnimationContainer ac, View3D view) { |
|
372 |
|
|
373 |
AnimationTimeTrack at = null; |
|
374 |
IAnimationTrack aa = ac.findTrack(name); |
|
375 |
if (aa == null) { |
|
376 |
|
|
377 |
// Getting the extension point. |
|
378 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
379 |
.getInstance(); |
|
380 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
381 |
.get("Animation")); |
|
382 |
|
|
383 |
// If f is a 2D windows, it will create with 2D specific animation |
|
384 |
// type. |
|
385 |
// Finding if there are an 2D animation track. |
|
386 |
// IAnimationTrack trackAux = ac.findTrack("encuadrator_track_2D"); |
|
387 |
// if (trackAux != null) { |
|
388 |
// // if there are one, it will disable. |
|
389 |
// trackAux.setEnabale(false); |
|
390 |
// } |
|
391 |
IAnimationType animationLayer3DFlat = null; |
|
392 |
try { |
|
393 |
animationLayer3DFlat = (IAnimationType) extPoint |
|
394 |
.create("AnimationLayer3DFlat"); |
|
395 |
} catch (InstantiationException e) { |
|
396 |
// TODO Auto-generated catch block |
|
397 |
e.printStackTrace(); |
|
398 |
} catch (IllegalAccessException e) { |
|
399 |
e.printStackTrace(); |
|
400 |
} |
|
401 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animationLayer3DFlat); |
|
402 |
|
|
403 |
at.setName(name); |
|
404 |
at.setEnabale(true); |
|
405 |
|
|
406 |
AnimatedObjectBase object3D = new AnimatedObjectBase(); |
|
407 |
object3D.addAnimatedObject("view", (BaseView) view); |
|
408 |
at.setAnimatedObject(object3D); |
|
409 |
|
|
410 |
/** ******************************************************************* */ |
|
411 |
View3D view3D = view; |
|
412 |
IInterpolator interpolator3D = null; |
|
413 |
if (view.getPlanet().getCoordinateSystemType() == Planet.CoordinateSystemType.PROJECTED) { |
|
414 |
interpolator3D = InterpolatorFactory |
|
415 |
.createObject("Interpolator3DFlat"); |
|
416 |
} else if (view.getPlanet().getCoordinateSystemType() == Planet.CoordinateSystemType.GEOCENTRIC) { |
|
417 |
interpolator3D = InterpolatorFactory |
|
418 |
.createObject("Interpolator3DSpherical"); |
|
419 |
} |
|
420 |
|
|
421 |
IInterpolatorTimeFuntion funtion = FuntionFactory |
|
422 |
.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion"); |
|
423 |
interpolator3D.setFuntion(funtion); |
|
424 |
animationLayer3DFlat.setInterpolator(interpolator3D); |
|
425 |
at.setAnimationType(animationLayer3DFlat); |
|
426 |
animationLayer3DFlat.setAnimatedObject(object3D); |
|
427 |
|
|
428 |
/** ********************************************************************* */ |
|
429 |
/******************************************************************* |
|
430 |
* old code * IInterpolator inter3DFlat = InterpolatorFactory |
|
431 |
* .createObject("Interpolator3DFlat"); IInterpolatorTimeFuntion |
|
432 |
* funtion = FuntionFactory |
|
433 |
* .createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion"); |
|
434 |
* inter3DFlat.setFuntion(funtion); |
|
435 |
* animationLayer3DFlat.setInterpolator(inter3DFlat); |
|
436 |
* at.setAnimationType(animationLayer3DFlat); |
|
437 |
* animationLayer3DFlat.setAnimatedObject(object3D); / |
|
438 |
******************************************************************/ |
|
439 |
} else { |
|
440 |
at = (AnimationTimeTrack) aa; |
|
441 |
} |
|
442 |
|
|
443 |
// IAnimationTrack trackAux = ac.findTrack("encuadrator_track_2D"); |
|
444 |
// if (trackAux != null) { |
|
445 |
// trackAux.setEnabale(false); |
|
446 |
// } |
|
447 |
return at; |
|
448 |
|
|
449 |
} |
|
450 |
|
|
451 |
public static ProjectAnimationDocument createAnimationDocument( |
|
452 |
String viewName, Project project) { |
|
453 |
ProjectAnimationDocument pv = null; |
|
454 |
ArrayList<ProjectDocument> projectList = project |
|
455 |
.getDocumentsByType(ProjectAnimationDocumentFactory.registerName); |
|
456 |
Iterator<ProjectDocument> it = projectList.iterator(); |
|
457 |
while (it.hasNext()) { |
|
458 |
ProjectDocument projectDocument = (ProjectDocument) it.next(); |
|
459 |
if (viewName.equals(projectDocument.getName())) { |
|
460 |
pv = (ProjectAnimationDocument) projectDocument; |
|
461 |
} |
|
462 |
|
|
463 |
} |
|
464 |
if (pv == null) { |
|
465 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
466 |
.getInstance(); |
|
467 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
468 |
.get("Documents")); |
|
469 |
ProjectDocumentFactory pdf = null; |
|
470 |
try { |
|
471 |
pdf = (ProjectDocumentFactory) extPoint |
|
472 |
.create(ProjectAnimationDocumentFactory.registerName); |
|
473 |
} catch (InstantiationException e) { |
|
474 |
e.printStackTrace(); |
|
475 |
} catch (IllegalAccessException e) { |
|
476 |
e.printStackTrace(); |
|
477 |
} |
|
478 |
pv = (ProjectAnimationDocument) pdf.create((Project) null); |
|
479 |
pv.setProjectDocumentFactory(pdf); |
|
480 |
pv.setName(viewName); |
|
481 |
} |
|
482 |
return pv; |
|
483 |
} |
|
484 |
|
|
485 |
public static ProjectAnimationDocument getProjectDocument(String name, |
|
486 |
Project project) { |
|
487 |
ProjectAnimationDocument pv = null; |
|
488 |
ArrayList<ProjectDocument> projectList = project |
|
489 |
.getDocumentsByType(ProjectAnimationDocumentFactory.registerName); |
|
490 |
Iterator<ProjectDocument> it = projectList.iterator(); |
|
491 |
while (it.hasNext()) { |
|
492 |
ProjectDocument projectDocument = (ProjectDocument) it.next(); |
|
493 |
if (name.equals(projectDocument.getName())) { |
|
494 |
pv = (ProjectAnimationDocument) projectDocument; |
|
495 |
} |
|
496 |
|
|
497 |
} |
|
498 |
return pv; |
|
499 |
} |
|
500 |
|
|
501 |
public static boolean exitsProject(String name, Project project) { |
|
502 |
boolean pv = false; |
|
503 |
ArrayList<ProjectDocument> projectList = project |
|
504 |
.getDocumentsByType(ProjectAnimationDocumentFactory.registerName); |
|
505 |
Iterator<ProjectDocument> it = projectList.iterator(); |
|
506 |
while (it.hasNext()) { |
|
507 |
ProjectDocument projectDocument = (ProjectDocument) it.next(); |
|
508 |
if (name.equals(projectDocument.getName())) { |
|
509 |
pv = true; |
|
510 |
} |
|
511 |
|
|
512 |
} |
|
513 |
return pv; |
|
514 |
} |
|
515 |
|
|
516 |
/** |
|
517 |
* |
|
518 |
* @param name : |
|
519 |
* Track name. |
|
520 |
* @param ac : |
|
521 |
* animation container. |
|
522 |
* @param object |
|
523 |
* @return at : Return a animation track based in time. |
|
524 |
* |
|
525 |
* Creating a animation track based in time. |
|
526 |
*/ |
|
527 |
public static AnimationTimeTrack getAnimationTimeTrackTransparency( |
|
528 |
String name, AnimationContainer ac, BaseView view, |
|
529 |
IAnimatedObject object) { |
|
530 |
|
|
531 |
AnimationTimeTrack at = null;// this.animationTimeTrack; |
|
532 |
|
|
533 |
IAnimationTrack animationTrack = ac.findTrack(name); |
|
534 |
if (animationTrack == null) { |
|
535 |
|
|
536 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
537 |
.getInstance(); |
|
538 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
539 |
.get("Animation")); |
|
540 |
|
|
541 |
IAnimationType animTransp = null; |
|
542 |
try { |
|
543 |
System.out.println(extPoint.getDescription()); |
|
544 |
|
|
545 |
// Instancing my new animation based in transparency. |
|
546 |
animTransp = (IAnimationType) extPoint |
|
547 |
.create("AnimationTransparency"); |
|
548 |
} catch (InstantiationException e) { |
|
549 |
e.printStackTrace(); |
|
550 |
} catch (IllegalAccessException e) { |
|
551 |
e.printStackTrace(); |
|
552 |
} |
|
553 |
|
|
554 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animTransp); |
|
555 |
at.setName(name); |
|
556 |
|
|
557 |
// Saving the view( in this case a BaseView). |
|
558 |
|
|
559 |
object.addAnimatedObject("view", view); |
|
560 |
|
|
561 |
at.setAnimatedObject(object); |
|
562 |
animTransp.setAnimatedObject(object); |
|
563 |
// My interpolator based in time and transparency. |
|
564 |
IInterpolator interTransparency = InterpolatorFactory |
|
565 |
.createObject("InterpolatorTransparency"); |
|
566 |
animTransp.setInterpolator(interTransparency); |
|
567 |
at.setAnimationType(animTransp); |
|
568 |
} else { |
|
569 |
at = (AnimationTimeTrack) animationTrack; |
|
570 |
} |
|
571 |
return at; |
|
572 |
} |
|
573 |
|
|
574 |
public static void createLayerTransparencyAnimation(BaseView window, |
|
575 |
AnimationContainer ac, String prefix) { |
|
576 |
System.out.println("pulsado boton transparencias !!!"); |
|
577 |
|
|
578 |
AnimationTimeTrack animationTimeTrack = null; |
|
579 |
AnimationKeyFrameInterval AKFinterval = null; |
|
580 |
List<IKeyFrame> keyFrameList = null; |
|
581 |
AnimatedObjectBase object = new AnimatedObjectBase(); |
|
582 |
// Getting the animation extension point |
|
583 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
584 |
.getInstance(); |
|
585 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
586 |
.get("Animation")); |
|
587 |
|
|
588 |
// List of keyframes. |
|
589 |
// If the window is instance of View |
|
590 |
if (window instanceof BaseView) { |
|
591 |
|
|
592 |
BaseView view = (BaseView) window; |
|
593 |
|
|
594 |
// Generating the list of keyframes |
|
595 |
// keyFrameList = new ArrayList(); |
|
596 |
IProjectView model = view.getModel(); |
|
597 |
MapContext mapContext = model.getMapContext(); |
|
598 |
FLayers layers = mapContext.getLayers(); |
|
599 |
FLayer[] actives = layers.getActives(); |
|
600 |
|
|
601 |
double fin = 1;// AKFinterval.getEndTime(); |
|
602 |
double ini = 0;// AKFinterval.getInitialTime(); |
|
603 |
double tiempo = 0.0; |
|
604 |
int size = actives.length; |
|
605 |
double incremento = ((fin - ini) / (size)); |
|
606 |
for (int i = size - 1; i >= 0; i--) {// order in TOC. |
|
607 |
|
|
608 |
animationTimeTrack = null; |
|
609 |
animationTimeTrack = AnimationUtils |
|
610 |
.getAnimationTimeTrackTransparency("Track_layer_" + i, |
|
611 |
ac, view, object); |
|
612 |
animationTimeTrack.setEnabale(true); |
|
613 |
object.addAnimatedObject("layer", actives[i]); |
|
614 |
|
|
615 |
// Generating the interval. |
|
616 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
|
617 |
.createKeyFrameInterval(); |
|
618 |
AKFinterval.setInitialTime(0.0); |
|
619 |
AKFinterval.setEndTime(1.0); |
|
620 |
|
|
621 |
keyFrameList = new ArrayList<IKeyFrame>(); |
|
622 |
IKeyFrame kfTransAux = null; |
|
623 |
IKeyFrame kfTransIni = null; |
|
624 |
IKeyFrame kfTransFin = null; |
|
625 |
try { |
|
626 |
kfTransAux = (IKeyFrame) extPoint |
|
627 |
.create("KeyFrameTransparency"); |
|
628 |
kfTransIni = (IKeyFrame) extPoint |
|
629 |
.create("KeyFrameTransparency"); |
|
630 |
kfTransFin = (IKeyFrame) extPoint |
|
631 |
.create("KeyFrameTransparency"); |
|
632 |
} catch (InstantiationException e1) { |
|
633 |
e1.printStackTrace(); |
|
634 |
} catch (IllegalAccessException e1) { |
|
635 |
e1.printStackTrace(); |
|
636 |
} |
|
637 |
// Calculating the time insertion. |
|
638 |
if (i == size - 1) // the keyframe is the first in the list. |
|
639 |
tiempo = ini + 0.001; |
|
640 |
|
|
641 |
// Three keyframes by track. |
|
642 |
// Keyframe 1 of the layer i. |
|
643 |
kfTransAux.setName("KF1_layer_" + i);// name of keyframe. |
|
644 |
kfTransAux.setTime(ini); // initial time interval. |
|
645 |
kfTransAux.setAnimatedObject(actives[i]);// set the object to |
|
646 |
// animate(a layer). |
|
647 |
// kfTransAux.setLevelTransparency(255); |
|
648 |
kfTransAux.CapturesProperties(); // capturing actual |
|
649 |
// transparency. |
|
650 |
keyFrameList.add(kfTransAux); // adding in the list. |
|
651 |
|
|
652 |
// keyframe 2 of the layer i. |
|
653 |
kfTransIni.setName("KF2_layer_" + i);// name of keyframe. |
|
654 |
kfTransIni.setTime(tiempo); // initial time interval. |
|
655 |
kfTransIni.setAnimatedObject(actives[i]);// set the same |
|
656 |
// layer in the |
|
657 |
// second keyframe. |
|
658 |
kfTransIni.CapturesProperties(); // capturing actual |
|
659 |
// transparency. |
|
660 |
keyFrameList.add(kfTransIni); // adding in the list. |
|
661 |
|
|
662 |
// keyframe 3 of the layer i. |
|
663 |
try { |
|
664 |
if (i == 0) // the keyframe is the last in the list. |
|
665 |
tiempo = fin; |
|
666 |
else |
|
667 |
tiempo += incremento; |
|
668 |
|
|
669 |
kfTransFin.setName("KF3_layer_" + i);// name of keyframe. |
|
670 |
kfTransFin.setTime(tiempo);// saving final time interval. |
|
671 |
// kfTransFin.setLevelTransparency(0);// interpolation: |
|
672 |
// layer transparency in |
|
673 |
// the moment to 0. |
|
674 |
kfTransFin.setAnimatedObject(actives[i]); // save the same |
|
675 |
// layer in the |
|
676 |
// third |
|
677 |
// keyframe |
|
678 |
keyFrameList.add(kfTransFin);// adding to the list. |
|
679 |
} catch (Exception e) { |
|
680 |
// TODO Auto-generated catch block |
|
681 |
e.printStackTrace(); |
|
682 |
} |
|
683 |
AKFinterval.setKeyFrameList(keyFrameList);// Adding the list |
|
684 |
// of keyframes to |
|
685 |
// the interval. |
|
686 |
|
|
687 |
} |
|
688 |
} |
|
689 |
} |
|
690 |
|
|
691 |
// Menu Player. |
|
692 |
// AnimationContainer ac = (AnimationContainer) |
|
693 |
// project.getAnimationContainer(); |
|
694 |
// AnimationPlayer ap = ac.getAnimationPlayer(); |
|
695 |
// ap.setAnimationContainer(ac); |
|
696 |
// AnimationContol3D fp = new AnimationContol3D(ap); |
|
697 |
// PluginServices.getMDIManager().addWindow((IWindow) fp); |
|
698 |
|
|
699 |
} |
trunk/extensions/extAnimationGUI/src/com/iver/ai2/animationgui/gui/MenuAnimationTransparency.java | ||
---|---|---|
3 | 3 |
import java.util.ArrayList; |
4 | 4 |
import java.util.List; |
5 | 5 |
|
6 |
import com.iver.ai2.animationgui.gui.document.ProjectAnimationDocument; |
|
7 |
import com.iver.ai2.animationgui.gui.document.ProjectAnimationDocumentFactory; |
|
8 |
import com.iver.ai2.animationgui.gui.util.AnimationUtils; |
|
6 | 9 |
import com.iver.andami.PluginServices; |
7 | 10 |
import com.iver.andami.plugins.Extension; |
8 | 11 |
import com.iver.andami.plugins.IExtension; |
... | ... | |
22 | 25 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
23 | 26 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
24 | 27 |
import com.iver.cit.gvsig.project.Project; |
28 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
|
25 | 29 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
26 | 30 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
27 | 31 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
28 | 32 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
29 | 33 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
30 | 34 |
|
31 |
|
|
32 | 35 |
/** |
33 | 36 |
* @author ?ngel |
34 | 37 |
* @since 1.1 |
... | ... | |
39 | 42 |
public class MenuAnimationTransparency extends Extension { |
40 | 43 |
|
41 | 44 |
private Project project; |
42 |
|
|
43 |
private AnimationContainer ac = null; |
|
45 |
|
|
46 |
// private AnimationContainer ac = null;
|
|
44 | 47 |
private AnimationTimeTrack animationTimeTrack = null; |
45 | 48 |
private AnimationKeyFrameInterval AKFinterval = null; |
46 |
private List keyFrameList = null; |
|
49 |
private List<IKeyFrame> keyFrameList = null;
|
|
47 | 50 |
private AnimatedObjectBase object = new AnimatedObjectBase(); |
48 |
|
|
51 |
|
|
52 |
// It is the project Document create to create a fast animation. |
|
53 |
private ProjectAnimationDocument pad; |
|
54 |
|
|
49 | 55 |
public void execute(String actionCommand) { |
50 |
|
|
56 |
|
|
57 |
AnimationContainer ac; |
|
51 | 58 |
// if the button pressed is "this" |
52 | 59 |
if (actionCommand.equals("CREARANIMTRANSP")) { |
53 |
System.out.println("pulsado boton transparencias !!!"); |
|
54 |
|
|
60 |
|
|
61 |
String prefix = "Default-animation-document"; |
|
62 |
// if there is not create the default animation. we will create it. |
|
63 |
pad = AnimationUtils.createAnimationDocument(prefix, project); |
|
64 |
if (!AnimationUtils.exitsProject(prefix, project)){ |
|
65 |
project.addDocument(pad); |
|
66 |
} |
|
67 |
|
|
55 | 68 |
// Getting the active windows |
56 | 69 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
57 |
|
|
70 |
|
|
58 | 71 |
// Getting the animation container |
59 |
ac = this.getAnimationContainer(); |
|
60 |
|
|
61 |
|
|
62 |
// Getting the animation extension point |
|
63 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
64 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints.get("Animation")); |
|
65 |
|
|
66 |
|
|
67 |
//List of keyframes. |
|
68 |
// If the window is instance of View |
|
69 |
if (window instanceof BaseView) { |
|
72 |
ac = pad.getAnimationContainer(); |
|
73 |
// Generating the animation transparency |
|
74 |
AnimationUtils.createLayerTransparencyAnimation((BaseView) window, |
|
75 |
ac, prefix); |
|
70 | 76 |
|
71 |
BaseView view = (BaseView) window; |
|
77 |
// Menu Player. |
|
78 |
// AnimationPlayer ap = ac.getAnimationPlayer(); |
|
79 |
// ap.setAnimationContainer(ac); |
|
80 |
// AnimationContol3D fp = new AnimationContol3D(ap); |
|
81 |
// PluginServices.getMDIManager().addWindow((IWindow) fp); |
|
82 |
} |
|
72 | 83 |
|
73 |
// Generating the list of keyframes |
|
74 |
//keyFrameList = new ArrayList(); |
|
75 |
IProjectView model = view.getModel(); |
|
76 |
MapContext mapContext = model.getMapContext(); |
|
77 |
FLayers layers = mapContext.getLayers(); |
|
78 |
FLayer[] actives = layers.getActives(); |
|
79 |
|
|
80 |
double fin = 1;//AKFinterval.getEndTime(); |
|
81 |
double ini = 0;//AKFinterval.getInitialTime(); |
|
82 |
double tiempo = 0.0; |
|
83 |
int size = actives.length; |
|
84 |
double incremento = ((fin - ini) / (size)); |
|
85 |
for(int i = size-1; i >= 0; i--){// order in TOC. |
|
86 |
|
|
87 |
animationTimeTrack = null; |
|
88 |
animationTimeTrack = this.getAnimationTimeTrack("Track_layer_" + i, ac); |
|
89 |
animationTimeTrack.setEnabale(true); |
|
90 |
object.addAnimatedObject("layer",actives[i]); |
|
91 |
|
|
92 |
|
|
93 |
// Generating the interval. |
|
94 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
|
95 |
.createKeyFrameInterval(); |
|
96 |
AKFinterval.setInitialTime(0.0); |
|
97 |
AKFinterval.setEndTime(1.0); |
|
98 |
|
|
99 |
keyFrameList = new ArrayList(); |
|
100 |
// KeyFrameTransparency kfTransAux = new KeyFrameTransparency(); |
|
101 |
IKeyFrame kfTransAux = null; |
|
102 |
IKeyFrame kfTransIni = null; |
|
103 |
IKeyFrame kfTransFin = null; |
|
104 |
try { |
|
105 |
kfTransAux = (IKeyFrame)extPoint.create("KeyFrameTransparency"); |
|
106 |
kfTransIni = (IKeyFrame)extPoint.create("KeyFrameTransparency"); |
|
107 |
kfTransFin = (IKeyFrame)extPoint.create("KeyFrameTransparency"); |
|
108 |
} |
|
109 |
catch (InstantiationException e1) { |
|
110 |
e1.printStackTrace(); |
|
111 |
} catch (IllegalAccessException e1) { |
|
112 |
e1.printStackTrace(); |
|
113 |
} |
|
114 |
//Calculating the time insertion. |
|
115 |
if (i == size-1) // the keyframe is the first in the list. |
|
116 |
tiempo = ini + 0.001; |
|
117 |
|
|
118 |
//Three keyframes by track. |
|
119 |
//Keyframe 1 of the layer i. |
|
120 |
kfTransAux.setName("KF1_layer_" + i);//name of keyframe. |
|
121 |
kfTransAux.setTime(ini); // initial time interval. |
|
122 |
kfTransAux.setAnimatedObject(actives[i]);//set the object to animate(a layer). |
|
123 |
//kfTransAux.setLevelTransparency(255); |
|
124 |
kfTransAux.CapturesProperties(); //capturing actual transparency. |
|
125 |
keyFrameList.add(kfTransAux); // adding in the list. |
|
126 |
|
|
127 |
//keyframe 2 of the layer i. |
|
128 |
kfTransIni.setName("KF2_layer_" + i);//name of keyframe. |
|
129 |
kfTransIni.setTime(tiempo); // initial time interval. |
|
130 |
kfTransIni.setAnimatedObject(actives[i]);//set the same layer in the second keyframe. |
|
131 |
kfTransIni.CapturesProperties(); //capturing actual transparency. |
|
132 |
keyFrameList.add(kfTransIni); // adding in the list. |
|
133 |
|
|
134 |
//keyframe 3 of the layer i. |
|
135 |
try { |
|
136 |
if(i == 0) // the keyframe is the last in the list. |
|
137 |
tiempo = fin; |
|
138 |
else |
|
139 |
tiempo += incremento; |
|
140 |
|
|
141 |
kfTransFin.setName("KF3_layer_" + i);//name of keyframe. |
|
142 |
kfTransFin.setTime(tiempo);// saving final time interval. |
|
143 |
// kfTransFin.setLevelTransparency(0);// interpolation: layer transparency in the moment to 0. |
|
144 |
kfTransFin.setAnimatedObject(actives[i]); //save the same layer in the third keyframe |
|
145 |
keyFrameList.add(kfTransFin);//adding to the list. |
|
146 |
} catch (Exception e) { |
|
147 |
// TODO Auto-generated catch block |
|
148 |
e.printStackTrace(); |
|
149 |
} |
|
150 |
AKFinterval.setKeyFrameList(keyFrameList);// Adding the list of keyframes to the interval. |
|
151 |
|
|
152 |
} |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
156 |
// Menu Player. |
|
157 |
AnimationContainer ac = (AnimationContainer) project.getAnimationContainer(); |
|
158 |
AnimationPlayer ap = ac.getAnimationPlayer(); |
|
159 |
ap.setAnimationContainer(ac); |
|
160 |
AnimationContol3D fp = new AnimationContol3D(ap); |
|
161 |
PluginServices.getMDIManager().addWindow((IWindow) fp); |
|
162 |
|
|
84 |
// System.out.println("pulsado boton transparencias !!!"); |
|
85 |
// |
|
86 |
// // Getting the active windows |
|
87 |
// IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
88 |
// |
|
89 |
// // Getting the animation container |
|
90 |
// ac = this.getAnimationContainer(); |
|
91 |
// |
|
92 |
// |
|
93 |
// // Getting the animation extension point |
|
94 |
// ExtensionPoints extensionPoints = |
|
95 |
// ExtensionPointsSingleton.getInstance(); |
|
96 |
// ExtensionPoint extPoint = ((ExtensionPoint) |
|
97 |
// extensionPoints.get("Animation")); |
|
98 |
// |
|
99 |
// |
|
100 |
// //List of keyframes. |
|
101 |
// // If the window is instance of View |
|
102 |
// if (window instanceof BaseView) { |
|
103 |
// |
|
104 |
// BaseView view = (BaseView) window; |
|
105 |
// |
|
106 |
// // Generating the list of keyframes |
|
107 |
// //keyFrameList = new ArrayList(); |
|
108 |
// IProjectView model = view.getModel(); |
|
109 |
// MapContext mapContext = model.getMapContext(); |
|
110 |
// FLayers layers = mapContext.getLayers(); |
|
111 |
// FLayer[] actives = layers.getActives(); |
|
112 |
// |
|
113 |
// double fin = 1;//AKFinterval.getEndTime(); |
|
114 |
// double ini = 0;//AKFinterval.getInitialTime(); |
|
115 |
// double tiempo = 0.0; |
|
116 |
// int size = actives.length; |
|
117 |
// double incremento = ((fin - ini) / (size)); |
|
118 |
// for(int i = size-1; i >= 0; i--){// order in TOC. |
|
119 |
// |
|
120 |
// animationTimeTrack = null; |
|
121 |
// animationTimeTrack = |
|
122 |
// AnimationUtils.getAnimationTimeTrackTransparency("Track_layer_" + i, |
|
123 |
// ac); |
|
124 |
// animationTimeTrack.setEnabale(true); |
|
125 |
// object.addAnimatedObject("layer",actives[i]); |
|
126 |
// |
|
127 |
// |
|
128 |
// // Generating the interval. |
|
129 |
// AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
Also available in: Unified diff