root / trunk / libraries / libAnimationCommon / src / main / java / com / iver / cit / gvsig / animation / animationType / AnimationTransparency.java @ 22808
History | View | Annotate | Download (6.26 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.AnimationObjectTransparency; |
7 |
import com.iver.cit.gvsig.animation.animatedObject.IAnimatedObject; |
8 |
import com.iver.cit.gvsig.animation.keyFrame.KeyFrameTransparency; |
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.fmap.layers.FLyrDefault; |
14 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
15 |
import com.iver.utiles.IPersistence; |
16 |
import com.iver.utiles.XMLEntity; |
17 |
|
18 |
|
19 |
public class AnimationTransparency implements IAnimationTypeKeyFrame { |
20 |
|
21 |
private String className;// = this.getClass().getName(); |
22 |
private String description = "Animacion basada en Transparencias"; |
23 |
private String name = "AnimationTransparency"; |
24 |
private int typeTrack = IAnimationType.TIME_TYPE_TRACK; |
25 |
private IInterpolator interpolator;
|
26 |
private BaseView view;
|
27 |
String nameView;
|
28 |
//private AnimationObjectTransparency animationObjectTransparency;
|
29 |
private IAnimatedObject animationObjectTransparency = new AnimationObjectTransparency() ; |
30 |
private String titleWindow; |
31 |
|
32 |
public AnimationTransparency() {
|
33 |
} |
34 |
|
35 |
public String getClassName() { |
36 |
return this.getClass().getName(); |
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 |
/**
|
60 |
*
|
61 |
* @param animate : Object to animate.
|
62 |
* Application of attributes to our object animated.
|
63 |
* In this animation the object is a layer(FLyerDefault).
|
64 |
* Attributes: layer transparency.
|
65 |
* invalidate(): repaint the view.
|
66 |
*/
|
67 |
|
68 |
public void AppliesToObject(Object animated) { |
69 |
|
70 |
KeyFrameTransparency kf = (KeyFrameTransparency) animated; |
71 |
FLyrDefault layer = (FLyrDefault)kf.getAnimatedObject(); |
72 |
int trans = (int)kf.getLevelTransparency(); |
73 |
|
74 |
// System.err.println("antes: " + System.currentTimeMillis());
|
75 |
// long antes = System.currentTimeMillis();
|
76 |
|
77 |
layer.setTransparency(trans); |
78 |
layer.setDirty(true);
|
79 |
layer.getMapContext().invalidate(); |
80 |
|
81 |
// System.err.println("despues: " + System.currentTimeMillis());
|
82 |
// long despues = System.currentTimeMillis();
|
83 |
// System.err.println("intervalo de tiempo: " + (despues-antes));
|
84 |
|
85 |
System.err.println("aplicando transparencia " + trans + " al objeto " + layer.getName()); |
86 |
} |
87 |
|
88 |
public int getTypeTrack() { |
89 |
return typeTrack;
|
90 |
} |
91 |
|
92 |
public void setTypeTrack(int typeTrack) { |
93 |
this.typeTrack = typeTrack;
|
94 |
} |
95 |
|
96 |
public IInterpolator getInterpolator() {
|
97 |
return this.interpolator; |
98 |
} |
99 |
|
100 |
public void setInterpolator(IInterpolator interpolator) { |
101 |
this.interpolator = interpolator;
|
102 |
} |
103 |
|
104 |
public Object getAnimatedObject() { |
105 |
if(this.animationObjectTransparency != null){ |
106 |
// getting all views.
|
107 |
try{
|
108 |
IWindow[] viewArray = PluginServices.getMDIManager().getAllWindows();
|
109 |
for (int i = 0; i < viewArray.length; i++) { |
110 |
IWindow window = viewArray[i]; |
111 |
if (window.getClass().getName().equals(this.nameView)){ |
112 |
// get the actual name of the view, and compare it with the view saved in xml.
|
113 |
if(window.getWindowInfo().getTitle().equals(this.titleWindow)){ |
114 |
BaseView newView = (BaseView)window; |
115 |
this.animationObjectTransparency.addAnimatedObject("view", newView); |
116 |
// this.animationObject3DFlat.setAnimatedView(newView);
|
117 |
this.setAnimatedObject(this.animationObjectTransparency); |
118 |
IInterpolatorTimeFuntion funtion = FuntionFactory.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion");
|
119 |
this.interpolator.setFuntion(funtion);
|
120 |
} |
121 |
} |
122 |
} |
123 |
}catch(Exception e) { |
124 |
e.printStackTrace(); |
125 |
} |
126 |
} |
127 |
return this.animationObjectTransparency; |
128 |
} |
129 |
|
130 |
public void setAnimatedObject(Object object) { |
131 |
//this.animationObjectTransparency = (AnimationObjectTransparency) object;
|
132 |
this.animationObjectTransparency = (IAnimatedObject) object;
|
133 |
} |
134 |
|
135 |
/*
|
136 |
* IPersistence methods.
|
137 |
*/
|
138 |
|
139 |
public XMLEntity getXMLEntity() {
|
140 |
|
141 |
//View3D myActualView = null;
|
142 |
|
143 |
XMLEntity xml = new XMLEntity();
|
144 |
xml.putProperty("className", this.getClassName()); |
145 |
xml.putProperty("description", description);
|
146 |
xml.putProperty("animationTrackTipe", typeTrack);
|
147 |
//xml.putProperty("nameClassView", animationObjectTransparency.getNameView());
|
148 |
//myActualView = (View3D) animationObjectTransparency.getAnimatedView();
|
149 |
|
150 |
BaseView myActualView = (BaseView) animationObjectTransparency.getAnimatedObject("view");
|
151 |
xml.putProperty("nameClassView", myActualView.getClass().getName());
|
152 |
|
153 |
|
154 |
|
155 |
titleWindow = myActualView.getWindowInfo().getTitle(); |
156 |
xml.putProperty("titleWindow", titleWindow);
|
157 |
xml.addChild(((IPersistence)this.interpolator).getXMLEntity());
|
158 |
return xml;
|
159 |
} |
160 |
|
161 |
public void setXMLEntity(XMLEntity xml) { |
162 |
|
163 |
String nameLayer;
|
164 |
|
165 |
if (xml.contains("className")) |
166 |
this.className= xml.getStringProperty("className"); |
167 |
if (xml.contains("animationTrackTipe")) |
168 |
this.typeTrack = xml.getIntProperty("animationTrackTipe"); |
169 |
if (xml.contains("nameView")) |
170 |
this.nameView = xml.getStringProperty("nameView"); |
171 |
if (xml.contains("nameLayer")) |
172 |
nameLayer = xml.getStringProperty("nameLayer");
|
173 |
|
174 |
//Acceding to the InterpolatorX of the AnimationTypeX
|
175 |
XMLEntity xmlInterpolator = xml.getChild(0);
|
176 |
try {
|
177 |
String class_name = xmlInterpolator.getStringProperty("className"); |
178 |
Class classInterpolator = Class.forName(class_name); |
179 |
Object obj = classInterpolator .newInstance();
|
180 |
IPersistence objPersist = (IPersistence) obj; |
181 |
objPersist.setXMLEntity(xmlInterpolator); |
182 |
this.interpolator = (IInterpolator) obj;
|
183 |
this.setInterpolator(interpolator);
|
184 |
//this.setAnimatedObject();
|
185 |
|
186 |
} catch (Exception e) { |
187 |
e.printStackTrace(); |
188 |
} |
189 |
|
190 |
} |
191 |
} |