svn-gvsig-desktop / import / ext3D / branches / ext3D_v1.1 / libAnimation / src / com / iver / cit / gvsig / animation / AnimationContainer.java @ 15414
History | View | Annotate | Download (4.69 KB)
1 |
package com.iver.cit.gvsig.animation; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.List; |
5 |
|
6 |
import com.iver.cit.gvsig.animation.traks.AnimationDatedTrack; |
7 |
import com.iver.cit.gvsig.animation.traks.AnimationTimeTrack; |
8 |
import com.iver.cit.gvsig.animation.traks.IAnimationTrack; |
9 |
import com.iver.utiles.IPersistance; |
10 |
import com.iver.utiles.XMLEntity; |
11 |
|
12 |
public class AnimationContainer implements IPersistance{ |
13 |
|
14 |
// IAnimationTrakc List
|
15 |
public List AnimationTrackList; |
16 |
|
17 |
private static AnimationPlayer animationPlayer = new AnimationPlayer(); |
18 |
|
19 |
public AnimationContainer() {
|
20 |
List aniTrackList = this.getAnimationTrackList(); |
21 |
aniTrackList = new ArrayList(); |
22 |
this.setAnimationTrackList(aniTrackList);
|
23 |
} |
24 |
|
25 |
/**
|
26 |
* @param animationType
|
27 |
* @return
|
28 |
*/
|
29 |
public List getTackListOfType(IAnimationType animationType) { |
30 |
List typeList = new ArrayList(); |
31 |
for (int i = 0; i < this.AnimationTrackList.size(); i++) { |
32 |
IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList
|
33 |
.get(i); |
34 |
if (animationType.getClassName().equals(
|
35 |
trackElement.getAnimationType().getClassName())) { |
36 |
typeList.add(trackElement); |
37 |
} |
38 |
|
39 |
} |
40 |
return typeList;
|
41 |
} |
42 |
|
43 |
/**
|
44 |
* @param animationType
|
45 |
* @return
|
46 |
*/
|
47 |
public IAnimationTrack CreateDatedTrack(IAnimationType animationType) {
|
48 |
|
49 |
List aniTrackList = this.getAnimationTrackList(); |
50 |
if (aniTrackList == null) { |
51 |
aniTrackList = new ArrayList(); |
52 |
} |
53 |
AnimationDatedTrack ADTrack = new AnimationDatedTrack(animationType);
|
54 |
aniTrackList.add(ADTrack); |
55 |
this.setAnimationTrackList(aniTrackList);
|
56 |
return ADTrack;
|
57 |
} |
58 |
|
59 |
public IAnimationTrack CreateTimeTrack(IAnimationType animationType) {
|
60 |
|
61 |
List aniTrackList = this.getAnimationTrackList(); |
62 |
if (aniTrackList == null) { |
63 |
aniTrackList = new ArrayList(); |
64 |
} |
65 |
AnimationTimeTrack ADTrack = new AnimationTimeTrack(animationType);
|
66 |
aniTrackList.add(ADTrack); |
67 |
this.setAnimationTrackList(aniTrackList);
|
68 |
return ADTrack;
|
69 |
} |
70 |
|
71 |
/**
|
72 |
* @param animationTrack
|
73 |
*/
|
74 |
public void addTrack(IAnimationTrack animationTrack) { |
75 |
IAnimationTrack track = findTrack(animationTrack.getName()); |
76 |
if (track == null) { |
77 |
this.AnimationTrackList.add(animationTrack);
|
78 |
} |
79 |
} |
80 |
|
81 |
/**
|
82 |
* @param name
|
83 |
* @return
|
84 |
*/
|
85 |
public IAnimationTrack findTrack(String name) { |
86 |
|
87 |
IAnimationTrack IAT = null;
|
88 |
for (int i = 0; i < this.AnimationTrackList.size(); i++) { |
89 |
IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList
|
90 |
.get(i); |
91 |
if (trackElement.getName().equals(name)) {
|
92 |
IAT = trackElement; |
93 |
} |
94 |
|
95 |
} |
96 |
return IAT;
|
97 |
} |
98 |
|
99 |
/**
|
100 |
* @param animationTrack
|
101 |
*/
|
102 |
public void removeTrack(IAnimationTrack animationTrack) { |
103 |
animationTrack.removeAllIntervals(); |
104 |
this.AnimationTrackList.remove(animationTrack);
|
105 |
} |
106 |
|
107 |
/**
|
108 |
*
|
109 |
*/
|
110 |
public void removeAllTrack() { |
111 |
this.AnimationTrackList.clear();
|
112 |
} |
113 |
|
114 |
/**
|
115 |
* @return
|
116 |
*/
|
117 |
public List getAnimationTrackList() { |
118 |
return AnimationTrackList;
|
119 |
} |
120 |
|
121 |
/**
|
122 |
* @param animationTrackList
|
123 |
*/
|
124 |
public void setAnimationTrackList(List animationTrackList) { |
125 |
AnimationTrackList = animationTrackList; |
126 |
} |
127 |
|
128 |
/*
|
129 |
* IPersistance methods.
|
130 |
*/
|
131 |
|
132 |
public String getClassName() { |
133 |
// TODO Auto-generated method stub
|
134 |
return this.getClass().getName(); |
135 |
} |
136 |
|
137 |
/**
|
138 |
* @return
|
139 |
*/
|
140 |
public XMLEntity getXMLEntity() {
|
141 |
XMLEntity xml = new XMLEntity();
|
142 |
xml.putProperty("className", this.getClassName()); |
143 |
for (int i = 0; i < this.AnimationTrackList.size(); i++) { |
144 |
IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList.get(i);
|
145 |
trackElement.getXMLEntity(); |
146 |
} |
147 |
return xml;
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* @param xml
|
152 |
*/
|
153 |
public void setXMLEntity(XMLEntity xml) { |
154 |
|
155 |
for (int i = 0; i < this.AnimationTrackList.size(); i++) { |
156 |
IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList.get(i);
|
157 |
trackElement.setXMLEntity(xml); |
158 |
} |
159 |
} |
160 |
|
161 |
public String toString() { |
162 |
String result = ""; |
163 |
List ATL = this.AnimationTrackList; |
164 |
result += "Mostrando lista de tracks:";
|
165 |
if ((ATL == null) || ATL.isEmpty()) { |
166 |
result += "\nLista vacia";
|
167 |
} else {
|
168 |
for (int i = 0; i < ATL.size(); i++) { |
169 |
Object element = ATL.get(i);
|
170 |
result += "\n" + element;
|
171 |
} |
172 |
} |
173 |
return result;
|
174 |
|
175 |
} |
176 |
|
177 |
public void apply(double Tini, double Tend) { |
178 |
List ATL = this.AnimationTrackList; |
179 |
System.out.println("Tiempo de inicio: " + Tini + " tiempo final " |
180 |
+ Tend); |
181 |
if ((ATL != null) && !ATL.isEmpty()) { |
182 |
for (int i = 0; i < ATL.size(); i++) { |
183 |
IAnimationTrack element = (IAnimationTrack) ATL.get(i); |
184 |
element.apply(Tini, Tend); |
185 |
} |
186 |
} |
187 |
} |
188 |
|
189 |
public AnimationPlayer getAnimationPlayer() {
|
190 |
return this.animationPlayer; |
191 |
} |
192 |
} |