svn-gvsig-desktop / trunk / libraries / libAnimationCommon / src / main / java / com / iver / cit / gvsig / animation / animationType / AnimationTransparency.java @ 20153
History | View | Annotate | Download (4.61 KB)
1 |
package com.iver.cit.gvsig.animation.animationType; |
---|---|
2 |
|
3 |
import com.iver.cit.gvsig.animation.IAnimationType; |
4 |
import com.iver.cit.gvsig.animation.animatedObject.AnimationObjectTransparency; |
5 |
import com.iver.cit.gvsig.animation.keyFrame.KeyFrameTransparency; |
6 |
import com.iver.cit.gvsig.animation.keyframe.IAnimationTypeKeyFrame; |
7 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
8 |
import com.iver.cit.gvsig.fmap.layers.FLyrDefault; |
9 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
10 |
import com.iver.utiles.IPersistence; |
11 |
import com.iver.utiles.XMLEntity; |
12 |
|
13 |
|
14 |
public class AnimationTransparency implements IAnimationTypeKeyFrame { |
15 |
|
16 |
private String className;// = this.getClass().getName(); |
17 |
private String description = "Animacion basada en Transparencias"; |
18 |
private String name = "AnimationTransparency"; |
19 |
private int typeTrack = IAnimationType.TIME_TYPE_TRACK; |
20 |
private IInterpolator interpolator;
|
21 |
private BaseView view;
|
22 |
private AnimationObjectTransparency animationObjectTransparency;
|
23 |
|
24 |
public AnimationTransparency() {
|
25 |
} |
26 |
|
27 |
public String getClassName() { |
28 |
return this.getClass().getName(); |
29 |
} |
30 |
|
31 |
public String getDescription() { |
32 |
return description;
|
33 |
} |
34 |
|
35 |
public String getName() { |
36 |
return name;
|
37 |
} |
38 |
|
39 |
public void setClassName(String className) { |
40 |
this.className = className;
|
41 |
} |
42 |
|
43 |
public void setDescription(String description) { |
44 |
this.description = description;
|
45 |
} |
46 |
|
47 |
public void setName(String name) { |
48 |
this.name = name;
|
49 |
} |
50 |
|
51 |
/**
|
52 |
*
|
53 |
* @param animate : Object to animate.
|
54 |
* Application of attributes to our object animated.
|
55 |
* In this animation the object is a layer(FLyerDefault).
|
56 |
* Attributes: layer transparency.
|
57 |
* invalidate(): repaint the view.
|
58 |
*/
|
59 |
|
60 |
public void AppliesToObject(Object animated) { |
61 |
|
62 |
KeyFrameTransparency kf = (KeyFrameTransparency) animated; |
63 |
FLyrDefault layer = (FLyrDefault)kf.getAnimatedObject(); |
64 |
int trans = (int)kf.getLevelTransparency(); |
65 |
|
66 |
// System.err.println("antes: " + System.currentTimeMillis());
|
67 |
// long antes = System.currentTimeMillis();
|
68 |
|
69 |
layer.setTransparency(trans); |
70 |
layer.setDirty(true);
|
71 |
//((ViewPort3D)layer.getMapContext().getViewPort()).setDirty(true);
|
72 |
layer.getMapContext().invalidate(); |
73 |
|
74 |
// System.err.println("despues: " + System.currentTimeMillis());
|
75 |
// long despues = System.currentTimeMillis();
|
76 |
// System.err.println("intervalo de tiempo: " + (despues-antes));
|
77 |
|
78 |
System.err.println("aplicando transparencia " + trans + " al objeto " + layer.getName()); |
79 |
} |
80 |
|
81 |
public int getTypeTrack() { |
82 |
return typeTrack;
|
83 |
} |
84 |
|
85 |
public void setTypeTrack(int typeTrack) { |
86 |
this.typeTrack = typeTrack;
|
87 |
} |
88 |
|
89 |
public IInterpolator getInterpolator() {
|
90 |
return this.interpolator; |
91 |
} |
92 |
|
93 |
public void setInterpolator(IInterpolator interpolator) { |
94 |
this.interpolator = interpolator;
|
95 |
} |
96 |
|
97 |
public Object getAnimatedObject() { |
98 |
// TODO Auto-generated method stub
|
99 |
return this.animationObjectTransparency; |
100 |
} |
101 |
|
102 |
public void setAnimatedObject(Object object) { |
103 |
//this.view = (BaseView) object;
|
104 |
this.animationObjectTransparency = (AnimationObjectTransparency) object;
|
105 |
} |
106 |
|
107 |
/*
|
108 |
* IPersistence methods.
|
109 |
*/
|
110 |
|
111 |
public XMLEntity getXMLEntity() {
|
112 |
|
113 |
XMLEntity xml = new XMLEntity();
|
114 |
xml.putProperty("className", this.getClassName()); |
115 |
xml.putProperty("description", description);
|
116 |
xml.putProperty("animationTrackTipe", typeTrack);
|
117 |
xml.putProperty("nameView", animationObjectTransparency.getNameView());
|
118 |
xml.putProperty("nameLayer", animationObjectTransparency.getNameLayer());
|
119 |
|
120 |
xml.addChild(((IPersistence)this.interpolator).getXMLEntity());
|
121 |
return xml;
|
122 |
} |
123 |
|
124 |
public void setXMLEntity(XMLEntity xml) { |
125 |
|
126 |
String nameView, nameLayer;
|
127 |
|
128 |
if (xml.contains("className")) |
129 |
this.className= xml.getStringProperty("className"); |
130 |
if (xml.contains("animationTrackTipe")) |
131 |
this.typeTrack = xml.getIntProperty("animationTrackTipe"); |
132 |
if (xml.contains("nameView")) |
133 |
nameView = xml.getStringProperty("nameView");
|
134 |
if (xml.contains("nameLayer")) |
135 |
nameLayer = xml.getStringProperty("nameLayer");
|
136 |
|
137 |
//Acceding to the InterpolatorX of the AnimationTypeX
|
138 |
XMLEntity xmlInterpolator = xml.getChild(0);
|
139 |
try {
|
140 |
String class_name = xmlInterpolator.getStringProperty("className"); |
141 |
Class classInterpolator = Class.forName(class_name); |
142 |
Object obj = classInterpolator .newInstance();
|
143 |
IPersistence objPersist = (IPersistence) obj; |
144 |
objPersist.setXMLEntity(xmlInterpolator); |
145 |
this.interpolator = (IInterpolator) obj;
|
146 |
this.setInterpolator(interpolator);
|
147 |
//this.setAnimatedObject();
|
148 |
|
149 |
} catch (Exception e) { |
150 |
e.printStackTrace(); |
151 |
} |
152 |
|
153 |
} |
154 |
} |