Statistics
| Revision:

svn-gvsig-desktop / import / ext3D / branches / ext3D_v1.1 / libAnimation / src / com / iver / cit / gvsig / animation / traks / AnimationDatedTrack.java @ 15445

History | View | Annotate | Download (5.48 KB)

1 15349 julio
package com.iver.cit.gvsig.animation.traks;
2
3
import java.sql.Date;
4
import java.util.ArrayList;
5
import java.util.Iterator;
6
import java.util.List;
7
8
import com.iver.cit.gvsig.animation.IAnimationType;
9
import com.iver.cit.gvsig.animation.interval.AnimationDatedInterval;
10
import com.iver.cit.gvsig.animation.interval.IAnimationInterval;
11 15412 afraile
import com.iver.utiles.DateTime;
12 15349 julio
import com.iver.utiles.XMLEntity;
13
14
public class AnimationDatedTrack implements IAnimationTrack {
15
16
        private String Name;
17
18
        private String Description;
19
20
        // List of AnimationDateInterval
21
        private List animationDateIntervalList;
22
23
        private IAnimationType animationType;
24
25
        private Object animatedObject;
26
27
        private boolean enable;
28
29 15412 afraile
        private String beginDateString;
30
31
        private String endDateString;
32
33
        private Date beginDate;
34
35
        private Date endDate;
36
37
        private String sFormat = new String( "Y-m-d" );
38 15445 afraile
39
        private String className;
40 15412 afraile
41
        //private AnimationDatedInterval datedInterval;
42
43 15349 julio
        public AnimationDatedTrack(IAnimationType animationType) {
44
                this.animationDateIntervalList = new ArrayList();
45
                this.animationType = animationType;
46
        }
47
48
        public Date getAnimationIntervalDate() {
49
                return null;
50
        }
51
52
        public Object getAnimatedObject() {
53
                return this.animatedObject;
54
        }
55
56
        public String getDescription() {
57
                return this.Description;
58
        }
59
60
        public List getIntervalList() {
61
                return animationDateIntervalList;
62
        }
63
64
        public String getName() {
65
                return this.Name;
66
        }
67
68
        public void setIntervalList(List intervalList) {
69
                this.animationDateIntervalList = intervalList;
70
71
        }
72
73
        public IAnimationType getAnimationType() {
74
                return this.animationType;
75
        }
76
77
        public boolean isEnable() {
78
                return this.enable;
79
        }
80
81
        public void setEnabale(boolean enable) {
82
                this.enable = enable;
83
        }
84
85
        public Date getBeginDate() {
86
                return beginDate;
87
        }
88
89
        public void setBeginDate(Date beginDate) {
90
                this.beginDate = beginDate;
91
        }
92
93
        public Date getEndDate() {
94
                return endDate;
95
        }
96
97
        public void setEndDate(Date endDate) {
98
                this.endDate = endDate;
99
        }
100
101
        public IAnimationInterval createInterval() {
102
103
                List ADIList = this.getIntervalList();
104
                if (ADIList == null) {
105
                        ADIList = new ArrayList();
106
                }
107
                AnimationDatedInterval ADInterval = new AnimationDatedInterval();
108
                ADIList.add(ADInterval);
109
                return ADInterval;
110
        }
111
112
        public String toString() {
113
114
                String result;
115
                List ADIL = this.animationDateIntervalList;
116
                result = "Mostrando lista de Intervalos de la track " + this.getName()
117
                                + ":" + this.getDescription();
118
                result += "\n**********************************************";
119
                result += "\nTipo de objetos que contiene "
120
                                + this.getAnimationType().getClassName();
121
                result += "\nNombre: " + this.getAnimationType().getName();
122
                result += "\nDescripcion: " + this.getAnimationType().getName();
123
                result += "\n**********************************************";
124
                for (Iterator iter = ADIL.iterator(); iter.hasNext();) {
125
                        Object element = (Object) iter.next();
126
                        result += "\n" + element;
127
                }
128
                return result;
129
        }
130
131
        public void setDescription(String description) {
132
                Description = description;
133
        }
134
135
        public void setName(String name) {
136
                Name = name;
137
        }
138
139
        public void removeAllIntervals() {
140
                this.animationDateIntervalList.clear();
141
        }
142
143
        public void removeInterval(IAnimationInterval animationInterval) {
144
                this.animationDateIntervalList.remove(animationInterval);
145
        }
146
147
        public void setAnimatedObject(Object animatedObject) {
148
                this.animatedObject = animatedObject;
149
        }
150 15412 afraile
151 15349 julio
        public void apply(double Tini, double Tend) {
152
                List ADTL = this.animationDateIntervalList;
153
                if ((ADTL != null) && (!ADTL.isEmpty())) {
154
                        for (int i = 0; i < ADTL.size(); i++) {
155
                                IAnimationInterval element = (IAnimationInterval) ADTL.get(i);
156
                                element.apply(Tini, Tend, this.getAnimationType(), this
157
                                                .getAnimatedObject());
158
                        }
159
                }
160
161
        }
162 15412 afraile
163
        public String getClassName() {
164
                // TODO Auto-generated method stub
165
                return this.getClass().getName();
166
        }
167
168
        /*
169
         * IPersistance methods
170
         *
171
         */
172
173
        public void setXMLEntity(XMLEntity xml) {
174
                // TODO method to do persisence to this class
175 15445 afraile
176
                if (xml.contains("class_name"))
177
                        className =        xml.getStringProperty("class_name");
178
                if (xml.contains("name"))
179
                        Name =        xml.getStringProperty("name");
180 15412 afraile
                if (xml.contains("descripcion"))
181
                        Description = xml.getStringProperty("description");
182
                if (xml.contains("begin_date"))
183
                        beginDateString = xml.getStringProperty("begin_date");
184
                if (xml.contains("end_date"))
185
                        endDateString = xml.getStringProperty("end_date");
186
187
188 15445 afraile
//                for (int i = 0; i < this.animationDateIntervalList.size(); i++) {
189
//                        AnimationDatedInterval datedInterval = (AnimationDatedInterval) this.animationDateIntervalList.get(i);
190
//                        datedInterval.setXMLEntity(xml);
191
//                }
192 15412 afraile
193
        }
194
195
        public XMLEntity getXMLEntity() {
196
                // TODO method to get persisence to this class
197
198
                XMLEntity xml = new XMLEntity();
199 15445 afraile
                xml.putProperty("class_name", this.getClassName());
200
                xml.putProperty("name", Name);
201 15412 afraile
                xml.putProperty("description",Description );
202
203
                beginDateString = DateTime.dateToString(beginDate, sFormat);
204
                endDateString = DateTime.dateToString(endDate, sFormat);
205
206
                xml.putProperty("begin_date", beginDateString);
207
                xml.putProperty("end_date", endDateString);
208
209 15445 afraile
//                for (int i = 0; i < this.animationDateIntervalList.size(); i++) {
210
//                        AnimationDatedInterval datedInterval = (AnimationDatedInterval) this.animationDateIntervalList.get(i);
211
//                        datedInterval.getXMLEntity();
212
//                }
213 15412 afraile
                return xml;
214
215
        }
216
217 15349 julio
}