Revision 15416 import/ext3D/branches/ext3D_v1.1/libAnimation/src/com/iver/cit/gvsig/animation/interval/AnimationKeyFrameInterval.java
AnimationKeyFrameInterval.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.animation.interval; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
3 | 4 |
import java.util.Iterator; |
4 | 5 |
import java.util.List; |
5 | 6 |
|
6 | 7 |
import com.iver.cit.gvsig.animation.IAnimationType; |
8 |
import com.iver.cit.gvsig.animation.keyframe.IAnimationTypeKeyFrame; |
|
9 |
import com.iver.cit.gvsig.animation.keyframe.IInterpolator; |
|
7 | 10 |
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame; |
11 |
import com.iver.cit.gvsig.animation.test.Interpolator2D; |
|
12 |
import com.iver.cit.gvsig.animation.test.KeyFrame2D; |
|
13 |
import com.iver.cit.gvsig.project.ProjectExtent; |
|
14 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
|
8 | 15 |
import com.iver.utiles.XMLEntity; |
9 | 16 |
|
10 | 17 |
public class AnimationKeyFrameInterval implements IAnimationTimeInterval { |
... | ... | |
54 | 61 |
|
55 | 62 |
String result; |
56 | 63 |
List KFL = this.KeyFrameList; |
57 |
if (KFL !=null) { |
|
64 |
if (KFL != null) {
|
|
58 | 65 |
result = "Mostrando lista de KeyFrames del intervalo Tini:" |
59 |
+ this.getInitialTime() + " Tend" + this.getEndTime(); |
|
66 |
+ this.getInitialTime() + " Tend" + this.getEndTime();
|
|
60 | 67 |
for (Iterator iter = KFL.iterator(); iter.hasNext();) { |
61 | 68 |
Object element = (Object) iter.next(); |
62 | 69 |
result += "\n" + element; |
... | ... | |
67 | 74 |
return result; |
68 | 75 |
} |
69 | 76 |
|
70 |
public void apply(double tini, double tend, IAnimationType animationType, Object animated) { |
|
71 |
// TODO Auto-generated method stub |
|
77 |
public void apply(double tini, double tend, IAnimationType animationType, |
|
78 |
Object animated) { |
|
79 |
|
|
80 |
IAnimationTypeKeyFrame animationTypeFrame = (IAnimationTypeKeyFrame) animationType; |
|
81 |
IInterpolator interpolator = animationTypeFrame.getInterpolator(); |
|
82 |
|
|
83 |
IKeyFrame previus = null; |
|
84 |
IKeyFrame next = null; |
|
85 |
List KFLInterpolate = new ArrayList(); |
|
86 |
|
|
87 |
List KFL = this.KeyFrameList; |
|
88 |
if (KFL != null) { |
|
89 |
for (Iterator iter = KFL.iterator(); iter.hasNext();) { |
|
90 |
IKeyFrame element = (IKeyFrame) iter.next(); |
|
91 |
double KFtime = element.getTime(); |
|
92 |
if (KFtime <= tini) { |
|
93 |
if (previus != null) { |
|
94 |
if (KFtime > previus.getTime()) |
|
95 |
previus = element; |
|
96 |
} else { |
|
97 |
previus = element; |
|
98 |
} |
|
99 |
|
|
100 |
|
|
101 |
} |
|
102 |
if (KFtime > tini) { |
|
103 |
if (next != null) { |
|
104 |
if (KFtime < previus.getTime()) |
|
105 |
next = element; |
|
106 |
} else { |
|
107 |
next = element; |
|
108 |
} |
|
109 |
|
|
110 |
} |
|
111 |
|
|
112 |
|
|
113 |
} |
|
114 |
KFLInterpolate.add(previus); |
|
115 |
KFLInterpolate.add(next); |
|
116 |
} |
|
117 |
|
|
118 |
IKeyFrame frame = null; |
|
119 |
if (KFLInterpolate != null) { |
|
120 |
// IInterpolator in = (IInterpolator) interpolator; |
|
121 |
frame = interpolator.interpolate(KFLInterpolate, 0, tini); |
|
122 |
} |
|
123 |
|
|
124 |
animationType.AppliesToObject(frame); |
|
125 |
|
|
126 |
|
|
127 |
|
|
72 | 128 |
} |
73 | 129 |
|
74 |
|
|
75 | 130 |
public XMLEntity getXMLEntity() { |
76 | 131 |
// TODO Auto-generated method stub |
77 | 132 |
XMLEntity xml = new XMLEntity(); |
78 | 133 |
xml.putProperty("className", this.getClassName()); |
79 |
|
|
134 |
|
|
80 | 135 |
xml.putProperty("begin_time", initialTime); |
81 | 136 |
xml.putProperty("end_time", endTime); |
82 | 137 |
xml.putProperty("interval_time", intervalTime); |
83 |
|
|
84 | 138 |
|
85 | 139 |
for (int i = 0; i < this.KeyFrameList.size(); i++) { |
86 |
IKeyFrame keyFrameItem = (IKeyFrame) this.KeyFrameList.get(i);
|
|
87 |
keyFrameItem.getXMLEntity();
|
|
88 |
}
|
|
140 |
IKeyFrame keyFrameItem = (IKeyFrame) this.KeyFrameList.get(i); |
|
141 |
keyFrameItem.getXMLEntity(); |
|
142 |
} |
|
89 | 143 |
return null; |
90 | 144 |
} |
91 | 145 |
|
92 |
|
|
93 | 146 |
public void setXMLEntity(XMLEntity xml) { |
94 | 147 |
// TODO Auto-generated method stub |
95 |
|
|
148 |
|
|
96 | 149 |
if (xml.contains("begin_time")) |
97 | 150 |
initialTime = xml.getDoubleProperty("begin_time"); |
98 | 151 |
if (xml.contains("end_time")) |
... | ... | |
100 | 153 |
if (xml.contains("interval_time")) |
101 | 154 |
intervalTime = xml.getDoubleProperty("interval_time"); |
102 | 155 |
for (int i = 0; i < this.KeyFrameList.size(); i++) { |
103 |
IKeyFrame keyFrameItem = (IKeyFrame) this.KeyFrameList.get(i);
|
|
104 |
keyFrameItem.setXMLEntity(xml);
|
|
156 |
IKeyFrame keyFrameItem = (IKeyFrame) this.KeyFrameList.get(i); |
|
157 |
keyFrameItem.setXMLEntity(xml); |
|
105 | 158 |
} |
106 |
|
|
159 |
|
|
107 | 160 |
} |
108 |
|
|
161 |
|
|
109 | 162 |
public String getClassName() { |
110 | 163 |
// TODO Auto-generated method stub |
111 | 164 |
return this.getClass().getName(); |
Also available in: Unified diff