Revision 32766

View differences:

tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/AnimationContainer.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation;
21

  
22
import java.util.ArrayList;
23
import java.util.List;
24

  
25
import com.iver.cit.gvsig.animation.traks.AnimationDatedTrack;
26
import com.iver.cit.gvsig.animation.traks.AnimationTimeTrack;
27
import com.iver.cit.gvsig.animation.traks.IAnimationTrack;
28
import com.iver.utiles.IPersistence;
29
import com.iver.utiles.XMLEntity;
30

  
31
public class AnimationContainer implements IPersistence {
32

  
33
	// IAnimationTrakc List.
34
	public List<IAnimationTrack>  AnimationTrackList;
35

  
36
	private int trackListSize=0;
37

  
38
	private  AnimationPlayer animationPlayer = new AnimationPlayer();
39

  
40
	public AnimationContainer() {
41
		List<IAnimationTrack> aniTrackList = this.getAnimationTrackList();
42
		aniTrackList = new ArrayList<IAnimationTrack>();
43
		this.setAnimationTrackList(aniTrackList);
44
	}
45

  
46
	/**
47
	 * @param animationType
48
	 * @return
49
	 */
50
	public List<IAnimationTrack> getTackListOfType(IAnimationType animationType) {
51
		List<IAnimationTrack> typeList = new ArrayList<IAnimationTrack>();
52
		for (int i = 0; i < this.AnimationTrackList.size(); i++) {
53
			IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList
54
					.get(i);
55
			if (animationType.getClassName().equals(
56
					trackElement.getAnimationType().getClassName())) {
57
				typeList.add(trackElement);
58
			}
59

  
60
		}
61
		return typeList;
62
	}
63

  
64
	/**
65
	 * @param animationType
66
	 * @return
67
	 */
68
	public IAnimationTrack CreateDatedTrack(IAnimationType animationType) {
69

  
70
		List<IAnimationTrack> aniTrackList = this.getAnimationTrackList();
71
		if (aniTrackList == null) {
72
			aniTrackList = new ArrayList<IAnimationTrack>();
73
		}
74
		AnimationDatedTrack ADTrack = new AnimationDatedTrack(animationType);
75
		aniTrackList.add(ADTrack);
76
		this.setAnimationTrackList(aniTrackList);
77
		return ADTrack;
78
	}
79

  
80
	public IAnimationTrack CreateTimeTrack(IAnimationType animationType) {
81

  
82
		List<IAnimationTrack> aniTrackList = this.getAnimationTrackList();
83
		if (aniTrackList == null) {
84
			aniTrackList = new ArrayList<IAnimationTrack>();
85
		}
86
		AnimationTimeTrack ADTrack = new AnimationTimeTrack(animationType);
87
		aniTrackList.add(ADTrack);
88
		this.setAnimationTrackList(aniTrackList);
89
		return ADTrack;
90
	}
91

  
92
	/**
93
	 * @param animationTrack
94
	 */
95
	public void addTrack(IAnimationTrack animationTrack) {
96
		IAnimationTrack track = findTrack(animationTrack.getName());
97
		if (track == null) {
98
			this.AnimationTrackList.add(animationTrack);
99
		}
100
	}
101

  
102
	/**
103
	 * @param name
104
	 * @return
105
	 */
106
	public IAnimationTrack findTrack(String name) {
107

  
108
		IAnimationTrack IAT = null;
109
		for (int i = 0; i < this.AnimationTrackList.size(); i++) {
110
			IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList
111
					.get(i);
112
			if (trackElement.getName().equals(name)) {
113
				IAT = trackElement;
114
			}
115

  
116
		}
117
		return IAT;
118
	}
119

  
120
	/**
121
	 * @param animationTrack
122
	 */
123
	public void removeTrack(IAnimationTrack animationTrack) {
124
		animationTrack.removeAllIntervals();
125
		this.AnimationTrackList.remove(animationTrack);
126
	}
127

  
128
	/**
129
	 * 
130
	 */
131
	public void removeAllTrack() {
132
		for (int i=AnimationTrackList.size() - 1; i>=0; i--) {
133
			removeTrack(AnimationTrackList.get(i));
134
		}
135
		
136
//		for (Iterator<IAnimationTrack> iterator = AnimationTrackList.iterator(); iterator.hasNext();) {
137
//			((IAnimationTrack) iterator.next()).removeAllIntervals();
138
////			removeTrack(iterator.next());
139
//		}
140
//		AnimationTrackList.clear();
141
	}
142

  
143
	/**
144
	 * @return
145
	 */
146
	public List<IAnimationTrack> getAnimationTrackList() {
147
		return AnimationTrackList;
148
	}
149

  
150
	
151
	public boolean isEmpty() {
152
		
153
		if(this.AnimationTrackList.size() == 0)
154
			return true;
155
		else
156
			return false;
157
		
158
	}
159
	
160
	/**
161
	 * @param animationTrackList
162
	 */
163
	public void setAnimationTrackList(List<IAnimationTrack> animationTrackList) {
164
		AnimationTrackList = animationTrackList;
165
	}
166
	
167
	public String toString() {
168
		String result = "";
169
		List<IAnimationTrack> ATL = this.AnimationTrackList;
170
		result += "Mostrando lista de tracks:";
171
		if ((ATL == null) || ATL.isEmpty()) {
172
			result += "\nLista vacia";
173
		} else {
174
			for (int i = 0; i < ATL.size(); i++) {
175
				Object element = ATL.get(i);
176
				result += "\n" + element;
177
			}
178
		}
179
		return result;
180

  
181
	}
182

  
183
	public void apply(double Tini, double Tend) {
184
		List<IAnimationTrack> ATL = this.AnimationTrackList;
185
//		System.out.println("Tiempo de inicio: " + Tini + " tiempo final "
186
//				+ Tend);
187
		if ((ATL != null) && !ATL.isEmpty()) {
188
			for (int i = 0; i < ATL.size(); i++) {
189
				IAnimationTrack element = (IAnimationTrack) ATL.get(i);
190
//				System.out.println("track: " + element.getName() + "OBJETO" + element.getAnimatedObject());
191
				element.apply(Tini, Tend);
192
				if (element.isEnable()){}
193
			}
194
		}
195
	}
196
	
197
	
198
	/**
199
	 * Return the name of this class.
200
	 * @return name.
201
	 */
202
	
203
	public String getClassName() {
204
		return this.getClass().getName();
205
	}
206
	
207
	/**
208
	 * Return the player associated with the container.
209
	 * @return animationPlayer.
210
	 */
211
	
212
	public AnimationPlayer getAnimationPlayer(){
213
		return this.animationPlayer;
214
	}
215
	
216
	/*
217
	 * IPersistence methods.
218
	 */
219
	
220
	public XMLEntity getXMLEntity() {
221
		XMLEntity xml = new XMLEntity();
222
		
223
		xml.putProperty("className", this.getClassName());
224
		xml.putProperty("animationContainer", "true");
225
		xml.putProperty("trackListSize", this.AnimationTrackList.size());
226
		
227
		xml.addChild(((IPersistence)animationPlayer).getXMLEntity());
228
		
229
		for (int i = 0; i < this.AnimationTrackList.size(); i++) {			
230
			IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList.get(i);			
231
			xml.addChild(((IPersistence)trackElement).getXMLEntity());
232
		}
233
		return xml;
234
	}
235

  
236
	
237
	
238

  
239
	/**
240
	 * @param xml
241
	 */
242
	public void setXMLEntity(XMLEntity xml) {
243
		
244
		String class_name;
245
		
246
		if (xml.contains("trackListSize"))
247
			this.trackListSize = xml.getIntProperty("trackListSize");
248
		 
249
		// Node AnimationPlayer in the animation tree. Calling setXmlEntity() methods.
250
		// Reconstruyendo el framework. Paso: accediendo a la configuracion del player.
251
		
252
		this.animationPlayer.setXMLEntity(xml.getChild(0));
253
		
254
		
255
		// Node IAnimationTrack in the animation tree. Calling setXmlEntity() methods.
256
		// Reconstruyendo el framework. Paso: nuevo IAnimationTrack, AnimationDateTrack o AnimationTimeTrack.
257
		
258
		List<IAnimationTrack> trackList = new ArrayList<IAnimationTrack>();
259
		for (int i = 1; i <= this.trackListSize; i++) {//desde el hijo 1 que es el primer track hasta el ?ltimo track.
260
			XMLEntity xmlTrack = xml.getChild(i);
261
			class_name = xmlTrack.getStringProperty("className");//Accedemos al tipo de track.
262
				try {
263
					Class<?> classTrack = Class.forName(class_name);
264
					Object obj = classTrack .newInstance();
265
					IPersistence objPersist = (IPersistence) obj;
266
					objPersist.setXMLEntity(xmlTrack);
267
					IAnimationTrack trackElement = (IAnimationTrack) obj;
268
					trackElement.setEnable(true);
269
					trackList.add(trackElement);
270
				} catch (Exception e) {
271
					e.printStackTrace();
272
			}
273
		}
274
		this.setAnimationTrackList(trackList);
275

  
276
	}
277

  
278
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/dateFilter/ICustomVectorialFilter.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.dateFilter;
21

  
22
//import com.iver.cit.gvsig.fmap.core.IFeature;
23

  
24
public interface ICustomVectorialFilter {
25
//	public boolean accepts(IFeature feature);
26
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/dateFilter/DateFilter.java
1
package com.iver.cit.gvsig.animation.dateFilter;
2

  
3

  
4
//public class DateFilter implements ICustomVectorialFilter, IPersistence {
5
	public class DateFilter {
6
//
7
//	public static int FIELDTYPE_DATE = 0;
8
//	public static int FIELDTYPE_DATESTRING = 1;
9
//
10
//	public static int BOTH = 2 | 4;
11
//	public static int BEFORE_BEGIN = 2;
12
//	public static int AFTER_END = 4;
13
//
14
//	private int fieldType = -1;
15
//
16
//	private int filterFieldIndex = -1;
17
//	private Date minDate = null;
18
//	private Date maxDate = null;
19
//	// derived
20
//	private SimpleDateFormat localeDF = null;
21
//	private SimpleDateFormat javaDF = null;
22
//	private Calendar cl = null;
23
//
24
//	private int filterMode = BEFORE_BEGIN;
25
//
26
//	public void setFieldIndex(int index) {
27
//		filterFieldIndex = index;
28
//	}
29
//
30
//	public void setFieldType(int type) {
31
//		fieldType = type;
32
//	}
33
//
34
//	public void setMinDate(Date miniDate) {
35
//		minDate = miniDate;
36
//	}
37
//
38
//	public void setMaxDate(Date maxiDate) {
39
//		maxDate = maxiDate;
40
//	}
41
//
42
//	public int getFieldType() {
43
//		return fieldType;
44
//	}
45
//
46
//	public Date getMinDate() {
47
//		return minDate;
48
//	}
49
//
50
//	public Date getMaxDate() {
51
//		return maxDate;
52
//	}
53
//
54
//	public boolean accepts(IFeature feature) {
55
//
56
//		if (filterFieldIndex == -1 || minDate == null || maxDate == null)
57
//			return false;
58
//
59
//		Value val = feature.getAttribute(filterFieldIndex);
60
//		if (val instanceof NullValue)
61
//			return false;
62
//
63
//		Date dateVal = null;
64
//		if (fieldType == FIELDTYPE_DATE) {
65
//			try {
66
//				dateVal = ((DateValue) val).getValue();
67
//			} catch (RuntimeException e) {
68
//				return false;
69
//			}
70
//		} else if (fieldType == FIELDTYPE_DATESTRING) {
71
//			if (localeDF == null)
72
//				localeDF = new SimpleDateFormat("dd/MM/yyyy");
73
//			if (javaDF == null)
74
//				javaDF = new SimpleDateFormat("yyyy-MM-dd");
75
//
76
//			String valStr = val.toString();
77
//
78
//			try {
79
//				java.util.Date utDate = localeDF.parse(valStr); // reads locale
80
//				// dd/MM/yyyy
81
//				// strings
82
//				String utDateStr = javaDF.format(utDate); // outputs
83
//				// yyyy-MM-dd
84
//				dateVal = Date.valueOf(utDateStr); // creates Date for
85
//				// comparison
86
//			} catch (ParseException e) {
87
//				return false;
88
//			}
89
//		}
90
//
91
//		try {
92
//			String dateValStr = dateVal.toString();
93
//			String minDateStr = minDate.toString();
94
//			String maxDateStr = maxDate.toString();
95
//
96
//			if (((this.filterMode & BEFORE_BEGIN) != BEFORE_BEGIN))
97
//				if (dateVal.compareTo(minDate) < 0)
98
//					return false;
99
//
100
//			if (((this.filterMode & AFTER_END) != AFTER_END))
101
//				if (dateVal.compareTo(maxDate) > 0)
102
//					return false;
103
//
104
//		} catch (Exception e) {
105
//			return false;
106
//		}
107
//		return true;
108
//	}
109
//
110
//	public String getClassName() {
111
//		return this.getClass().getName();
112
//	}
113
//
114
//	public XMLEntity getXMLEntity() {
115
//		XMLEntity xml = new XMLEntity();
116
//
117
//		xml.putProperty("fieldType", fieldType);
118
//		xml.putProperty("fieldIndex", filterFieldIndex);
119
//		xml.putProperty("minDate", minDate.toString());
120
//		xml.putProperty("maxDate", maxDate.toString());
121
//
122
//		return xml;
123
//	}
124
//
125
//	public void setXMLEntity(XMLEntity xml) {
126
//		if (xml.contains("fieldType"))
127
//			fieldType = xml.getIntProperty("fieldType");
128
//
129
//		if (xml.contains("fieldIndex"))
130
//			filterFieldIndex = xml.getIntProperty("fieldIndex");
131
//
132
//		if (xml.contains("minDate"))
133
//			minDate = Date.valueOf(xml.getStringProperty("minDate"));
134
//
135
//		if (xml.contains("maxDate"))
136
//			maxDate = Date.valueOf(xml.getStringProperty("maxDate"));
137
//	}
138
//
139
//	public String toString() {
140
//		String result = "";
141
//
142
//		result += minDate.toString() + "\n" + maxDate.toString();
143
//
144
//		return result;
145
//	}
146
//
147
//	public boolean compareTo(ICustomVectorialFilter filter) {
148
//		DateFilter filterAux = (DateFilter) filter;
149
//		boolean type = this.getFieldType() == filterAux.getFieldType();
150
//		boolean min = this.getMinDate().toString().equals(
151
//				filterAux.getMinDate().toString());
152
//		boolean max = this.getMaxDate().toString().equals(
153
//				filterAux.getMaxDate().toString());
154
//
155
//		return (type && min && max);
156
//	}
157
//
158
//	public int getFilterMode() {
159
//		return filterMode;
160
//	}
161
//
162
//	public void setFilterMode(int filterMode) {
163
//		this.filterMode = filterMode;
164
//	}
165
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/dateFilter/IDateFilter.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.dateFilter;
21

  
22
public interface IDateFilter {
23

  
24
	public void setFieldIndex(int field);
25

  
26
	public void setFiieldType(int Type);
27

  
28
	public void setMinDate(String date);
29

  
30
	public void setMaxDate(String Date);
31

  
32
	public int getFieldIndex();
33

  
34
	public int getFiieldType();
35

  
36
	public String getMinDate();
37

  
38
	public String getMaxDate();
39
	
40
	public boolean accepts(Object feature);
41

  
42
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/dateFilter/IndexFilter.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.dateFilter;
21

  
22
//import com.hardcode.gdbms.engine.values.NullValue;
23
//import com.hardcode.gdbms.engine.values.NumericValue;
24
//import com.hardcode.gdbms.engine.values.Value;
25
//import com.iver.cit.gvsig.fmap.core.IFeature;
26
//import com.iver.utiles.IPersistence;
27
//import com.iver.utiles.XMLEntity;
28

  
29
//public class IndexFilter implements ICustomVectorialFilter, IPersistence {
30
	public class IndexFilter  {
31

  
32
//	private int filterFieldIndex=-1;
33
//	private int minIndex = -1;
34
//	private int maxIndex = -1;
35
//	
36
//	public void setFieldIndex(int index) {
37
//		filterFieldIndex = index;
38
//	}
39
//	
40
//	// if type is INTEGER, use these instead of setMinDate/setMaxDate
41
//	// internally, the int value is used as year
42
//	public void setMinIndex(int miniIndex) {
43
//		minIndex = miniIndex;
44
//	}
45
//	
46
//	public void setMaxIndex(int maxiIndex) {
47
//		maxIndex = maxiIndex;
48
//	}
49
//	
50
//	public boolean accepts(IFeature feature) {
51
//		
52
//		Value val = feature.getAttribute(filterFieldIndex);
53
//		if (val instanceof NullValue)
54
//			return false;
55
//		
56
//		if (!(val instanceof NumericValue))
57
//			return false;
58
//		
59
//		int intVal = ((NumericValue)val).intValue();
60
//	
61
//		if (intVal < minIndex)
62
//		    return false;
63
//		
64
//		if (intVal > maxIndex)
65
//		    return false;
66
//			
67
//		return true;
68
//	}
69
//
70
//	public String getClassName() {
71
//		return this.getClass().getName();
72
//	}
73
//
74
//	public XMLEntity getXMLEntity() {
75
//		XMLEntity xml = new XMLEntity();
76
//
77
//		xml.putProperty("fieldIndex", filterFieldIndex);
78
//		xml.putProperty("minIndex", minIndex);
79
//		xml.putProperty("maxIndex", maxIndex);
80
//
81
//		return xml;
82
//	}
83
//
84
//	public void setXMLEntity(XMLEntity xml) {
85
//
86
//		if (xml.contains("fieldIndex"))
87
//			filterFieldIndex = xml.getIntProperty("fieldIndex");
88
//		
89
//		if (xml.contains("minIndex"))
90
//			minIndex = xml.getIntProperty("minIndex");
91
//
92
//		if (xml.contains("maxIndex"))
93
//			maxIndex = xml.getIntProperty("maxIndex");
94
//	}
95
//
96
//	public boolean compareTo(ICustomVectorialFilter filter) {
97
//		IndexFilter filterAux = (IndexFilter) filter;
98
//
99
//		return ((this.minIndex == filterAux.minIndex) && (this.maxIndex == filterAux.maxIndex));
100
//	}
101

  
102
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/IKeyFrame.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.keyframe;
21

  
22
import java.util.List;
23

  
24
import com.iver.utiles.IPersistence;
25

  
26
public interface IKeyFrame extends IPersistence {
27
	
28
	public void setName(String name);
29
	public String getName();
30
	
31
	public void setTime(double time);
32
	public double getTime();
33
	
34
	public void setPropertiesList(List<IKeyFrame> list);
35
	public List<IKeyFrame> getPropertiesList();
36
	
37
	public void setAnimatedObject(Object object);
38
	public void CapturesProperties();
39
	
40
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/IAnimationTypeKeyFrame.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.keyframe;
21

  
22
import com.iver.cit.gvsig.animation.IAnimationType;
23
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator;
24

  
25
public interface IAnimationTypeKeyFrame extends IAnimationType{
26
	
27
	public IInterpolator getInterpolator();
28
	
29
	public void setInterpolator(IInterpolator interpolator);
30

  
31
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/interpolator/IInterpolator.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.keyframe.interpolator;
21

  
22
import java.util.List;
23

  
24
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame;
25
import com.iver.utiles.IPersistence;
26

  
27
public interface IInterpolator extends IPersistence{
28

  
29
	public IKeyFrame interpolate(List<IKeyFrame> kfList, int index, double time);
30

  
31
	public String getName();
32

  
33
	public String getDescription();
34

  
35
	public String getClassName();
36
	
37
	public void setFuntion(IInterpolatorTimeFuntion funtion);
38
	
39
	public IInterpolatorTimeFuntion getFuntion();
40
	
41

  
42
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/interpolator/IInterpolatorTimeFuntion.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.keyframe.interpolator;
21

  
22

  
23
public interface IInterpolatorTimeFuntion {
24

  
25
	// Identification of the class
26
	public void setName(String name);
27

  
28
	public void setDescription(String name);
29

  
30
	public String getName();
31

  
32
	public String getDescription();
33

  
34
	public String getClassName();
35

  
36
	// Interpolation function
37
	public double interpolate(double T);
38

  
39
	public double[] interpolate(double T[]);
40
	
41
	public IInterpolatorTimeFuntion create();
42

  
43
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/interpolator/LinearFuntion.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.keyframe.interpolator;
21

  
22

  
23
public class LinearFuntion implements IInterpolatorTimeFuntion {
24

  
25
	private String name;
26
	private String description;
27

  
28
	public String getName() {
29
		return name;
30
	}
31

  
32
	public void setName(String name) {
33
		this.name = name;
34
	}
35

  
36
	public String getClassName() {
37
		return this.getClass().getName();
38
	}
39

  
40
	public String getDescription() {
41
		return this.description;
42
	}
43

  
44
	public void setDescription(String name) {
45
		this.description = name;
46
	}
47

  
48
	public double interpolate(double T) {
49
		return T;
50
	}
51

  
52
	public double[] interpolate(double[] T) {
53
		return T;
54
	}
55

  
56
	public IInterpolatorTimeFuntion create() {
57
		return this;
58
	}
59

  
60
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/interpolator/FuntionFactory.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.keyframe.interpolator;
21

  
22
import java.util.HashMap;
23
import java.util.Map;
24

  
25

  
26
/*
27
 * factoria para el registro y la creacion de funciones de animacion de tiempo
28
 * 
29
 * 
30
 */
31
public class FuntionFactory {
32

  
33
//	private static Map<String, IInterpolatorFuntion> objectsList;
34
	private static Map objectsList;
35

  
36
	static {
37
//		objectsList = new HashMap<String, IInterpolatorFuntion>();
38
		objectsList = new HashMap();
39
		LinearFuntion lf = new LinearFuntion();
40
		lf.setName("LinearFuntion");
41
		lf.setDescription("Funcion para el tiempo lineal");
42
		FuntionFactory.register(lf);
43
	}
44

  
45
	public static void register(IInterpolatorTimeFuntion funtion) {
46
		objectsList.put(funtion.getClassName(), funtion);
47
	}
48

  
49
	public static IInterpolatorTimeFuntion createObject(String type) {
50
		IInterpolatorTimeFuntion funtion = null;
51
		try {
52
			if ((objectsList.containsKey(type)) == false)
53
				return null;
54
			funtion = (IInterpolatorTimeFuntion) objectsList.get(type).getClass().newInstance();
55
		} catch (InstantiationException e) {
56
			e.printStackTrace();
57
		} catch (IllegalAccessException e) {
58
			e.printStackTrace();
59
		}
60
		return funtion;
61
	}
62

  
63
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/interpolator/InterpolatorFactory.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.keyframe.interpolator;
21

  
22
import java.util.HashMap;
23
import java.util.Map;
24

  
25
public class InterpolatorFactory {
26
	private static Map<String, IInterpolator> objectsList;
27

  
28
	static {
29
		objectsList = new HashMap<String, IInterpolator>();
30
	}
31

  
32
	public static void register(String alias, IInterpolator interpolator) {
33
		objectsList.put(alias, interpolator);
34
	}
35

  
36
	public static IInterpolator createObject(String alias) {
37
		IInterpolator interpolator = null;
38
		System.out.println("existe el tipo " + alias + "  "
39
				+ objectsList.containsKey(alias));
40
		if ((objectsList.containsKey(alias)) == false) {
41
			return null;
42
		} else {
43
			interpolator = (IInterpolator) objectsList.get(alias);
44
		}
45
		return interpolator;
46
	}
47

  
48
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/AnimationFunction.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.keyframe;
21

  
22
import java.util.List;
23

  
24
import com.iver.utiles.IPersistence;
25
import com.iver.utiles.XMLEntity;
26

  
27

  
28
/**
29
 * @author ?ngel Fraile Gri??n  e-mail: angel.fraile@iver.es
30
 * @since 1.1
31
 * 
32
 */
33

  
34
public class AnimationFunction implements IPersistence{
35

  
36
	private List AnimationFunctionList;
37
	//private String className;
38
	
39
	//private AnimationFunction animationFunctionItem;
40

  
41
	public List getAnimationFuntionList() {
42
		return AnimationFunctionList;
43
	}
44

  
45
	public void setAnimationFuntionList(List animationFuntionList) {
46
		AnimationFunctionList = animationFuntionList;
47
	}
48

  
49
	public String toString() {
50

  
51
		String result = "";
52

  
53
		return result;
54
	}
55

  
56
	
57
	public String getClassName() {
58
		return this.getClass().getName();
59
	}
60

  
61
	
62
	public XMLEntity getXMLEntity() {
63
		XMLEntity xml = new XMLEntity();
64
		
65
		xml.putProperty("class_name", this.getClassName());		
66
		for (int i = 0; i < this.AnimationFunctionList.size(); i++) {
67
			AnimationFunction animationFunctionItem = (AnimationFunction) this.AnimationFunctionList.get(i);	
68
			xml.addChild(((IPersistence)animationFunctionItem).getXMLEntity());
69
			return xml;//provisional	
70
		}	
71
		return xml;
72
	}
73

  
74
	
75
	public void setXMLEntity(XMLEntity xml) {
76
		// TODO Auto-generated method stub
77
//		
78
//		if (xml.contains("class_name"))
79
//			className = xml.getStringProperty("class_name");	
80
//		for (int i = 0; i < this.AnimationFunctionList.size(); i++) {
81
//			AnimationFunction animationFunctionItem = (AnimationFunction) this.AnimationFunctionList.get(i);			
82
//			return;	 //provisional
83
//		}	
84
//		
85
	}
86
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/interval/AnimationDatedInterval.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.interval;
21

  
22
import java.sql.Date;
23
import java.text.SimpleDateFormat;
24
import java.util.Calendar;
25
import java.util.Locale;
26

  
27
import com.iver.cit.gvsig.animation.IAnimationType;
28
import com.iver.utiles.DateTime;
29
import com.iver.utiles.IPersistence;
30
import com.iver.utiles.XMLEntity;
31

  
32
public class AnimationDatedInterval implements IAnimationInterval, IPersistence {
33

  
34
	private Date beginDateInterval;
35

  
36
	private Date endDateInterval;
37

  
38
	private String beginDateString = new String();
39

  
40
	private String endDateString = new String();
41

  
42
	private String sFormat = new String("Y-m-d");
43

  
44
	static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
45

  
46
	public Date getBeginDateInterval() {
47
		return beginDateInterval;
48
	}
49

  
50
	public void setBeginDateInterval(Date beginDateInterval) {
51
		this.beginDateInterval = beginDateInterval;
52
	}
53

  
54
	public Date getEndDateInterval() {
55
		return endDateInterval;
56
	}
57

  
58
	public void setEndDateInterval(Date endDateInterval) {
59
		this.endDateInterval = endDateInterval;
60
	}
61

  
62
	public String toString() {
63
		String result = "Intervalo de " + this.beginDateInterval + " a "
64
				+ this.endDateInterval;
65
		return result;
66
	}
67

  
68
	public double getEndTime() {
69
		return this.endDateInterval.getTime();
70
	}
71

  
72
	public double getInitialTime() {
73
		return this.beginDateInterval.getTime();
74
	}
75

  
76
	public double getIntervalTime() {
77
		return (this.endDateInterval.getTime() - this.beginDateInterval
78
				.getTime());
79
	}
80

  
81
	public void setEndTime(double time) {
82
		this.endDateInterval.setTime((long) time);
83

  
84
	}
85

  
86
	public void setInitialTime(double time) {
87
		this.beginDateInterval.setTime((long) time);
88

  
89
	}
90

  
91
	public void setIntervalTime(double time) {
92
		// TODO generate method to calculate interval time
93
	}
94

  
95
	public void apply(double tini, double tend, IAnimationType animationType,
96
			Object animated) {
97
		// falta completar la funcion
98
		// System.out.println("PINTANDO OBJETO");
99
		// System.out.println("milisegundos del inicio del intervalo "
100
		// + this.dateToSeconds(this.getBeginDateInterval()));
101

  
102
//		int day1 = this.getBeginDateInterval().getDate();
103
//		int day2 = this.getEndDateInterval().getDate();
104
//		int result = linearInterpolate(day1, day2, 0.0, 1.0, tini);
105
//		// System.out.println("fecha resultante " + result);
106
//		int min = (int) (result - 1);
107
//		// System.out.println("fehca minima " + "2000-01-" + min );
108
//		int max = (int) (result + 1);
109
//		// System.out.println("fehca minima " + "2000-01-" + max );
110
//
111
//		DateFilter filter = new DateFilter();
112
//		filter.setFieldIndex(0); // Date field in com_aut data sample
113
//		filter.setFieldType(DateFilter.FIELDTYPE_DATESTRING);
114
////		filter.setMinDate(Date.valueOf("2000-01-1"));
115
//		filter.setMinDate(Date.valueOf("2000-01-" + min));
116
//		filter.setMaxDate(Date.valueOf("2000-01-" + max));
117

  
118
		animationType.AppliesToObject(animated);
119

  
120
	}
121

  
122
	private int linearInterpolate(int minX, int minX2, double timePos,
123
			double timePos2, double time) {
124
		// P1 + (P2-P1)*((t-t1)/(t2-t1))
125

  
126
		double result = ((minX + (minX2 - minX)) * time);
127

  
128
		return (int) Math.ceil(result);
129
	}
130

  
131
	private double dateToSeconds(Date date) {
132
		Calendar ca = Calendar.getInstance(Locale.US);
133
		ca.setTime(date);
134
		return ca.getTimeInMillis();
135
	}
136

  
137
	/*
138
	 * IPersistance methods.
139
	 */
140

  
141
	public String getClassName() {
142
		// TODO Auto-generated method stub
143
		return null;
144
	}
145

  
146
	public XMLEntity getXMLEntity() {
147

  
148
		XMLEntity xml = new XMLEntity();
149
		xml.putProperty("className", this.getClassName());
150
		// xml.putProperty("beginDateInterval", beginDateString);
151
		// xml.putProperty("endDateInterval", endDateString);
152

  
153
		beginDateString = DateTime.dateToString(beginDateInterval, sFormat);
154
		endDateString = DateTime.dateToString(endDateInterval, sFormat);
155

  
156
		xml.putProperty("begin_date", beginDateString);
157
		xml.putProperty("end_date", endDateString);
158

  
159
		return xml;
160
	}
161

  
162
	public void setXMLEntity(XMLEntity xml) {
163
		if (xml.contains("begin_date"))
164
			beginDateString = xml.getStringProperty("begin_date");
165
		if (xml.contains("end_date"))
166
			endDateString = xml.getStringProperty("end_date");
167

  
168
	}
169
}
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/libAnimation/src/com/iver/cit/gvsig/animation/interval/AnimationKeyFrameInterval.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19

  
20
package com.iver.cit.gvsig.animation.interval;
21

  
22
import java.util.ArrayList;
23
import java.util.Iterator;
24
import java.util.List;
25

  
26
import com.iver.cit.gvsig.animation.IAnimationType;
27
import com.iver.cit.gvsig.animation.keyframe.IAnimationTypeKeyFrame;
28
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame;
29
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator;
30
import com.iver.utiles.IPersistence;
31
import com.iver.utiles.XMLEntity;
32
import com.iver.utiles.extensionPoints.ExtensionPoint;
33
import com.iver.utiles.extensionPoints.ExtensionPoints;
34
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
35

  
36
/**
37
 * @author ?ngel Fraile Gri??n  e-mail: angel.fraile@iver.es
38
 * @since 1.1
39
 * 
40
 */
41

  
42
public class AnimationKeyFrameInterval implements IAnimationTimeInterval {
43

  
44
	private List<IKeyFrame> KeyFrameList;
45

  
46
	private double initialTime = 0;
47

  
48
	private double endTime = 1;
49

  
50
	private double intervalTime = endTime - initialTime;
51

  
52
	private int keyFrameListSize;
53

  
54
	private IKeyFrame keyframe;
55
	
56

  
57
	public List<IKeyFrame> getKeyFrameList() {
58
		return KeyFrameList;
59
	}
60

  
61
	public void setKeyFrameList(List<IKeyFrame> keyFrameList) {
62
		KeyFrameList = keyFrameList;
63
	}
64

  
65
	public double getEndTime() {
66
		return endTime;
67
	}
68

  
69
	public double getInitialTime() {
70
		return initialTime;
71
	}
72

  
73
	public double getIntervalTime() {
74
		return (endTime - initialTime);
75
	}
76

  
77
	public void setEndTime(double time) {
78
		this.endTime = time;
79

  
80
	}
81

  
82
	public void setInitialTime(double time) {
83
		this.initialTime = time;
84
	}
85

  
86
	public void setIntervalTime(double time) {
87
		this.intervalTime = time;
88
	}
89

  
90
	public String toString() {
91

  
92
		String result;
93
		List<IKeyFrame> KFL = this.KeyFrameList;
94
		if (KFL != null) {
95
			result = "Mostrando lista de KeyFrames del intervalo Tini:"
96
					+ this.getInitialTime() + " Tend" + this.getEndTime();
97
			for (Iterator<IKeyFrame> iter = KFL.iterator(); iter.hasNext();) {
98
				Object element = (Object) iter.next();
99
				result += "\n" + element;
100
			}
101
		} else {
102
			result = "Lista de key frame vacia";
103
		}
104
		return result;
105
	}
106

  
107
	
108
	public void apply(double tini, double tend, IAnimationType animationType,
109
			Object animated) {
110

  
111
		IAnimationTypeKeyFrame animationTypeFrame = (IAnimationTypeKeyFrame) animationType;
112
		IInterpolator interpolator = animationTypeFrame.getInterpolator();
113

  
114
		IKeyFrame previus = null;
115
		IKeyFrame next = null;
116
		List<IKeyFrame> KFLInterpolate = new ArrayList<IKeyFrame>();
117

  
118
		List<IKeyFrame> KFL = this.KeyFrameList;
119
		if (KFL != null) {
120
			for (Iterator<IKeyFrame> iter = KFL.iterator(); iter.hasNext();) {
121
				IKeyFrame element = (IKeyFrame) iter.next();
122
				double KFtime = element.getTime();
123
				boolean asigned = false;
124
				if (KFtime <= tini) {
125
					if (previus != null) {
126
						if (KFtime > previus.getTime())
127
							previus = element;
128
					} else {
129
						previus = element;
130
					}
131
					asigned = true;
132
				}
133
				if ((KFtime > tini) && (!asigned)) {
134
					if (next != null) {
135
						if (KFtime < previus.getTime())
136
							next = element;
137
					} else {
138
						next = element;
139
					}
140

  
141
				}
142

  
143
			}
144
			KFLInterpolate.add(previus);
145
			KFLInterpolate.add(next);
146
		}
147

  
148
		IKeyFrame frame = null;
149
		if (KFLInterpolate != null) {
150
			frame = interpolator.interpolate(KFLInterpolate, 0, tini);
151
		}
152
		if (frame != null)
153
			animationType.AppliesToObject(frame);
154

  
155
	}
156
	
157
	public String getClassName() {
158
		return this.getClass().getName();
159
	}
160
	
161
	public int getKeyFrameListSize() {
162
		return keyFrameListSize;
163
	}
164

  
165
	public void setKeyFrameListSize(int keyFrameListSize) {
166
		this.keyFrameListSize = keyFrameListSize;
167
	}
168

  
169
	
170
	/*
171
	 * IPersistence methods.
172
	 */
173

  
174
	public XMLEntity getXMLEntity() {
175
		XMLEntity xml = new XMLEntity();
176

  
177
		xml.putProperty("className", this.getClassName());
178
		xml.putProperty("keyFrameListSize", this.KeyFrameList.size());
179
		xml.putProperty("beginTime", initialTime);
180
		xml.putProperty("endTime", endTime);
181
		xml.putProperty("intervalTime", intervalTime);
182

  
183
		//all the keyFrames in the interval.
184
		for (int i = 0; i < this.KeyFrameList.size(); i++) {
185
			IKeyFrame keyFrameItem = (IKeyFrame) this.KeyFrameList.get(i);	
186
			xml.addChild(((IPersistence)keyFrameItem).getXMLEntity());
187
		}
188
		return xml;		
189

  
190
	}
191

  
192
	public void setXMLEntity(XMLEntity xml) {
193
		
194
		if (xml.contains("keyFrameListSize"))
195
			this.keyFrameListSize=	xml.getIntProperty("keyFrameListSize");
196
		if (xml.contains("beginTime"))
197
			this.initialTime = xml.getDoubleProperty("beginTime");
198
		if (xml.contains("endTime"))
199
			this.endTime = xml.getDoubleProperty("endTime");
200
		if (xml.contains("intervalTime"))
201
			this.intervalTime = xml.getDoubleProperty("intervalTime");
202
		
203
		
204
		// Node IKeyFrame in the animation tree. Calling setXmlEntity() methods.
205
		// Reconstruyendo el framework. Paso: nuevos(seg?n el n?mero de keyframes del intervalo) IKeyFrame, del  
206
		// 									  tipo KeyFrameX, seg?n la animaci?n.
207
		List<IKeyFrame> timeKeyFrameList = new ArrayList<IKeyFrame>();
208
		for (int i = 0; i < this.keyFrameListSize; i++) {// Desde el hijo 0.
209
			
210
			XMLEntity xmlKeyframe = xml.getChild(i);
211
			
212
			ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
213
			ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints.get("Animation"));
214
			
215
			String aliasKeyFrameName = xmlKeyframe.getStringProperty("keyFrameAlias");
216
			
217
			try {
218
				keyframe = (IKeyFrame) extPoint.create(aliasKeyFrameName);
219
				keyframe.setXMLEntity(xmlKeyframe);
220
				timeKeyFrameList.add(keyframe);
221
			} catch (InstantiationException e) {
222
				e.printStackTrace();
223
			} catch (IllegalAccessException e) {
224
				e.printStackTrace();
225
			}
226
		
227
		}
228
		this.setKeyFrameList(timeKeyFrameList);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff