Statistics
| Revision:

root / import / ext3D / branches / ext3D_v1.1 / libAnimation / src / com / iver / cit / gvsig / animation / traks / AnimationTimeTrack.java @ 15445

History | View | Annotate | Download (5.53 KB)

1
package com.iver.cit.gvsig.animation.traks;
2

    
3
import java.util.ArrayList;
4
import java.util.Iterator;
5
import java.util.List;
6
import com.iver.cit.gvsig.animation.IAnimationType;
7
import com.iver.cit.gvsig.animation.interval.AnimationFunctionInterval;
8
import com.iver.cit.gvsig.animation.interval.AnimationKeyFrameInterval;
9
import com.iver.cit.gvsig.animation.interval.IAnimationInterval;
10
import com.iver.cit.gvsig.animation.interval.IAnimationTimeInterval;
11
import com.iver.utiles.XMLEntity;
12

    
13
public class AnimationTimeTrack implements IAnimationTrack {
14

    
15
        private IAnimationType animationType;
16

    
17
        private String Name;
18

    
19
        private String Description;
20

    
21
        private double beginTime;
22

    
23
        private double endTime;
24

    
25
        private List animationTimeIntervalList;
26

    
27
        private boolean enable;
28

    
29
        private Object animatedObject;
30

    
31
        private String className ;
32

    
33
        public AnimationTimeTrack(IAnimationType animationType) {
34
                this.animationTimeIntervalList = new ArrayList();
35
                this.animationType = animationType;
36
        }
37

    
38
        public Object getAnimatedObject() {
39
                return this.animatedObject;
40
        }
41

    
42

    
43
        public String getDescription() {
44
                return this.Description;
45
        }
46

    
47
        public List getIntervalList() {
48
                return animationTimeIntervalList;
49
        }
50

    
51
        public String getName() {
52
                return this.Name;
53
        }
54

    
55

    
56
        public void setAnimatedObject(Object animatedObject) {
57
                this.animatedObject = animatedObject;
58
        }
59

    
60

    
61
        public void setIntervalList(List intervalList) {
62
                animationTimeIntervalList = intervalList;
63
        }
64

    
65

    
66
        public double getBeginTime() {
67
                return beginTime;
68
        }
69

    
70
        public void setBeginTime(double beginTime) {
71
                this.beginTime = beginTime;
72
        }
73

    
74
        public double getendTime() {
75
                return endTime;
76
        }
77

    
78
        public void setendTime(double endTime) {
79
                this.endTime = endTime;
80
        }
81

    
82
        public IAnimationType getAnimationType() {
83
                return this.animationType;
84
        }
85

    
86
        public boolean isEnable() {
87
                return this.enable;
88
        }
89

    
90
        public void setEnabale(boolean enable) {
91
                this.enable = enable;
92
        }
93

    
94
        public IAnimationInterval createKeyFrameInterval() {
95
                List ATIList = this.getIntervalList();
96
                if (ATIList == null) {
97
                        ATIList = new ArrayList();
98
                }
99
                AnimationKeyFrameInterval ATInterval = new AnimationKeyFrameInterval();
100
                ATIList.add(ATInterval);
101
                return ATInterval;
102
        }
103
        public IAnimationInterval createFunctionInterval() {
104
                List ATIList = this.getIntervalList();
105
                if (ATIList == null) {
106
                        ATIList = new ArrayList();
107
                }
108
                AnimationFunctionInterval AFInterval = new AnimationFunctionInterval();
109
                ATIList.add(AFInterval);
110
                return AFInterval;
111
        }
112

    
113
        public void removeAllIntervals() {
114
                this.animationTimeIntervalList.clear();
115
        }
116

    
117
        public void removeInterval(IAnimationInterval animationInterval) {
118
                this.animationTimeIntervalList.remove(animationInterval);
119
        }
120

    
121
        public void setAnimationType(IAnimationType animationType) {
122
                this.animationType = animationType;
123
        }
124

    
125
        public void setDescription(String description) {
126
                Description = description;
127
        }
128

    
129
        public void setName(String name) {
130
                this.Name = name;
131
        }
132
        
133
        public String toString() {
134

    
135
                String result;
136
                List ATIL = this.animationTimeIntervalList;
137
                result = "Mostrando lista de Intervalos de la track " + this.getName()
138
                                + ":" + this.getDescription();
139
                result += "\n**********************************************";
140
                result += "\nTipo de objetos que contiene "
141
                                + this.getAnimationType().getClassName();
142
                result += "\nNombre: " + this.getAnimationType().getName();
143
                result += "\nDescripcion: " + this.getAnimationType().getName();
144
                result += "\n**********************************************";
145
                for (Iterator iter = ATIL.iterator(); iter.hasNext();) {
146
                        Object element = (Object) iter.next();
147
                        result += "\n" + element;
148
                }
149
                return result;
150
        }
151
        
152
        public void apply(double Tini, double Tend) {
153
                List ATTL = this.animationTimeIntervalList;
154
                if ((ATTL != null) && (!ATTL.isEmpty())) {
155
                        for (int i = 0; i < ATTL.size(); i++) {
156
                                IAnimationInterval element = (IAnimationInterval) ATTL.get(i);
157
                                element.apply(Tini, Tend, this.getAnimationType(), this
158
                                                .getAnimatedObject());
159
                        }
160
                }
161
                
162
        }
163
        
164

    
165
        /*
166
         * IPersistance methods 
167
         * 
168
         */
169
        
170
        public String getClassName() {
171
                // TODO Auto-generated method stub
172
                return this.getClass().getName();
173
        }        
174
        
175
        public XMLEntity getXMLEntity() {
176
                // TODO Auto-generated method stub
177
                
178
                
179
                XMLEntity xml = new XMLEntity();
180
                xml.putProperty("class_name", this.getClassName());
181
                xml.putProperty("name", Name);
182
                xml.putProperty("description",Description );
183
                xml.putProperty("begin_time", beginTime);
184
                xml.putProperty("end_time", endTime);
185
                
186
//                for (int i = 0; i < this.animationTimeIntervalList.size(); i++) {
187
//                        IAnimationTimeInterval timeInterval = (IAnimationTimeInterval) this.animationTimeIntervalList.get(i);                        
188
//                        timeInterval.getXMLEntity();        
189
//                }                
190
                return xml;
191
        }
192
        
193
        public void setXMLEntity(XMLEntity xml) {
194
                // TODO Auto-generated method stub
195
                if (xml.contains("class_name"))
196
                        className =        xml.getStringProperty("class_name");
197
                if (xml.contains("name"))
198
                        Name =        xml.getStringProperty("name");
199
                if (xml.contains("description"))
200
                        Description = xml.getStringProperty("description");
201
                if (xml.contains("begin_time"))
202
                        beginTime = xml.getDoubleProperty("begin_time");
203
                if (xml.contains("end_time"))
204
                        endTime = xml.getDoubleProperty("end_time");
205
                
206
//                
207
//                for (int i = 0; i < this.animationTimeIntervalList.size(); i++) {
208
//                        IAnimationTimeInterval timeInterval = (IAnimationTimeInterval) this.animationTimeIntervalList.get(i);                        
209
//                        timeInterval.setXMLEntity(xml);        
210
//                }                
211
                
212
        }
213
        
214
}