Revision 31983
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_11/extensions/extAnimationGUI/build.number | ||
---|---|---|
1 |
#Build Number for ANT. Do not edit! |
|
2 |
#Wed Jan 16 11:54:01 CET 2008 |
|
3 |
build.number=1209 |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_11/extensions/extAnimationGUI/src/com/iver/ai2/animationgui/gui/util/AnimationUtils.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
|
|
20 |
|
|
21 |
/** |
|
22 |
* @author �ngel Fraile Gri��n e-mail: angel.fraile@iver.es |
|
23 |
* @since 1.1 |
|
24 |
* |
|
25 |
*/ |
|
26 |
|
|
27 |
package com.iver.ai2.animationgui.gui.util; |
|
28 |
|
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.Iterator; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.gvsig.gvsig3dgui.view.View3D; |
|
34 |
import org.gvsig.osgvp.planets.Planet; |
|
35 |
import org.gvsig.osgvp.terrain.Terrain; |
|
36 |
import org.gvsig.osgvp.viewer.Camera; |
|
37 |
|
|
38 |
import com.iver.ai2.animationgui.gui.document.ProjectAnimationDocument; |
|
39 |
import com.iver.ai2.animationgui.gui.document.ProjectAnimationDocumentFactory; |
|
40 |
import com.iver.ai2.gvsig3d.camera.ProjectCamera; |
|
41 |
import com.iver.andami.PluginServices; |
|
42 |
import com.iver.andami.plugins.IExtension; |
|
43 |
import com.iver.cit.gvsig.ProjectExtension; |
|
44 |
import com.iver.cit.gvsig.animation.AnimationContainer; |
|
45 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
46 |
import com.iver.cit.gvsig.animation.animatedObject.AnimatedObjectBase; |
|
47 |
import com.iver.cit.gvsig.animation.animatedObject.AnimationObject2D; |
|
48 |
import com.iver.cit.gvsig.animation.animatedObject.AnimationObject3DFlat; |
|
49 |
import com.iver.cit.gvsig.animation.animatedObject.IAnimatedObject; |
|
50 |
import com.iver.cit.gvsig.animation.interval.AnimationKeyFrameInterval; |
|
51 |
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame; |
|
52 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.FuntionFactory; |
|
53 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
|
54 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolatorTimeFuntion; |
|
55 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.InterpolatorFactory; |
|
56 |
import com.iver.cit.gvsig.animation.traks.AnimationTimeTrack; |
|
57 |
import com.iver.cit.gvsig.animation.traks.IAnimationTrack; |
|
58 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
59 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
60 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
61 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
62 |
import com.iver.cit.gvsig.project.Project; |
|
63 |
import com.iver.cit.gvsig.project.ProjectExtent; |
|
64 |
import com.iver.cit.gvsig.project.ProjectFactory; |
|
65 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
|
66 |
import com.iver.cit.gvsig.project.documents.ProjectDocumentFactory; |
|
67 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
|
68 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
|
69 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
|
70 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
|
71 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
|
72 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
73 |
|
|
74 |
public class AnimationUtils { |
|
75 |
|
|
76 |
private static String AnimationPrefix = "Animation-"; |
|
77 |
private static int cont2D = 0; |
|
78 |
private static int cont3D = 0; |
|
79 |
private static Project project; |
|
80 |
|
|
81 |
static { |
|
82 |
IExtension extension = PluginServices |
|
83 |
.getExtension(com.iver.cit.gvsig.ProjectExtension.class); |
|
84 |
ProjectExtension pe = (ProjectExtension) extension; |
|
85 |
project = pe.getProject(); |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
/** |
|
90 |
* Default function in movement animations 2D and 3D |
|
91 |
* |
|
92 |
* @param view: Actual view selected |
|
93 |
* @param ac: Animation container |
|
94 |
* @param prefix: Part of the tracks animation names |
|
95 |
*/ |
|
96 |
public static void captureEncuadrator(BaseView view, AnimationContainer ac, |
|
97 |
String prefix) { |
|
98 |
// snapshot pressed. |
|
99 |
System.out.println("pulsado boton de capturar encuadres!!!"); |
|
100 |
|
|
101 |
// If the window instance is View, it will manage extends 2D |
|
102 |
if (view instanceof View) { |
|
103 |
AnimationUtils.captureEncuadrator2D((View) view, ac, prefix); |
|
104 |
} |
|
105 |
else |
|
106 |
if (view instanceof BaseView) { |
|
107 |
AnimationUtils.captureEncuadrator3D((View3D) view, ac, prefix); |
|
108 |
} |
|
109 |
|
|
110 |
|
|
111 |
System.out.println(ac); |
|
112 |
|
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Creating a animation 2D track based in time. |
|
117 |
* |
|
118 |
* @param view: Actual view selected |
|
119 |
* @param ac: Animation container |
|
120 |
* @param prefix: Part of the tracks animation names |
|
121 |
*/ |
|
122 |
|
|
123 |
public static void captureEncuadrator2D(View view, AnimationContainer ac, |
|
124 |
String prefix) { |
|
125 |
|
|
126 |
AnimationTimeTrack animationTimeTrack = null; |
|
127 |
AnimationKeyFrameInterval AKFinterval = null; |
|
128 |
List<IKeyFrame> keyFrameList = null; |
|
129 |
|
|
130 |
String baseName = prefix + "-" + view.getWindowInfo().getTitle() + "-" |
|
131 |
+ AnimationPrefix; |
|
132 |
String name = baseName + cont2D++; |
|
133 |
|
|
134 |
// Getting the animation extension point. |
|
135 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
136 |
.getInstance(); |
|
137 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
138 |
.get("Animation")); |
|
139 |
|
|
140 |
// Creating new track |
|
141 |
animationTimeTrack = AnimationUtils.getAnimationTimeTrack(baseName |
|
142 |
+ "-encuadrator_track_2D", ac, view); |
|
143 |
// Creating the interval |
|
144 |
List intervalList = animationTimeTrack.getIntervalList(); |
|
145 |
|
|
146 |
if (intervalList != null) { |
|
147 |
for (Iterator<AnimationKeyFrameInterval> iterator = intervalList.iterator(); iterator |
|
148 |
.hasNext();) { |
|
149 |
AnimationKeyFrameInterval animationKeyFrameInterval = iterator.next(); |
|
150 |
if (animationKeyFrameInterval != null) { |
|
151 |
AKFinterval = animationKeyFrameInterval; |
|
152 |
} |
|
153 |
} |
|
154 |
if (intervalList.size() == 0) { |
|
155 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
|
156 |
.createKeyFrameInterval(); |
|
157 |
// Setting up interval properties. |
|
158 |
AKFinterval.setInitialTime(0.0); |
|
159 |
AKFinterval.setEndTime(1.0); |
|
160 |
} |
|
161 |
} |
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
// Getting the current extend and adding to project extends. |
|
166 |
MapControl mapa = view.getMapControl(); |
|
167 |
ProjectExtent extent = ProjectFactory.createExtent(); |
|
168 |
extent.setDescription(name); |
|
169 |
extent.setExtent(mapa.getViewPort().getExtent()); |
|
170 |
project.addExtent(extent); |
|
171 |
|
|
172 |
// Creating the keyframe list. |
|
173 |
ProjectExtent[] extentsList = project.getExtents(); |
|
174 |
keyFrameList = new ArrayList<IKeyFrame>(); |
|
175 |
for (int i = 0; i < extentsList.length; i++) { |
|
176 |
ProjectExtent projectExtent = extentsList[i]; |
|
177 |
if (projectExtent.getDescription().contains(baseName)) { |
|
178 |
IKeyFrame kf2D = null; |
|
179 |
try { |
|
180 |
kf2D = (IKeyFrame) extPoint.create("KeyFrame2D"); |
|
181 |
} catch (InstantiationException e) { |
|
182 |
e.printStackTrace(); |
|
183 |
} catch (IllegalAccessException e) { |
|
184 |
e.printStackTrace(); |
|
185 |
} |
|
186 |
|
|
187 |
// Setting up the initial and end time interval. |
|
188 |
double fin = AKFinterval.getEndTime(); |
|
189 |
double ini = AKFinterval.getInitialTime(); |
|
190 |
double size = extentsList.length; |
|
191 |
// Calculating the insertion time. |
|
192 |
double tiempo = 0.0; |
|
193 |
if (i != 0) |
|
194 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
|
195 |
kf2D.setTime(tiempo); |
|
196 |
// hacer funcion de insercion o adapter |
|
197 |
kf2D.setAnimatedObject(projectExtent); |
|
198 |
kf2D.CapturesProperties(); |
|
199 |
keyFrameList.add(kf2D); |
|
200 |
} |
|
201 |
} |
|
202 |
AKFinterval.setKeyFrameList(keyFrameList); |
|
203 |
} |
|
204 |
|
|
205 |
public static Project getProject() { |
|
206 |
return project; |
|
207 |
} |
|
208 |
|
|
209 |
|
|
210 |
public static String getAnimationPrefix() { |
|
211 |
return AnimationPrefix; |
|
212 |
} |
|
213 |
|
|
214 |
|
|
215 |
/** |
|
216 |
* Creating a animation 3D track based in time. |
|
217 |
* |
|
218 |
* @param view: Actual view selected |
|
219 |
* @param ac: Animation container |
|
220 |
* @param prefix: Part of the tracks animation names |
|
221 |
*/ |
|
222 |
public static void captureEncuadrator3D(View3D view, AnimationContainer ac, |
|
223 |
String prefix) { |
|
224 |
AnimationTimeTrack animationTimeTrack = null; |
|
225 |
AnimationKeyFrameInterval AKFinterval = null; |
|
226 |
List<IKeyFrame> keyFrameList = null; |
|
227 |
|
|
228 |
String baseName = prefix + "-" + view.getWindowInfo().getTitle() + "-" |
|
229 |
+ AnimationPrefix; |
|
230 |
String name = baseName + cont3D++; |
|
231 |
|
|
232 |
// Getting the animation extension point. |
|
233 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
234 |
.getInstance(); |
|
235 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
236 |
.get("Animation")); |
|
237 |
|
|
238 |
// Creating new track |
|
239 |
animationTimeTrack = AnimationUtils.getAnimationTimeTrack(baseName |
|
240 |
+ "-encuadrator_track_3D", ac, view); |
|
241 |
|
|
242 |
// Creating the interval |
|
243 |
List intervalList = animationTimeTrack |
|
244 |
.getIntervalList(); |
|
245 |
if (intervalList != null) { |
|
246 |
for (Iterator iterator = intervalList.iterator(); iterator |
|
247 |
.hasNext();) { |
|
248 |
AnimationKeyFrameInterval animationKeyFrameInterval = (AnimationKeyFrameInterval) iterator |
|
249 |
.next(); |
|
250 |
if (animationKeyFrameInterval != null) { |
|
251 |
AKFinterval = animationKeyFrameInterval; |
|
252 |
} |
|
253 |
} |
|
254 |
if (intervalList.size() == 0) { |
|
255 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
|
256 |
.createKeyFrameInterval(); |
|
257 |
// Setting up interval properties. |
|
258 |
AKFinterval.setInitialTime(0.0); |
|
259 |
AKFinterval.setEndTime(1.0); |
|
260 |
} |
|
261 |
} |
|
262 |
// Getting the current camera position and insert it into project camera list. |
|
263 |
Camera ca = view.getCamera(); |
|
264 |
ProjectCamera camera = new ProjectCamera(); |
|
265 |
camera.setDescription(name); |
|
266 |
camera.setCamera(ca); |
|
267 |
project.addCamera(camera); |
|
268 |
|
|
269 |
List<ProjectCamera> extentsList = filterExtendsList(baseName, project); |
|
270 |
keyFrameList = new ArrayList<IKeyFrame>(); |
|
271 |
for (int i = 0; i < extentsList.size(); i++) { |
|
272 |
ProjectCamera projectCamera = (ProjectCamera) extentsList.get(i); |
|
273 |
IKeyFrame kf3D = null; |
|
274 |
try { |
|
275 |
kf3D = (IKeyFrame) extPoint.create("KeyFrame3DFlat"); |
|
276 |
} catch (InstantiationException e) { |
|
277 |
e.printStackTrace(); |
|
278 |
} catch (IllegalAccessException e) { |
|
279 |
e.printStackTrace(); |
|
280 |
} |
|
281 |
|
|
282 |
// Setting up the initial and end time interval. |
|
283 |
double fin = AKFinterval.getEndTime(); |
|
284 |
double ini = AKFinterval.getInitialTime(); |
|
285 |
double size = extentsList.size(); |
|
286 |
// Calculating the correct time for this key frame. |
|
287 |
double tiempo = 0.0; |
|
288 |
if (i != 0) |
|
289 |
tiempo = i * ((fin - ini) / (size - 1.0)); |
|
290 |
// Setting the time. |
|
291 |
kf3D.setTime(tiempo); |
|
292 |
// hacer funcion de insercion o adapter |
|
293 |
kf3D.setAnimatedObject(projectCamera); |
|
294 |
kf3D.CapturesProperties(); |
|
295 |
keyFrameList.add(kf3D); |
|
296 |
} |
|
297 |
AKFinterval.setKeyFrameList(keyFrameList); |
|
298 |
|
|
299 |
} |
|
300 |
|
|
301 |
private static List<ProjectCamera> filterExtendsList(String baseName, |
|
302 |
Project project2) { |
|
303 |
List<ProjectCamera> extendsList = null; |
|
304 |
Object[] extentsList = project2.getCameras(); |
|
305 |
for (int i = 0; i < extentsList.length; i++) { |
|
306 |
ProjectCamera projectCamera = (ProjectCamera) extentsList[i]; |
|
307 |
if (projectCamera.getDescription().contains(baseName)) { |
|
308 |
if (extendsList == null) |
|
309 |
extendsList = new ArrayList<ProjectCamera>(); |
|
310 |
extendsList.add(projectCamera); |
|
311 |
} |
|
312 |
} |
|
313 |
return extendsList; |
|
314 |
} |
|
315 |
|
|
316 |
private static AnimationTimeTrack getAnimationTimeTrack(String name, |
|
317 |
AnimationContainer ac, BaseView view) { |
|
318 |
|
|
319 |
AnimationTimeTrack att = null; |
|
320 |
if (view instanceof View) { |
|
321 |
att = AnimationUtils.getAnimationTimeTrackForView(name, ac, |
|
322 |
(View) view); |
|
323 |
} |
|
324 |
|
|
325 |
if (view instanceof View3D) { |
|
326 |
att = AnimationUtils.getAnimationTimeTrackForView3D(name, ac, |
|
327 |
(View3D) view); |
|
328 |
} |
|
329 |
return att; |
|
330 |
} |
|
331 |
|
|
332 |
private static AnimationTimeTrack getAnimationTimeTrackForView(String name, |
|
333 |
AnimationContainer ac, View view) { |
|
334 |
|
|
335 |
AnimationTimeTrack at = null; |
|
336 |
IAnimationTrack aa = ac.findTrack(name); |
|
337 |
if (aa == null) { |
|
338 |
|
|
339 |
// Getting the extension point. |
|
340 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
341 |
.getInstance(); |
|
342 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
343 |
.get("Animation")); |
|
344 |
|
|
345 |
IAnimationType animationLayer2D = null; |
|
346 |
try { |
|
347 |
animationLayer2D = (IAnimationType) extPoint |
|
348 |
.create("AnimationLayer2D"); |
|
349 |
} catch (InstantiationException e) { |
|
350 |
// TODO Auto-generated catch block |
|
351 |
e.printStackTrace(); |
|
352 |
} catch (IllegalAccessException e) { |
|
353 |
// TODO Auto-generated catch block |
|
354 |
e.printStackTrace(); |
|
355 |
} |
|
356 |
// Setting up the track properties |
|
357 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animationLayer2D); |
|
358 |
at.setName(name); |
|
359 |
at.setEnable(true); |
|
360 |
// Setting up the animated object |
|
361 |
// Creating the object 2D |
|
362 |
AnimatedObjectBase object2D = new AnimationObject2D(); |
|
363 |
|
|
364 |
// Getting the interpolator |
|
365 |
IInterpolator inter2D = InterpolatorFactory |
|
366 |
.createObject("Interpolator2D"); |
|
367 |
((AnimationObject2D)object2D).setAnimatedView(view); |
|
368 |
|
|
369 |
// Getting the interpolator funcion |
|
370 |
IInterpolatorTimeFuntion funtion = FuntionFactory |
|
371 |
.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion"); |
|
372 |
inter2D.setFuntion(funtion); |
|
373 |
|
|
374 |
animationLayer2D.setInterpolator(inter2D); |
|
375 |
at.setAnimationType(animationLayer2D); |
|
376 |
animationLayer2D.setAnimatedObject(object2D); |
|
377 |
|
|
378 |
at.setAnimatedObject(object2D); |
|
379 |
} else { |
|
380 |
at = (AnimationTimeTrack) aa; |
|
381 |
} |
|
382 |
|
|
383 |
return at; |
|
384 |
|
|
385 |
} |
|
386 |
|
|
387 |
private static AnimationTimeTrack getAnimationTimeTrackForView3D( |
|
388 |
String name, AnimationContainer ac, View3D view) { |
|
389 |
|
|
390 |
AnimationTimeTrack at = null; |
|
391 |
IAnimationTrack aa = ac.findTrack(name); |
|
392 |
if (aa == null) { |
|
393 |
|
|
394 |
// Getting the extension point. |
|
395 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
396 |
.getInstance(); |
|
397 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
398 |
.get("Animation")); |
|
399 |
|
|
400 |
IAnimationType animationLayer3DFlat = null; |
|
401 |
try { |
|
402 |
animationLayer3DFlat = (IAnimationType) extPoint |
|
403 |
.create("AnimationLayer3DFlat"); |
|
404 |
} catch (InstantiationException e) { |
|
405 |
// TODO Auto-generated catch block |
|
406 |
e.printStackTrace(); |
|
407 |
} catch (IllegalAccessException e) { |
|
408 |
e.printStackTrace(); |
|
409 |
} |
|
410 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animationLayer3DFlat); |
|
411 |
|
|
412 |
at.setName(name); |
|
413 |
at.setEnable(true); |
|
414 |
|
|
415 |
AnimatedObjectBase object3D = new AnimationObject3DFlat(); |
|
416 |
((AnimationObject3DFlat)object3D).setAnimatedCanvas3D(view.getCanvas3d()); |
|
417 |
((AnimationObject3DFlat)object3D).setAnimatedView(view); |
|
418 |
|
|
419 |
at.setAnimatedObject(object3D); |
|
420 |
|
|
421 |
/** ******************************************************************* */ |
|
422 |
IInterpolator interpolator3D = null; |
|
423 |
if (view.getTerrain().getCoordinateSystemType() == Terrain.CoordinateSystemType.PROJECTED) { |
|
424 |
interpolator3D = InterpolatorFactory |
|
425 |
.createObject("Interpolator3DFlat"); |
|
426 |
} else if (view.getTerrain().getCoordinateSystemType() == Terrain.CoordinateSystemType.GEOCENTRIC) { |
|
427 |
interpolator3D = InterpolatorFactory |
|
428 |
.createObject("Interpolator3DSpherical"); |
|
429 |
} |
|
430 |
|
|
431 |
IInterpolatorTimeFuntion funtion = FuntionFactory |
|
432 |
.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion"); |
|
433 |
interpolator3D.setFuntion(funtion); |
|
434 |
animationLayer3DFlat.setInterpolator(interpolator3D); |
|
435 |
at.setAnimationType(animationLayer3DFlat); |
|
436 |
|
|
437 |
animationLayer3DFlat.setAnimatedObject(object3D); |
|
438 |
|
|
439 |
/** ********************************************************************* */ |
|
440 |
/******************************************************************* |
|
441 |
* old code * IInterpolator inter3DFlat = InterpolatorFactory |
|
442 |
* .createObject("Interpolator3DFlat"); IInterpolatorTimeFuntion |
|
443 |
* funtion = FuntionFactory |
|
444 |
* .createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion"); |
|
445 |
* inter3DFlat.setFuntion(funtion); |
|
446 |
* animationLayer3DFlat.setInterpolator(inter3DFlat); |
|
447 |
* at.setAnimationType(animationLayer3DFlat); |
|
448 |
* animationLayer3DFlat.setAnimatedObject(object3D); / |
|
449 |
******************************************************************/ |
|
450 |
} else { |
|
451 |
at = (AnimationTimeTrack) aa; |
|
452 |
} |
|
453 |
return at; |
|
454 |
|
|
455 |
} |
|
456 |
|
|
457 |
/** |
|
458 |
* Return a new animation document or the document where the view viewName is included |
|
459 |
* |
|
460 |
* @param viewName |
|
461 |
* @param project |
|
462 |
* @return a new or actual animation document |
|
463 |
*/ |
|
464 |
public static ProjectAnimationDocument createAnimationDocument( |
|
465 |
String viewName, Project project) { |
|
466 |
ProjectAnimationDocument pv = null; |
|
467 |
ArrayList<ProjectDocument> projectList = project |
|
468 |
.getDocumentsByType(ProjectAnimationDocumentFactory.registerName); |
|
469 |
Iterator<ProjectDocument> it = projectList.iterator(); |
|
470 |
while (it.hasNext()) { |
|
471 |
ProjectDocument projectDocument = (ProjectDocument) it.next(); |
|
472 |
if (viewName.equals(projectDocument.getName())) { |
|
473 |
pv = (ProjectAnimationDocument) projectDocument; |
|
474 |
} |
|
475 |
|
|
476 |
} |
|
477 |
if (pv == null) { |
|
478 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
479 |
.getInstance(); |
|
480 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
481 |
.get("Documents")); |
|
482 |
ProjectDocumentFactory pdf = null; |
|
483 |
try { |
|
484 |
pdf = (ProjectDocumentFactory) extPoint |
|
485 |
.create(ProjectAnimationDocumentFactory.registerName); |
|
486 |
} catch (InstantiationException e) { |
|
487 |
e.printStackTrace(); |
|
488 |
} catch (IllegalAccessException e) { |
|
489 |
e.printStackTrace(); |
|
490 |
} |
|
491 |
pv = (ProjectAnimationDocument) pdf.create((Project) null); |
|
492 |
pv.setProjectDocumentFactory(pdf); |
|
493 |
pv.setName(viewName); |
|
494 |
} |
|
495 |
return pv; |
|
496 |
} |
|
497 |
|
|
498 |
/** |
|
499 |
* Return the document indicated with the parameter name |
|
500 |
* |
|
501 |
* @param name |
|
502 |
* @param project |
|
503 |
* @return |
|
504 |
*/ |
|
505 |
public static ProjectAnimationDocument getProjectDocument(String name, |
|
506 |
Project project) { |
|
507 |
ProjectAnimationDocument pv = null; |
|
508 |
ArrayList<ProjectDocument> projectList = project |
|
509 |
.getDocumentsByType(ProjectAnimationDocumentFactory.registerName); |
|
510 |
Iterator<ProjectDocument> it = projectList.iterator(); |
|
511 |
while (it.hasNext()) { |
|
512 |
ProjectDocument projectDocument = (ProjectDocument) it.next(); |
|
513 |
if (name.equals(projectDocument.getName())) { |
|
514 |
pv = (ProjectAnimationDocument) projectDocument; |
|
515 |
} |
|
516 |
|
|
517 |
} |
|
518 |
return pv; |
|
519 |
} |
|
520 |
|
|
521 |
public static boolean exitsProject(String name, Project project) { |
|
522 |
boolean pv = false; |
|
523 |
ArrayList<ProjectDocument> projectList = project |
|
524 |
.getDocumentsByType(ProjectAnimationDocumentFactory.registerName); |
|
525 |
Iterator<ProjectDocument> it = projectList.iterator(); |
|
526 |
while (it.hasNext()) { |
|
527 |
ProjectDocument projectDocument = (ProjectDocument) it.next(); |
|
528 |
if (name.equals(projectDocument.getName())) { |
|
529 |
pv = true; |
|
530 |
} |
|
531 |
|
|
532 |
} |
|
533 |
return pv; |
|
534 |
} |
|
535 |
|
|
536 |
/** |
|
537 |
* |
|
538 |
* @param name : |
|
539 |
* Track name. |
|
540 |
* @param ac: animation container. |
|
541 |
* @param object: animated object |
|
542 |
* @return at : Return an animation track based in time. |
|
543 |
* |
|
544 |
* Creating a animation track based in time. |
|
545 |
*/ |
|
546 |
public static AnimationTimeTrack getAnimationTimeTrackTransparency( |
|
547 |
String name, AnimationContainer ac, BaseView view, |
|
548 |
IAnimatedObject object) { |
|
549 |
|
|
550 |
AnimationTimeTrack at = null;// this.animationTimeTrack; |
|
551 |
|
|
552 |
IAnimationTrack animationTrack = ac.findTrack(name); |
|
553 |
if (animationTrack == null) { |
|
554 |
|
|
555 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
556 |
.getInstance(); |
|
557 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
558 |
.get("Animation")); |
|
559 |
|
|
560 |
IAnimationType animTransp = null; |
|
561 |
try { |
|
562 |
System.out.println(extPoint.getDescription()); |
|
563 |
|
|
564 |
// Instancing my new animation based in transparency. |
|
565 |
animTransp = (IAnimationType) extPoint |
|
566 |
.create("AnimationTransparency"); |
|
567 |
} catch (InstantiationException e) { |
|
568 |
e.printStackTrace(); |
|
569 |
} catch (IllegalAccessException e) { |
|
570 |
e.printStackTrace(); |
|
571 |
} |
|
572 |
|
|
573 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animTransp); |
|
574 |
at.setName(name); |
|
575 |
|
|
576 |
// Saving the view( in this case a BaseView). |
|
577 |
|
|
578 |
object.addAnimatedObject("view", view); |
|
579 |
|
|
580 |
at.setAnimatedObject(object); |
|
581 |
animTransp.setAnimatedObject(object); |
|
582 |
// My interpolator based in time and transparency. |
|
583 |
IInterpolator interTransparency = InterpolatorFactory |
|
584 |
.createObject("InterpolatorTransparency"); |
|
585 |
animTransp.setInterpolator(interTransparency); |
|
586 |
at.setAnimationType(animTransp); |
|
587 |
} else { |
|
588 |
at = (AnimationTimeTrack) animationTrack; |
|
589 |
} |
|
590 |
return at; |
|
591 |
} |
|
592 |
|
|
593 |
/** |
|
594 |
* Creating a transparency animation common 2D and 3D |
|
595 |
* @param window |
|
596 |
* @param ac |
|
597 |
* @param prefix |
|
598 |
*/ |
|
599 |
|
|
600 |
public static void createLayerTransparencyAnimation(BaseView window, |
|
601 |
AnimationContainer ac, String prefix) { |
|
602 |
System.out.println("pulsado boton transparencias !!!"); |
|
603 |
|
|
604 |
AnimationTimeTrack animationTimeTrack = null; |
|
605 |
AnimationKeyFrameInterval AKFinterval = null; |
|
606 |
List<IKeyFrame> keyFrameList = null; |
|
607 |
AnimatedObjectBase object = new AnimatedObjectBase(); |
|
608 |
// Getting the animation extension point |
|
609 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
610 |
.getInstance(); |
|
611 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
612 |
.get("Animation")); |
|
613 |
|
|
614 |
// List of keyframes. |
|
615 |
// If the window is instance of View |
|
616 |
if (window instanceof BaseView) { |
|
617 |
|
|
618 |
BaseView view = (BaseView) window; |
|
619 |
|
|
620 |
// Generating the list of keyframes |
|
621 |
// keyFrameList = new ArrayList(); |
|
622 |
IProjectView model = view.getModel(); |
|
623 |
MapContext mapContext = model.getMapContext(); |
|
624 |
FLayers layers = mapContext.getLayers(); |
|
625 |
FLayer[] actives = layers.getActives(); |
|
626 |
|
|
627 |
double fin = 1;// AKFinterval.getEndTime(); |
|
628 |
double ini = 0;// AKFinterval.getInitialTime(); |
|
629 |
double tiempo = 0.0; |
|
630 |
int size = actives.length; |
|
631 |
double incremento = ((fin - ini) / (size)); |
|
632 |
for (int i = size - 1; i >= 0; i--) {// order in TOC. |
|
633 |
|
|
634 |
animationTimeTrack = null; |
|
635 |
animationTimeTrack = AnimationUtils |
|
636 |
.getAnimationTimeTrackTransparency("Track_layer_" + i, |
|
637 |
ac, view, object); |
|
638 |
animationTimeTrack.setEnable(true); |
|
639 |
object.addAnimatedObject("layer", actives[i]); |
|
640 |
|
|
641 |
// Generating the interval. |
|
642 |
AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
|
643 |
.createKeyFrameInterval(); |
|
644 |
AKFinterval.setInitialTime(0.0); |
|
645 |
AKFinterval.setEndTime(1.0); |
|
646 |
|
|
647 |
keyFrameList = new ArrayList<IKeyFrame>(); |
|
648 |
IKeyFrame kfTransAux = null; |
|
649 |
IKeyFrame kfTransIni = null; |
|
650 |
IKeyFrame kfTransFin = null; |
|
651 |
try { |
|
652 |
kfTransAux = (IKeyFrame) extPoint |
|
653 |
.create("KeyFrameTransparency"); |
|
654 |
kfTransIni = (IKeyFrame) extPoint |
|
655 |
.create("KeyFrameTransparency"); |
|
656 |
kfTransFin = (IKeyFrame) extPoint |
|
657 |
.create("KeyFrameTransparency"); |
|
658 |
} catch (InstantiationException e1) { |
|
659 |
e1.printStackTrace(); |
|
660 |
} catch (IllegalAccessException e1) { |
|
661 |
e1.printStackTrace(); |
|
662 |
} |
|
663 |
// Calculating the time insertion. |
|
664 |
if (i == size - 1) // the keyframe is the first in the list. |
|
665 |
tiempo = ini + 0.001; |
|
666 |
|
|
667 |
// Three keyframes by track. |
|
668 |
// Keyframe 1 of the layer i. |
|
669 |
kfTransAux.setName("KF1_layer_" + i);// name of keyframe. |
|
670 |
kfTransAux.setTime(ini); // initial time interval. |
|
671 |
kfTransAux.setAnimatedObject(actives[i]);// set the object to |
|
672 |
// animate(a layer). |
|
673 |
kfTransAux.CapturesProperties(); // capturing actual |
|
674 |
// transparency. |
|
675 |
keyFrameList.add(kfTransAux); // adding in the list. |
|
676 |
|
|
677 |
// keyframe 2 of the layer i. |
|
678 |
kfTransIni.setName("KF2_layer_" + i);// name of keyframe. |
|
679 |
kfTransIni.setTime(tiempo); // initial time interval. |
|
680 |
kfTransIni.setAnimatedObject(actives[i]);// set the same |
|
681 |
// layer in the |
|
682 |
// second keyframe. |
|
683 |
kfTransIni.CapturesProperties(); // capturing actual |
|
684 |
// transparency. |
|
685 |
keyFrameList.add(kfTransIni); // adding in the list. |
|
686 |
|
|
687 |
// keyframe 3 of the layer i. |
|
688 |
try { |
|
689 |
if (i == 0) // the keyframe is the last in the list. |
|
690 |
tiempo = fin; |
|
691 |
else |
|
692 |
tiempo += incremento; |
|
693 |
|
|
694 |
kfTransFin.setName("KF3_layer_" + i);// name of keyframe. |
|
695 |
kfTransFin.setTime(tiempo);// saving final time interval. |
|
696 |
// kfTransFin.setLevelTransparency(0);// interpolation: |
|
697 |
// layer transparency in |
|
698 |
// the moment to 0. |
|
699 |
kfTransFin.setAnimatedObject(actives[i]); // save the same |
|
700 |
// layer in the |
|
701 |
// third |
|
702 |
// keyframe |
|
703 |
keyFrameList.add(kfTransFin);// adding to the list. |
|
704 |
} catch (Exception e) { |
|
705 |
// TODO Auto-generated catch block |
|
706 |
e.printStackTrace(); |
|
707 |
} |
|
708 |
AKFinterval.setKeyFrameList(keyFrameList);// Adding the list |
|
709 |
// of keyframes to |
|
710 |
// the interval. |
|
711 |
|
|
712 |
} |
|
713 |
} |
|
714 |
} |
|
715 |
|
|
716 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_11/extensions/extAnimationGUI/src/com/iver/ai2/animationgui/gui/MenuAnimationTransparency.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
|
|
20 |
package com.iver.ai2.animationgui.gui; |
|
21 |
|
|
22 |
import com.iver.ai2.animationgui.gui.document.ProjectAnimationDocument; |
|
23 |
import com.iver.ai2.animationgui.gui.util.AnimationUtils; |
|
24 |
import com.iver.andami.PluginServices; |
|
25 |
import com.iver.andami.plugins.Extension; |
|
26 |
import com.iver.andami.plugins.IExtension; |
|
27 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
28 |
import com.iver.cit.gvsig.ProjectExtension; |
|
29 |
import com.iver.cit.gvsig.animation.AnimationContainer; |
|
30 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
31 |
import com.iver.cit.gvsig.animation.animatedObject.AnimatedObjectBase; |
|
32 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
|
33 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.InterpolatorFactory; |
|
34 |
import com.iver.cit.gvsig.animation.traks.AnimationTimeTrack; |
|
35 |
import com.iver.cit.gvsig.animation.traks.IAnimationTrack; |
|
36 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
37 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
38 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
39 |
import com.iver.cit.gvsig.project.Project; |
|
40 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
|
41 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
|
42 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
|
43 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
|
44 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
45 |
|
|
46 |
/** |
|
47 |
* @author ?ngel |
|
48 |
* @since 1.1 |
|
49 |
* |
|
50 |
* Menu of animation transparency toolbar's options. |
|
51 |
*/ |
|
52 |
|
|
53 |
public class MenuAnimationTransparency extends Extension { |
|
54 |
|
|
55 |
private Project project; |
|
56 |
|
|
57 |
// private AnimationContainer ac = null; |
|
58 |
private AnimationTimeTrack animationTimeTrack = null; |
|
59 |
private AnimatedObjectBase object = new AnimatedObjectBase(); |
|
60 |
|
|
61 |
// It is the project Document create to create a fast animation. |
|
62 |
private ProjectAnimationDocument pad; |
|
63 |
|
|
64 |
public void execute(String actionCommand) { |
|
65 |
|
|
66 |
AnimationContainer ac; |
|
67 |
// if the button pressed is "this" |
|
68 |
if (actionCommand.equals("CREARANIMTRANSP")) { |
|
69 |
|
|
70 |
String prefix = "Default-animation-document"; |
|
71 |
// if there is not create the default animation. we will create it. |
|
72 |
pad = AnimationUtils.createAnimationDocument(prefix, project); |
|
73 |
if (!AnimationUtils.exitsProject(prefix, project)){ |
|
74 |
project.addDocument(pad); |
|
75 |
} |
|
76 |
|
|
77 |
// Getting the active windows |
|
78 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
79 |
|
|
80 |
// Getting the animation container |
|
81 |
ac = pad.getAnimationContainer(); |
|
82 |
// Generating the animation transparency |
|
83 |
AnimationUtils.createLayerTransparencyAnimation((BaseView) window, |
|
84 |
ac, prefix); |
|
85 |
|
|
86 |
// Menu Player. |
|
87 |
// AnimationPlayer ap = ac.getAnimationPlayer(); |
|
88 |
// ap.setAnimationContainer(ac); |
|
89 |
// AnimationContol3D fp = new AnimationContol3D(ap); |
|
90 |
// PluginServices.getMDIManager().addWindow((IWindow) fp); |
|
91 |
} |
|
92 |
|
|
93 |
// System.out.println("pulsado boton transparencias !!!"); |
|
94 |
// |
|
95 |
// // Getting the active windows |
|
96 |
// IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
97 |
// |
|
98 |
// // Getting the animation container |
|
99 |
// ac = this.getAnimationContainer(); |
|
100 |
// |
|
101 |
// |
|
102 |
// // Getting the animation extension point |
|
103 |
// ExtensionPoints extensionPoints = |
|
104 |
// ExtensionPointsSingleton.getInstance(); |
|
105 |
// ExtensionPoint extPoint = ((ExtensionPoint) |
|
106 |
// extensionPoints.get("Animation")); |
|
107 |
// |
|
108 |
// |
|
109 |
// //List of keyframes. |
|
110 |
// // If the window is instance of View |
|
111 |
// if (window instanceof BaseView) { |
|
112 |
// |
|
113 |
// BaseView view = (BaseView) window; |
|
114 |
// |
|
115 |
// // Generating the list of keyframes |
|
116 |
// //keyFrameList = new ArrayList(); |
|
117 |
// IProjectView model = view.getModel(); |
|
118 |
// MapContext mapContext = model.getMapContext(); |
|
119 |
// FLayers layers = mapContext.getLayers(); |
|
120 |
// FLayer[] actives = layers.getActives(); |
|
121 |
// |
|
122 |
// double fin = 1;//AKFinterval.getEndTime(); |
|
123 |
// double ini = 0;//AKFinterval.getInitialTime(); |
|
124 |
// double tiempo = 0.0; |
|
125 |
// int size = actives.length; |
|
126 |
// double incremento = ((fin - ini) / (size)); |
|
127 |
// for(int i = size-1; i >= 0; i--){// order in TOC. |
|
128 |
// |
|
129 |
// animationTimeTrack = null; |
|
130 |
// animationTimeTrack = |
|
131 |
// AnimationUtils.getAnimationTimeTrackTransparency("Track_layer_" + i, |
|
132 |
// ac); |
|
133 |
// animationTimeTrack.setEnabale(true); |
|
134 |
// object.addAnimatedObject("layer",actives[i]); |
|
135 |
// |
|
136 |
// |
|
137 |
// // Generating the interval. |
|
138 |
// AKFinterval = (AnimationKeyFrameInterval) animationTimeTrack |
|
139 |
// .createKeyFrameInterval(); |
|
140 |
// AKFinterval.setInitialTime(0.0); |
|
141 |
// AKFinterval.setEndTime(1.0); |
|
142 |
// |
|
143 |
// keyFrameList = new ArrayList<IKeyFrame>(); |
|
144 |
// // KeyFrameTransparency kfTransAux = new KeyFrameTransparency(); |
|
145 |
// IKeyFrame kfTransAux = null; |
|
146 |
// IKeyFrame kfTransIni = null; |
|
147 |
// IKeyFrame kfTransFin = null; |
|
148 |
// try { |
|
149 |
// kfTransAux = (IKeyFrame)extPoint.create("KeyFrameTransparency"); |
|
150 |
// kfTransIni = (IKeyFrame)extPoint.create("KeyFrameTransparency"); |
|
151 |
// kfTransFin = (IKeyFrame)extPoint.create("KeyFrameTransparency"); |
|
152 |
// } |
|
153 |
// catch (InstantiationException e1) { |
|
154 |
// e1.printStackTrace(); |
|
155 |
// } catch (IllegalAccessException e1) { |
|
156 |
// e1.printStackTrace(); |
|
157 |
// } |
|
158 |
// //Calculating the time insertion. |
|
159 |
// if (i == size-1) // the keyframe is the first in the list. |
|
160 |
// tiempo = ini + 0.001; |
|
161 |
// |
|
162 |
// //Three keyframes by track. |
|
163 |
// //Keyframe 1 of the layer i. |
|
164 |
// kfTransAux.setName("KF1_layer_" + i);//name of keyframe. |
|
165 |
// kfTransAux.setTime(ini); // initial time interval. |
|
166 |
// kfTransAux.setAnimatedObject(actives[i]);//set the object to |
|
167 |
// animate(a layer). |
|
168 |
// //kfTransAux.setLevelTransparency(255); |
|
169 |
// kfTransAux.CapturesProperties(); //capturing actual transparency. |
|
170 |
// keyFrameList.add(kfTransAux); // adding in the list. |
|
171 |
// |
|
172 |
// //keyframe 2 of the layer i. |
|
173 |
// kfTransIni.setName("KF2_layer_" + i);//name of keyframe. |
|
174 |
// kfTransIni.setTime(tiempo); // initial time interval. |
|
175 |
// kfTransIni.setAnimatedObject(actives[i]);//set the same layer in the |
|
176 |
// second keyframe. |
|
177 |
// kfTransIni.CapturesProperties(); //capturing actual transparency. |
|
178 |
// keyFrameList.add(kfTransIni); // adding in the list. |
|
179 |
// |
|
180 |
// //keyframe 3 of the layer i. |
|
181 |
// try { |
|
182 |
// if(i == 0) // the keyframe is the last in the list. |
|
183 |
// tiempo = fin; |
|
184 |
// else |
|
185 |
// tiempo += incremento; |
|
186 |
// |
|
187 |
// kfTransFin.setName("KF3_layer_" + i);//name of keyframe. |
|
188 |
// kfTransFin.setTime(tiempo);// saving final time interval. |
|
189 |
// // kfTransFin.setLevelTransparency(0);// interpolation: layer |
|
190 |
// transparency in the moment to 0. |
|
191 |
// kfTransFin.setAnimatedObject(actives[i]); //save the same layer in |
|
192 |
// the third keyframe |
|
193 |
// keyFrameList.add(kfTransFin);//adding to the list. |
|
194 |
// } catch (Exception e) { |
|
195 |
// // TODO Auto-generated catch block |
|
196 |
// e.printStackTrace(); |
|
197 |
// } |
|
198 |
// AKFinterval.setKeyFrameList(keyFrameList);// Adding the list of |
|
199 |
// keyframes to the interval. |
|
200 |
// |
|
201 |
// } |
|
202 |
// } |
|
203 |
// } |
|
204 |
|
|
205 |
} |
|
206 |
|
|
207 |
public void postInitialize() { |
|
208 |
// Getting the project using plugin services. |
|
209 |
IExtension extension = PluginServices |
|
210 |
.getExtension(com.iver.cit.gvsig.ProjectExtension.class); |
|
211 |
ProjectExtension pe = (ProjectExtension) extension; |
|
212 |
project = pe.getProject(); |
|
213 |
|
|
214 |
PluginServices.getIconTheme().registerDefault( |
|
215 |
"transparency-icon", |
|
216 |
this.getClass().getClassLoader().getResource( |
|
217 |
"images/trans6.png")); |
|
218 |
} |
|
219 |
|
|
220 |
public void initialize() { |
|
221 |
// TODO Auto-generated method stub |
|
222 |
} |
|
223 |
|
|
224 |
|
|
225 |
/** |
|
226 |
* |
|
227 |
* @param name : |
|
228 |
* Track name. |
|
229 |
* @param ac : |
|
230 |
* animation container. |
|
231 |
* @return at : Return a animation track based in time. |
|
232 |
* |
|
233 |
* Creating a animation track based in time. |
|
234 |
*/ |
|
235 |
private AnimationTimeTrack getAnimationTimeTrack_DELETED(String name, |
|
236 |
AnimationContainer ac) { |
|
237 |
|
|
238 |
AnimationTimeTrack at = this.animationTimeTrack; |
|
239 |
|
|
240 |
IAnimationTrack animationTrack = ac.findTrack(name); |
|
241 |
if (animationTrack == null) { |
|
242 |
|
|
243 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
244 |
.getInstance(); |
|
245 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
|
246 |
.get("Animation")); |
|
247 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices // window |
|
248 |
// active. |
|
249 |
.getMDIManager().getActiveWindow(); |
|
250 |
|
|
251 |
if (f instanceof BaseView) { |
|
252 |
IAnimationType animTransp = null; |
|
253 |
try { |
|
254 |
System.out.println(extPoint.getDescription()); |
|
255 |
|
|
256 |
// Instancing my new animation based in transparency. |
|
257 |
animTransp = (IAnimationType) extPoint |
|
258 |
.create("AnimationTransparency"); |
|
259 |
} catch (InstantiationException e) { |
|
260 |
e.printStackTrace(); |
|
261 |
} catch (IllegalAccessException e) { |
|
262 |
e.printStackTrace(); |
|
263 |
} |
|
264 |
|
|
265 |
at = (AnimationTimeTrack) ac.CreateTimeTrack(animTransp); |
|
266 |
at.setName(name); |
|
267 |
|
|
268 |
// Saving the view( in this case a BaseView). |
|
269 |
BaseView view = (BaseView) f; |
|
270 |
|
|
271 |
object.addAnimatedObject("view", view); |
|
272 |
|
|
273 |
at.setAnimatedObject(object); |
|
274 |
animTransp.setAnimatedObject(object); |
|
275 |
// My interpolator based in time and transparency. |
|
276 |
IInterpolator interTransparency = InterpolatorFactory |
|
277 |
.createObject("InterpolatorTransparency"); |
|
278 |
animTransp.setInterpolator(interTransparency); |
|
279 |
at.setAnimationType(animTransp); |
|
280 |
} |
|
281 |
} |
|
282 |
return at; |
|
283 |
} |
|
284 |
|
|
285 |
/** |
|
286 |
* @see com.iver.andami.plugins.IExtension#isVisible() Options to see the |
|
287 |
* button in the tool bar. View: must be a base view. One or more |
|
288 |
* layers in the view. |
|
289 |
*/ |
|
290 |
public boolean isVisible() { |
|
291 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
|
292 |
.getMDIManager().getActiveWindow(); |
|
293 |
|
|
294 |
if (f == null) { |
|
295 |
return false; |
|
296 |
} |
|
297 |
|
|
298 |
// Only isVisible = true, where the view have layers. |
|
299 |
if (f instanceof BaseView) { |
|
300 |
BaseView vista = (BaseView) f; |
|
301 |
IProjectView model = vista.getModel(); |
|
302 |
MapContext mapa = model.getMapContext(); |
|
303 |
|
|
304 |
return mapa.getLayers().getLayersCount() > 0; |
|
305 |
} |
|
306 |
return false; |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* @see com.iver.andami.plugins.IExtension#isEnabled() Options when we can |
|
311 |
* use this animation type. View: must be a base view. One or more |
|
312 |
* ACTIVATED layers in the view. |
|
313 |
*/ |
|
314 |
public boolean isEnabled() { |
|
315 |
// TODO Auto-generated method stub |
|
316 |
|
|
317 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
|
318 |
.getMDIManager().getActiveWindow(); |
|
319 |
|
|
320 |
// if the view is not activated. |
|
321 |
if (f == null) |
|
322 |
return false; |
|
323 |
// if the view is a instance of a base view. |
|
324 |
if (f instanceof BaseView) { |
|
325 |
BaseView baseView = (BaseView) f; |
|
326 |
IProjectView model = baseView.getModel(); |
|
327 |
MapContext mapContext = model.getMapContext(); |
|
328 |
FLayers layers = mapContext.getLayers(); |
|
329 |
FLayer[] actives = layers.getActives(); |
|
330 |
// only is enabled with one or more layers activated. |
|
331 |
if (actives.length > 0) { |
|
332 |
return true; |
|
333 |
} |
|
334 |
} |
|
335 |
return false; |
|
336 |
} |
|
337 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_11/extensions/extAnimationGUI/src/com/iver/ai2/animationgui/gui/document/ProjectAnimationDocument.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
|
|
20 |
package com.iver.ai2.animationgui.gui.document; |
|
21 |
|
|
22 |
import java.util.Iterator; |
|
23 |
|
|
24 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
25 |
import com.iver.ai2.animationgui.gui.document.Animation.StateUpdate; |
|
26 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
27 |
import com.iver.cit.gvsig.animation.AnimationContainer; |
|
28 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
|
29 |
import com.iver.cit.gvsig.project.Project; |
|
30 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
|
31 |
import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
|
32 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
|
33 |
import com.iver.utiles.IPersistence; |
|
34 |
import com.iver.utiles.XMLEntity; |
|
35 |
|
|
36 |
public class ProjectAnimationDocument extends ProjectDocument { |
|
37 |
|
|
38 |
|
|
39 |
private static final long serialVersionUID = 1L; |
|
40 |
AnimationContainer animationContainer; |
|
41 |
private Animation animation = null; |
|
42 |
|
|
43 |
public ProjectAnimationDocument() { |
|
44 |
super(); |
|
45 |
this.animationContainer = new AnimationContainer(); |
|
46 |
} |
|
47 |
|
|
48 |
public void afterAdd() { |
|
49 |
// TODO Auto-generated method stub |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
public void afterRemove() { |
|
54 |
// TODO Auto-generated method stub |
|
55 |
|
|
56 |
} |
|
57 |
|
|
58 |
public IWindow createWindow() { |
|
59 |
// Introduce here the code to make the gui. |
|
60 |
if (animation == null) |
|
61 |
animation = new Animation(this); |
|
62 |
else |
|
63 |
animation.startThread(); |
|
64 |
return animation; |
|
65 |
} |
|
66 |
|
|
67 |
public void exportToXML(XMLEntity root, Project project) { |
|
68 |
// TODO Auto-generated method stub |
|
69 |
} |
|
70 |
|
|
71 |
public IWindow getProperties() { |
|
72 |
// TODO Auto-generated method stub |
|
73 |
// Introduce here the code to make the gui for the properties. |
|
74 |
return new AnimationProperties(this, false); |
|
75 |
} |
|
76 |
|
|
77 |
public void importFromXML(XMLEntity root, XMLEntity typeRoot, |
|
78 |
int elementIndex, Project project, boolean removeDocumentsFromRoot) { |
|
79 |
// TODO Auto-generated method stub |
|
80 |
|
|
81 |
} |
|
82 |
|
|
83 |
public AnimationContainer getAnimationContainer() { |
|
84 |
return animationContainer; |
|
85 |
} |
|
86 |
|
|
87 |
public void setAnimationContainer(AnimationContainer animationContainer) { |
|
88 |
this.animationContainer = animationContainer; |
|
89 |
} |
|
90 |
|
|
91 |
public XMLEntity getXMLEntity() { |
|
92 |
XMLEntity xml = null; |
|
93 |
try { |
|
94 |
xml = super.getXMLEntity(); |
|
95 |
xml.addChild(this.animationContainer.getXMLEntity()); |
|
96 |
} catch (SaveException e) { |
|
97 |
// TODO Auto-generated catch block |
|
98 |
e.printStackTrace(); |
|
99 |
} |
|
100 |
return xml; |
|
101 |
} |
|
102 |
|
|
103 |
public void setXMLEntity(XMLEntity xml) { |
|
104 |
// Busqueda de un hijo a partir de su nombre. |
|
105 |
// Node AnimationContainer in the animation tree. Calling setXmlEntity() |
|
106 |
// methods. |
|
107 |
// Reconstruyendo el framework. Primer paso: nuevo container para |
|
108 |
// almacenar. |
|
109 |
try { |
|
110 |
super.setXMLEntity(xml); |
|
111 |
|
|
112 |
int animations = 0; |
|
113 |
Iterator<XMLEntity> iterator = xml.findChildren( |
|
114 |
"animationContainer", "true"); |
|
115 |
if (iterator.hasNext()) { |
|
116 |
XMLEntity xmlAC = iterator.next(); |
|
117 |
animations++; |
|
118 |
String classAC = xmlAC.getStringProperty("className"); |
|
119 |
Class<?> clase = Class.forName(classAC); |
|
120 |
animationContainer = (AnimationContainer) clase |
|
121 |
.newInstance(); |
|
122 |
} |
|
123 |
|
|
124 |
// Crear objeto a partir de su clase. |
|
125 |
Iterator<XMLEntity> iterXML = xml.findChildren("className", |
|
126 |
"com.iver.cit.gvsig.animation.AnimationContainer"); |
|
127 |
if (iterXML.hasNext()) { |
|
128 |
((IPersistence) animationContainer) |
|
129 |
.setXMLEntity((XMLEntity) iterXML.next()); |
|
130 |
} |
|
131 |
|
|
132 |
} catch (XMLException e1) { |
|
133 |
// TODO Auto-generated catch block |
|
134 |
e1.printStackTrace(); |
|
135 |
} catch (OpenException e1) { |
|
136 |
// TODO Auto-generated catch block |
|
137 |
e1.printStackTrace(); |
|
138 |
} catch (ReadDriverException e1) { |
|
139 |
// TODO Auto-generated catch block |
|
140 |
e1.printStackTrace(); |
|
141 |
} catch (InstantiationException e) { |
|
142 |
// TODO Auto-generated catch block |
|
143 |
e.printStackTrace(); |
|
144 |
} catch (IllegalAccessException e) { |
|
145 |
// TODO Auto-generated catch block |
|
146 |
e.printStackTrace(); |
|
147 |
} catch (ClassNotFoundException e) { |
|
148 |
// TODO Auto-generated catch block |
|
149 |
e.printStackTrace(); |
|
150 |
} |
|
151 |
|
|
152 |
} |
|
153 |
|
|
154 |
|
|
155 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_11/extensions/extAnimationGUI/src/com/iver/ai2/animationgui/gui/document/AnimationProperties.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
|
|
20 |
package com.iver.ai2.animationgui.gui.document; |
|
21 |
|
|
22 |
import java.awt.Dimension; |
|
23 |
import java.awt.Insets; |
|
24 |
import java.awt.event.ActionListener; |
|
25 |
|
|
26 |
import javax.swing.BorderFactory; |
|
27 |
import javax.swing.JLabel; |
|
28 |
import javax.swing.JScrollPane; |
|
29 |
import javax.swing.JTextArea; |
|
30 |
import javax.swing.JTextField; |
|
31 |
|
|
32 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
33 |
import org.gvsig.gui.beans.swing.JButton; |
|
34 |
|
|
35 |
import com.iver.andami.PluginServices; |
|
36 |
import com.iver.andami.ui.mdiManager.SingletonWindow; |
|
37 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
38 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
|
39 |
|
|
40 |
/** |
|
41 |
* Dialog where are all the view properties |
|
42 |
* |
|
43 |
* @author ?ngel Fraile Gri??n e-mail: angel.fraile@iver.es |
|
44 |
* @since 1.1 |
|
45 |
* |
|
46 |
*/ |
|
47 |
public class AnimationProperties extends GridBagLayoutPanel implements |
|
48 |
SingletonWindow { |
|
49 |
|
|
50 |
|
|
51 |
private static final long serialVersionUID = 1L; |
|
52 |
|
|
53 |
private JTextField txtName; |
|
54 |
|
|
55 |
private JTextField txtDate; |
|
56 |
|
|
57 |
private JTextField txtOwner; |
|
58 |
|
|
59 |
private int width = 390; |
|
60 |
|
|
61 |
private int height = 250; |
|
62 |
|
|
63 |
private JScrollPane jScrollPane; |
|
64 |
|
|
65 |
private JTextArea txtComments; |
|
66 |
|
|
67 |
private GridBagLayoutPanel okCancelPanel; |
|
68 |
|
|
69 |
private boolean editable; |
|
70 |
|
|
71 |
private JButton okButton; |
|
72 |
|
|
73 |
private JButton cancelButton; |
|
74 |
|
|
75 |
private ProjectDocument projectDocument; |
|
76 |
|
|
77 |
/** |
|
78 |
* Default constructor |
|
79 |
* |
|
80 |
* @param ProjectDocument: Actual project document |
|
81 |
* @param boolean: |
|
82 |
*/ |
|
83 |
public AnimationProperties(ProjectDocument p, boolean edit) { |
|
84 |
projectDocument = p; |
|
85 |
setEditable(edit); |
|
86 |
initialize(); |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* This method initializes this |
|
91 |
*/ |
|
92 |
private void initialize() { |
|
93 |
// Inicialize component |
|
94 |
setName("Animation properties"); |
|
95 |
// Introducing the margin |
|
96 |
setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
|
97 |
// Dimension of the panel |
|
98 |
// setSize(new Dimension(width, height)); |
|
99 |
this.setPreferredSize(new Dimension(width, height)); |
|
100 |
|
|
101 |
// ADDING COMPONENTS |
|
102 |
|
|
103 |
// Name Component |
|
104 |
this.addComponent(PluginServices.getText(this, "Name"), getTxtName(), new Insets(0,10,2,10)); |
|
105 |
// Date component |
|
106 |
this.addComponent(PluginServices.getText(this, "Creation_Date"), getTxtDate(), new Insets(2,10,2,10)); |
|
107 |
// Owner component |
|
108 |
this.addComponent(PluginServices.getText(this, "Owner"), getTxtOwner(), new Insets(2,10,2,10)); |
|
109 |
// Description component |
|
110 |
GridBagLayoutPanel aux = new GridBagLayoutPanel(); |
|
111 |
aux.add(getJScrollPane()); |
|
112 |
addComponent(new JLabel(PluginServices.getText(this, "Commentaries")),new Insets(2,6,2,6)); |
|
113 |
addComponent(aux,new Insets(2,6,2,6)); |
|
114 |
|
|
115 |
|
|
116 |
// Accept buton |
|
117 |
this.addComponent(getOkCancelPanel(),new Insets(2,150,2,0)); |
|
118 |
|
|
119 |
// Inicialicing default values |
|
120 |
this.txtName.setText(PluginServices.getText(this, "Creation_Date")); |
|
121 |
txtName.setText(projectDocument.getName()); |
|
122 |
txtDate.setText(projectDocument.getCreationDate()); |
|
123 |
txtOwner.setText(projectDocument.getOwner()); |
|
124 |
txtComments.setText(projectDocument.getComment()); |
|
125 |
|
|
126 |
} |
|
127 |
|
|
128 |
|
|
129 |
private javax.swing.JTextField getTxtName() { |
|
130 |
if (txtName == null) { |
|
131 |
txtName = new javax.swing.JTextField(); |
|
132 |
txtName.setPreferredSize(new java.awt.Dimension(150, 23)); |
|
133 |
} |
|
134 |
|
|
135 |
return txtName; |
|
136 |
} |
|
137 |
|
|
138 |
private javax.swing.JTextField getTxtDate() { |
|
139 |
if (txtDate == null) { |
|
140 |
txtDate = new javax.swing.JTextField(); |
|
141 |
txtDate.setPreferredSize(new java.awt.Dimension(150, 23)); |
|
142 |
txtDate.setEditable(false); |
|
143 |
txtDate.setBackground(java.awt.Color.white); |
|
144 |
} |
|
145 |
|
|
146 |
return txtDate; |
|
147 |
} |
|
148 |
|
|
149 |
private javax.swing.JTextField getTxtOwner() { |
|
150 |
if (txtOwner == null) { |
|
151 |
txtOwner = new javax.swing.JTextField(); |
|
152 |
txtOwner.setPreferredSize(new java.awt.Dimension(150, 23)); |
|
153 |
} |
|
154 |
|
|
155 |
return txtOwner; |
|
156 |
} |
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
private javax.swing.JScrollPane getJScrollPane() { |
|
161 |
if (jScrollPane == null) { |
|
162 |
jScrollPane = new javax.swing.JScrollPane(); |
|
163 |
//jScrollPane.setSize(new java.awt.Dimension(340, 70)); |
|
164 |
jScrollPane.setViewportView(getTxtComments()); |
|
165 |
jScrollPane.setPreferredSize(new java.awt.Dimension(340, 70)); |
|
166 |
} |
|
167 |
|
|
168 |
return jScrollPane; |
|
169 |
} |
|
170 |
|
|
171 |
private javax.swing.JTextArea getTxtComments() { |
|
172 |
if (txtComments == null) { |
|
173 |
txtComments = new javax.swing.JTextArea(); |
|
174 |
txtComments.setRows(1); |
|
175 |
txtComments.setColumns(28); |
|
176 |
} |
|
177 |
|
|
178 |
return txtComments; |
|
179 |
} |
|
180 |
|
|
181 |
|
|
182 |
private GridBagLayoutPanel getOkCancelPanel() { |
|
183 |
if (okCancelPanel == null) { |
|
184 |
ActionListener okAction, cancelAction; |
|
185 |
okAction = new java.awt.event.ActionListener() { |
|
186 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
187 |
projectDocument.setName(txtName.getText()); |
|
188 |
projectDocument.setCreationDate(txtDate.getText()); |
|
189 |
projectDocument.setOwner(txtOwner.getText()); |
|
190 |
projectDocument.setComment(txtComments.getText()); |
|
191 |
PluginServices.getMDIManager().closeWindow(AnimationProperties.this); |
|
192 |
} |
|
193 |
}; |
|
194 |
cancelAction = new java.awt.event.ActionListener() { |
|
195 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
196 |
PluginServices.getMDIManager().closeWindow(AnimationProperties.this); |
|
197 |
} |
|
198 |
}; |
|
199 |
|
|
200 |
okCancelPanel = new GridBagLayoutPanel(); |
|
201 |
okCancelPanel.setAlignmentX(GridBagLayoutPanel.RIGHT_ALIGNMENT); |
|
202 |
okButton = new JButton(); |
|
203 |
okButton.setText(PluginServices.getText(this, "Accept")); |
|
204 |
okButton.addActionListener(okAction); |
|
205 |
cancelButton = new JButton(); |
|
206 |
cancelButton.setText(PluginServices.getText(this, "Cancel")); |
|
207 |
cancelButton.addActionListener(cancelAction); |
|
208 |
|
|
209 |
okCancelPanel.addComponent(okButton,cancelButton); |
|
210 |
} |
|
211 |
return okCancelPanel; |
|
212 |
} |
|
213 |
|
|
214 |
|
|
215 |
public Object getWindowModel() { |
|
216 |
return projectDocument; |
|
217 |
} |
|
218 |
|
|
219 |
/** |
|
220 |
* |
|
221 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo() |
|
222 |
* @return WindowInfo: window parameters |
|
223 |
*/ |
|
224 |
public WindowInfo getWindowInfo() { |
|
225 |
WindowInfo m_viewinfo = new WindowInfo(); |
|
226 |
m_viewinfo.setTitle("Animation Properties"); |
|
227 |
m_viewinfo.setHeight(height); |
|
228 |
m_viewinfo.setWidth(width); |
|
229 |
return m_viewinfo; |
|
230 |
} |
|
231 |
|
|
232 |
public Object getWindowProfile() { |
|
233 |
return WindowInfo.TOOL_PROFILE; |
|
234 |
} |
|
235 |
|
|
236 |
public boolean isEditable() { |
|
237 |
return editable; |
|
238 |
} |
|
239 |
|
|
240 |
public void setEditable(boolean editable) { |
|
241 |
this.editable = editable; |
|
242 |
} |
|
243 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_11/extensions/extAnimationGUI/src/com/iver/ai2/animationgui/gui/document/ExtensionPoint3D.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
Also available in: Unified diff