svn-gvsig-desktop / trunk / libraries / libAnimation2D / src / main / java / com / iver / cit / gvsig / animation / animationType / AnimationLayer2D.java @ 23224
History | View | Annotate | Download (5.16 KB)
1 |
package com.iver.cit.gvsig.animation.animationType; |
---|---|
2 |
|
3 |
import com.iver.andami.PluginServices; |
4 |
import com.iver.andami.ui.mdiManager.IWindow; |
5 |
import com.iver.cit.gvsig.animation.IAnimationType; |
6 |
import com.iver.cit.gvsig.animation.animatedObject.AnimationObject2D; |
7 |
import com.iver.cit.gvsig.animation.interpolator.Interpolator2D; |
8 |
import com.iver.cit.gvsig.animation.keyFrame.KeyFrame2D; |
9 |
import com.iver.cit.gvsig.animation.keyframe.IAnimationTypeKeyFrame; |
10 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.FuntionFactory; |
11 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
12 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolatorTimeFuntion; |
13 |
import com.iver.cit.gvsig.project.ProjectExtent; |
14 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
15 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
16 |
import com.iver.utiles.IPersistence; |
17 |
import com.iver.utiles.XMLEntity; |
18 |
|
19 |
public class AnimationLayer2D implements IAnimationTypeKeyFrame { |
20 |
|
21 |
private String className = "AnimationLayer2D"; |
22 |
private String description = "Animacion para zoom de capas"; |
23 |
private String name = "Animacion de zoom capas"; |
24 |
private int typeTrack = IAnimationType.TIME_TYPE_TRACK; |
25 |
private IInterpolator interpolator;
|
26 |
private View view; |
27 |
private AnimationObject2D animationObject2D = new AnimationObject2D() ; |
28 |
private String titleWindow; |
29 |
//private String nameClassView;
|
30 |
|
31 |
public AnimationLayer2D() {
|
32 |
this.interpolator = new Interpolator2D(); |
33 |
} |
34 |
|
35 |
public String getClassName() { |
36 |
return className;
|
37 |
} |
38 |
|
39 |
public String getDescription() { |
40 |
return description;
|
41 |
} |
42 |
|
43 |
public String getName() { |
44 |
return name;
|
45 |
} |
46 |
|
47 |
public void setClassName(String className) { |
48 |
this.className = className;
|
49 |
} |
50 |
|
51 |
public void setDescription(String description) { |
52 |
this.description = description;
|
53 |
} |
54 |
|
55 |
public void setName(String name) { |
56 |
this.name = name;
|
57 |
} |
58 |
|
59 |
public void AppliesToObject(Object animated) { |
60 |
|
61 |
// Casting the animated object
|
62 |
KeyFrame2D keyFrame2D = (KeyFrame2D) animated; |
63 |
// Applies to object
|
64 |
//this.view = (View) animationObject2D.getAnimatedObject("view2D");
|
65 |
this.view = (View) this.animationObject2D.getAnimatedView(); |
66 |
this.view.getMapControl().getViewPort().setExtent(
|
67 |
((ProjectExtent) keyFrame2D.getAnimatedObject()).getExtent()); |
68 |
// Repainting the object
|
69 |
this.view.getMapControl().drawMap(true); |
70 |
//this.view.repaintMap();
|
71 |
} |
72 |
|
73 |
public int getTypeTrack() { |
74 |
return typeTrack;
|
75 |
} |
76 |
|
77 |
public void setTypeTrack(int typeTrack) { |
78 |
this.typeTrack = typeTrack;
|
79 |
|
80 |
} |
81 |
|
82 |
public IInterpolator getInterpolator() {
|
83 |
return this.interpolator; |
84 |
} |
85 |
|
86 |
public void setInterpolator(IInterpolator interpolator) { |
87 |
this.interpolator = interpolator;
|
88 |
|
89 |
} |
90 |
|
91 |
|
92 |
public Object getAnimatedObject() { |
93 |
if(this.animationObject2D != null) { |
94 |
// getting all views.
|
95 |
try{
|
96 |
IWindow[] viewArray = PluginServices.getMDIManager().getAllWindows();
|
97 |
for (int i = 0; i < viewArray.length; i++) { |
98 |
IWindow window = viewArray[i]; |
99 |
if(window.getWindowInfo().getTitle().equals(this.titleWindow)){ |
100 |
BaseView newView = (BaseView)window; |
101 |
this.animationObject2D.setAnimatedView(newView);
|
102 |
this.setAnimatedObject(this.animationObject2D); |
103 |
IInterpolatorTimeFuntion funtion = FuntionFactory.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion");
|
104 |
this.interpolator.setFuntion(funtion);
|
105 |
} |
106 |
} |
107 |
}catch(Exception e) { |
108 |
e.printStackTrace(); |
109 |
} |
110 |
} |
111 |
return this.animationObject2D; |
112 |
} |
113 |
|
114 |
|
115 |
public void setAnimatedObject(Object object) { |
116 |
if (object instanceof AnimationObject2D) |
117 |
this.animationObject2D = (AnimationObject2D) object;
|
118 |
|
119 |
} |
120 |
public XMLEntity getXMLEntity() {
|
121 |
|
122 |
View myActualView = null; |
123 |
|
124 |
XMLEntity xml = new XMLEntity();
|
125 |
xml.putProperty("className", this.getClassName()); |
126 |
xml.putProperty("description", description);
|
127 |
xml.putProperty("animationTrackTipe", typeTrack);
|
128 |
// xml.putProperty("nameClassView", animationObject2D.getNameClassView());
|
129 |
myActualView = (View) animationObject2D.getAnimatedView();
|
130 |
titleWindow = myActualView.getWindowInfo().getTitle(); |
131 |
xml.putProperty("titleWindow", titleWindow);
|
132 |
xml.addChild(((IPersistence)this.interpolator).getXMLEntity());
|
133 |
return xml;
|
134 |
} |
135 |
|
136 |
public void setXMLEntity(XMLEntity xml) { |
137 |
if (xml.contains("className")) |
138 |
this.className= xml.getStringProperty("className"); |
139 |
if (xml.contains("animationTrackTipe")) |
140 |
this.typeTrack = xml.getIntProperty("animationTrackTipe"); |
141 |
// if (xml.contains("nameClassView"))
|
142 |
// this.nameClassView = xml.getStringProperty("nameClassView");
|
143 |
if (xml.contains("titleWindow")) |
144 |
this.titleWindow = xml.getStringProperty("titleWindow"); |
145 |
|
146 |
XMLEntity xmlInterpolator = xml.getChild(0);
|
147 |
|
148 |
try {
|
149 |
String class_name = xmlInterpolator.getStringProperty("className"); |
150 |
Class classInterpolator = Class.forName(class_name); |
151 |
Object obj = classInterpolator .newInstance();
|
152 |
IPersistence objPersist = (IPersistence) obj; |
153 |
objPersist.setXMLEntity(xmlInterpolator); |
154 |
this.interpolator = (IInterpolator) obj;
|
155 |
this.setInterpolator(interpolator);
|
156 |
|
157 |
} catch (Exception e) { |
158 |
e.printStackTrace(); |
159 |
} |
160 |
} |
161 |
|
162 |
} |