Revision 15500
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/.classpath | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
5 |
<classpathentry combineaccessrules="false" kind="src" path="/libIverUtiles"/> |
|
6 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap"/> |
|
7 |
<classpathentry combineaccessrules="false" kind="src" path="/_fwAndami"/> |
|
8 |
<classpathentry combineaccessrules="false" kind="src" path="/appgvSIG"/> |
|
9 |
<classpathentry kind="src" path="test"/> |
|
10 |
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/> |
|
11 |
<classpathentry kind="lib" path="/libFMap/lib/gdbms-0.8-SNAPSHOT.jar" sourcepath="/libGDBMS"/> |
|
12 |
<classpathentry kind="output" path="bin"/> |
|
13 |
</classpath> |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>libAnimation</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
</buildSpec> |
|
14 |
<natures> |
|
15 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
16 |
</natures> |
|
17 |
</projectDescription> |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/test/Animation3D.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.test; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
4 |
|
|
5 |
public class Animation3D implements IAnimationType { |
|
6 |
|
|
7 |
private String className; |
|
8 |
private String Description; |
|
9 |
private String Name; |
|
10 |
private int typeTrack = IAnimationType.TIME_TYPE_TRACK; |
|
11 |
|
|
12 |
public String getClassName() { |
|
13 |
return className; |
|
14 |
} |
|
15 |
|
|
16 |
public String getDescription() { |
|
17 |
return Description; |
|
18 |
} |
|
19 |
|
|
20 |
public String getName() { |
|
21 |
return Name; |
|
22 |
} |
|
23 |
|
|
24 |
public void setClassName(String className) { |
|
25 |
this.className = className; |
|
26 |
} |
|
27 |
|
|
28 |
public void setDescription(String description) { |
|
29 |
Description = description; |
|
30 |
} |
|
31 |
|
|
32 |
public void setName(String name) { |
|
33 |
Name = name; |
|
34 |
} |
|
35 |
|
|
36 |
public void AppliesToObject(Object animated) { |
|
37 |
// TODO Auto-generated method stub |
|
38 |
|
|
39 |
} |
|
40 |
|
|
41 |
public int getTypeTrack() { |
|
42 |
return typeTrack; |
|
43 |
} |
|
44 |
|
|
45 |
public void setTypeTrack(int typeTrack) { |
|
46 |
this.typeTrack = typeTrack; |
|
47 |
|
|
48 |
} |
|
49 |
|
|
50 |
public Object getAnimatedObject() { |
|
51 |
// TODO Auto-generated method stub |
|
52 |
return null; |
|
53 |
} |
|
54 |
|
|
55 |
public void setAnimatedObject(Object object) { |
|
56 |
// TODO Auto-generated method stub |
|
57 |
|
|
58 |
} |
|
59 |
|
|
60 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/test/AnimationTypeFactory3D.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.test; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.animation.AnimationFactory; |
|
4 |
|
|
5 |
|
|
6 |
public class AnimationTypeFactory3D extends AnimationFactory { |
|
7 |
|
|
8 |
public static String registerName = "Animation3D"; |
|
9 |
|
|
10 |
|
|
11 |
public static Animation3D animation3D; |
|
12 |
|
|
13 |
static { |
|
14 |
if (animation3D == null) { |
|
15 |
animation3D = new Animation3D(); |
|
16 |
animation3D.setClassName("Animation3D"); |
|
17 |
animation3D.setName("Animation3D"); |
|
18 |
animation3D.setDescription("Hola caracola"); |
|
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
public Object create() { |
|
25 |
|
|
26 |
return animation3D; |
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* Registers in the points of extension the Factory with alias. |
|
31 |
* |
|
32 |
*/ |
|
33 |
public static void register() { |
|
34 |
register(registerName, new AnimationTypeFactory3D(), "com.iver.cit.gvsig.animation.test.Animation3D"); |
|
35 |
} |
|
36 |
|
|
37 |
public String getRegisterName() { |
|
38 |
return registerName; |
|
39 |
} |
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/timer/IUpdateCallBack.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.timer; |
|
2 |
|
|
3 |
public interface IUpdateCallBack { |
|
4 |
|
|
5 |
public void update(); |
|
6 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/timer/AnimationTimer.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.timer; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
// this class is only an example. it isn?t used in librarys |
|
11 |
public class AnimationTimer implements Runnable { |
|
12 |
double milis; |
|
13 |
private boolean finish; |
|
14 |
private List callBackList; |
|
15 |
private Thread thread; |
|
16 |
|
|
17 |
|
|
18 |
/** |
|
19 |
* Lanza un timer cada segundo. |
|
20 |
*/ |
|
21 |
public AnimationTimer() |
|
22 |
{ |
|
23 |
|
|
24 |
} |
|
25 |
|
|
26 |
public void run() { |
|
27 |
while (true) { |
|
28 |
try { |
|
29 |
Thread.sleep((long) milis); |
|
30 |
synchronized (this) { |
|
31 |
if (finish) { |
|
32 |
break; |
|
33 |
} |
|
34 |
} |
|
35 |
} catch (InterruptedException e) { |
|
36 |
|
|
37 |
e.printStackTrace(); |
|
38 |
} |
|
39 |
//Updating |
|
40 |
Update(); |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
public synchronized void end() { |
|
45 |
finish = true; |
|
46 |
thread.stop(); |
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
private void Update() { |
|
51 |
// TODO Auto-generated method stub |
|
52 |
for (int i = 0; i < callBackList.size(); i++) { |
|
53 |
IUpdateCallBack element = (IUpdateCallBack) callBackList.get(i); |
|
54 |
element.update(); |
|
55 |
} |
|
56 |
|
|
57 |
} |
|
58 |
|
|
59 |
public void start(double milis) { |
|
60 |
this.milis = milis; |
|
61 |
|
|
62 |
// Create the thread supplying it with the runnable object |
|
63 |
thread = new Thread(this); |
|
64 |
|
|
65 |
// Start the thread |
|
66 |
thread.start(); |
|
67 |
} |
|
68 |
|
|
69 |
public void addCallBackObject(IUpdateCallBack object) { |
|
70 |
if (callBackList == null) |
|
71 |
callBackList = new ArrayList(); |
|
72 |
callBackList.add(object); |
|
73 |
} |
|
74 |
|
|
75 |
|
|
76 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/AnimationContainer.java | ||
---|---|---|
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.IPersistence; |
|
10 |
import com.iver.utiles.XMLEntity; |
|
11 |
|
|
12 |
public class AnimationContainer implements IPersistence { |
|
13 |
|
|
14 |
// IAnimationTrakc List |
|
15 |
public List AnimationTrackList; |
|
16 |
|
|
17 |
private String className; |
|
18 |
|
|
19 |
private static AnimationPlayer animationPlayer = new AnimationPlayer(); |
|
20 |
|
|
21 |
public AnimationContainer() { |
|
22 |
List aniTrackList = this.getAnimationTrackList(); |
|
23 |
aniTrackList = new ArrayList(); |
|
24 |
this.setAnimationTrackList(aniTrackList); |
|
25 |
} |
|
26 |
|
|
27 |
/** |
|
28 |
* @param animationType |
|
29 |
* @return |
|
30 |
*/ |
|
31 |
public List getTackListOfType(IAnimationType animationType) { |
|
32 |
List typeList = new ArrayList(); |
|
33 |
for (int i = 0; i < this.AnimationTrackList.size(); i++) { |
|
34 |
IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList |
|
35 |
.get(i); |
|
36 |
if (animationType.getClassName().equals( |
|
37 |
trackElement.getAnimationType().getClassName())) { |
|
38 |
typeList.add(trackElement); |
|
39 |
} |
|
40 |
|
|
41 |
} |
|
42 |
return typeList; |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* @param animationType |
|
47 |
* @return |
|
48 |
*/ |
|
49 |
public IAnimationTrack CreateDatedTrack(IAnimationType animationType) { |
|
50 |
|
|
51 |
List aniTrackList = this.getAnimationTrackList(); |
|
52 |
if (aniTrackList == null) { |
|
53 |
aniTrackList = new ArrayList(); |
|
54 |
} |
|
55 |
AnimationDatedTrack ADTrack = new AnimationDatedTrack(animationType); |
|
56 |
aniTrackList.add(ADTrack); |
|
57 |
this.setAnimationTrackList(aniTrackList); |
|
58 |
return ADTrack; |
|
59 |
} |
|
60 |
|
|
61 |
public IAnimationTrack CreateTimeTrack(IAnimationType animationType) { |
|
62 |
|
|
63 |
List aniTrackList = this.getAnimationTrackList(); |
|
64 |
if (aniTrackList == null) { |
|
65 |
aniTrackList = new ArrayList(); |
|
66 |
} |
|
67 |
AnimationTimeTrack ADTrack = new AnimationTimeTrack(animationType); |
|
68 |
aniTrackList.add(ADTrack); |
|
69 |
this.setAnimationTrackList(aniTrackList); |
|
70 |
return ADTrack; |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* @param animationTrack |
|
75 |
*/ |
|
76 |
public void addTrack(IAnimationTrack animationTrack) { |
|
77 |
IAnimationTrack track = findTrack(animationTrack.getName()); |
|
78 |
if (track == null) { |
|
79 |
this.AnimationTrackList.add(animationTrack); |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* @param name |
|
85 |
* @return |
|
86 |
*/ |
|
87 |
public IAnimationTrack findTrack(String name) { |
|
88 |
|
|
89 |
IAnimationTrack IAT = null; |
|
90 |
for (int i = 0; i < this.AnimationTrackList.size(); i++) { |
|
91 |
IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList |
|
92 |
.get(i); |
|
93 |
if (trackElement.getName().equals(name)) { |
|
94 |
IAT = trackElement; |
|
95 |
} |
|
96 |
|
|
97 |
} |
|
98 |
return IAT; |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* @param animationTrack |
|
103 |
*/ |
|
104 |
public void removeTrack(IAnimationTrack animationTrack) { |
|
105 |
animationTrack.removeAllIntervals(); |
|
106 |
this.AnimationTrackList.remove(animationTrack); |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* |
|
111 |
*/ |
|
112 |
public void removeAllTrack() { |
|
113 |
this.AnimationTrackList.clear(); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* @return |
|
118 |
*/ |
|
119 |
public List getAnimationTrackList() { |
|
120 |
return AnimationTrackList; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* @param animationTrackList |
|
125 |
*/ |
|
126 |
public void setAnimationTrackList(List animationTrackList) { |
|
127 |
AnimationTrackList = animationTrackList; |
|
128 |
} |
|
129 |
|
|
130 |
/* |
|
131 |
* IPersistance methods. |
|
132 |
*/ |
|
133 |
|
|
134 |
public String getClassName() { |
|
135 |
// TODO Auto-generated method stub |
|
136 |
return this.getClass().getName(); |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* @return |
|
141 |
*/ |
|
142 |
public XMLEntity getXMLEntity() { |
|
143 |
XMLEntity xml = new XMLEntity(); |
|
144 |
xml.putProperty("class_name", this.getClassName()); |
|
145 |
for (int i = 0; i < this.AnimationTrackList.size(); i++) { |
|
146 |
IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList.get(i); |
|
147 |
trackElement.getXMLEntity(); |
|
148 |
} |
|
149 |
return xml; |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* @param xml |
|
154 |
*/ |
|
155 |
public void setXMLEntity(XMLEntity xml) { |
|
156 |
if (xml.contains("class_name")) |
|
157 |
className = xml.getStringProperty("class_name"); |
|
158 |
for (int i = 0; i < this.AnimationTrackList.size(); i++) { |
|
159 |
IAnimationTrack trackElement = (IAnimationTrack) this.AnimationTrackList |
|
160 |
.get(i); |
|
161 |
trackElement.setXMLEntity(xml); |
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
public String toString() { |
|
166 |
String result = ""; |
|
167 |
List ATL = this.AnimationTrackList; |
|
168 |
result += "Mostrando lista de tracks:"; |
|
169 |
if ((ATL == null) || ATL.isEmpty()) { |
|
170 |
result += "\nLista vacia"; |
|
171 |
} else { |
|
172 |
for (int i = 0; i < ATL.size(); i++) { |
|
173 |
Object element = ATL.get(i); |
|
174 |
result += "\n" + element; |
|
175 |
} |
|
176 |
} |
|
177 |
return result; |
|
178 |
|
|
179 |
} |
|
180 |
|
|
181 |
public void apply(double Tini, double Tend) { |
|
182 |
List ATL = this.AnimationTrackList; |
|
183 |
System.out.println("Tiempo de inicio: " + Tini + " tiempo final " |
|
184 |
+ Tend); |
|
185 |
if ((ATL != null) && !ATL.isEmpty()) { |
|
186 |
for (int i = 0; i < ATL.size(); i++) { |
|
187 |
IAnimationTrack element = (IAnimationTrack) ATL.get(i); |
|
188 |
if (element.isEnable()) |
|
189 |
element.apply(Tini, Tend); |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
public AnimationPlayer getAnimationPlayer() { |
|
195 |
return this.animationPlayer; |
|
196 |
} |
|
197 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/dateFilter/DateFilter.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.dateFilter; |
|
2 |
|
|
3 |
import java.sql.Date; |
|
4 |
import java.text.ParseException; |
|
5 |
import java.text.SimpleDateFormat; |
|
6 |
import java.util.Calendar; |
|
7 |
|
|
8 |
import com.hardcode.gdbms.engine.values.DateValue; |
|
9 |
import com.hardcode.gdbms.engine.values.NullValue; |
|
10 |
import com.hardcode.gdbms.engine.values.Value; |
|
11 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
12 |
import com.iver.cit.gvsig.fmap.layers.ICustomVectorialFilter; |
|
13 |
import com.iver.utiles.IPersistance; |
|
14 |
import com.iver.utiles.XMLEntity; |
|
15 |
import com.sun.media.jai.opimage.AffineCRIF; |
|
16 |
|
|
17 |
public class DateFilter implements ICustomVectorialFilter, IPersistance { |
|
18 |
|
|
19 |
public static int FIELDTYPE_DATE = 0; |
|
20 |
public static int FIELDTYPE_DATESTRING = 1; |
|
21 |
|
|
22 |
public static int BOTH = 2 | 4; |
|
23 |
public static int BEFORE_BEGIN = 2; |
|
24 |
public static int AFTER_END = 4; |
|
25 |
|
|
26 |
private int fieldType = -1; |
|
27 |
|
|
28 |
private int filterFieldIndex = -1; |
|
29 |
private Date minDate = null; |
|
30 |
private Date maxDate = null; |
|
31 |
// derived |
|
32 |
private SimpleDateFormat localeDF = null; |
|
33 |
private SimpleDateFormat javaDF = null; |
|
34 |
private Calendar cl = null; |
|
35 |
|
|
36 |
private int filterMode = BEFORE_BEGIN; |
|
37 |
|
|
38 |
public void setFieldIndex(int index) { |
|
39 |
filterFieldIndex = index; |
|
40 |
} |
|
41 |
|
|
42 |
public void setFieldType(int type) { |
|
43 |
fieldType = type; |
|
44 |
} |
|
45 |
|
|
46 |
public void setMinDate(Date miniDate) { |
|
47 |
minDate = miniDate; |
|
48 |
} |
|
49 |
|
|
50 |
public void setMaxDate(Date maxiDate) { |
|
51 |
maxDate = maxiDate; |
|
52 |
} |
|
53 |
|
|
54 |
public int getFieldType() { |
|
55 |
return fieldType; |
|
56 |
} |
|
57 |
|
|
58 |
public Date getMinDate() { |
|
59 |
return minDate; |
|
60 |
} |
|
61 |
|
|
62 |
public Date getMaxDate() { |
|
63 |
return maxDate; |
|
64 |
} |
|
65 |
|
|
66 |
public boolean accepts(IFeature feature) { |
|
67 |
|
|
68 |
if (filterFieldIndex == -1 || minDate == null || maxDate == null) |
|
69 |
return false; |
|
70 |
|
|
71 |
Value val = feature.getAttribute(filterFieldIndex); |
|
72 |
if (val instanceof NullValue) |
|
73 |
return false; |
|
74 |
|
|
75 |
Date dateVal = null; |
|
76 |
if (fieldType == FIELDTYPE_DATE) { |
|
77 |
try { |
|
78 |
dateVal = ((DateValue) val).getValue(); |
|
79 |
} catch (RuntimeException e) { |
|
80 |
return false; |
|
81 |
} |
|
82 |
} else if (fieldType == FIELDTYPE_DATESTRING) { |
|
83 |
if (localeDF == null) |
|
84 |
localeDF = new SimpleDateFormat("dd/MM/yyyy"); |
|
85 |
if (javaDF == null) |
|
86 |
javaDF = new SimpleDateFormat("yyyy-MM-dd"); |
|
87 |
|
|
88 |
String valStr = val.toString(); |
|
89 |
|
|
90 |
try { |
|
91 |
java.util.Date utDate = localeDF.parse(valStr); // reads locale |
|
92 |
// dd/MM/yyyy |
|
93 |
// strings |
|
94 |
String utDateStr = javaDF.format(utDate); // outputs |
|
95 |
// yyyy-MM-dd |
|
96 |
dateVal = Date.valueOf(utDateStr); // creates Date for |
|
97 |
// comparison |
|
98 |
} catch (ParseException e) { |
|
99 |
return false; |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
try { |
|
104 |
String dateValStr = dateVal.toString(); |
|
105 |
String minDateStr = minDate.toString(); |
|
106 |
String maxDateStr = maxDate.toString(); |
|
107 |
|
|
108 |
if (((this.filterMode & BEFORE_BEGIN) != BEFORE_BEGIN)) |
|
109 |
if (dateVal.compareTo(minDate) < 0) |
|
110 |
return false; |
|
111 |
|
|
112 |
if (((this.filterMode & AFTER_END) != AFTER_END)) |
|
113 |
if (dateVal.compareTo(maxDate) > 0) |
|
114 |
return false; |
|
115 |
|
|
116 |
} catch (Exception e) { |
|
117 |
return false; |
|
118 |
} |
|
119 |
return true; |
|
120 |
} |
|
121 |
|
|
122 |
public String getClassName() { |
|
123 |
return this.getClass().getName(); |
|
124 |
} |
|
125 |
|
|
126 |
public XMLEntity getXMLEntity() { |
|
127 |
XMLEntity xml = new XMLEntity(); |
|
128 |
|
|
129 |
xml.putProperty("fieldType", fieldType); |
|
130 |
xml.putProperty("fieldIndex", filterFieldIndex); |
|
131 |
xml.putProperty("minDate", minDate.toString()); |
|
132 |
xml.putProperty("maxDate", maxDate.toString()); |
|
133 |
|
|
134 |
return xml; |
|
135 |
} |
|
136 |
|
|
137 |
public void setXMLEntity(XMLEntity xml) { |
|
138 |
if (xml.contains("fieldType")) |
|
139 |
fieldType = xml.getIntProperty("fieldType"); |
|
140 |
|
|
141 |
if (xml.contains("fieldIndex")) |
|
142 |
filterFieldIndex = xml.getIntProperty("fieldIndex"); |
|
143 |
|
|
144 |
if (xml.contains("minDate")) |
|
145 |
minDate = Date.valueOf(xml.getStringProperty("minDate")); |
|
146 |
|
|
147 |
if (xml.contains("maxDate")) |
|
148 |
maxDate = Date.valueOf(xml.getStringProperty("maxDate")); |
|
149 |
} |
|
150 |
|
|
151 |
public String toString() { |
|
152 |
String result = ""; |
|
153 |
|
|
154 |
result += minDate.toString() + "\n" + maxDate.toString(); |
|
155 |
|
|
156 |
return result; |
|
157 |
} |
|
158 |
|
|
159 |
public boolean compareTo(ICustomVectorialFilter filter) { |
|
160 |
DateFilter filterAux = (DateFilter) filter; |
|
161 |
boolean type = this.getFieldType() == filterAux.getFieldType(); |
|
162 |
boolean min = this.getMinDate().toString().equals( |
|
163 |
filterAux.getMinDate().toString()); |
|
164 |
boolean max = this.getMaxDate().toString().equals( |
|
165 |
filterAux.getMaxDate().toString()); |
|
166 |
|
|
167 |
return (type && min && max); |
|
168 |
} |
|
169 |
|
|
170 |
public int getFilterMode() { |
|
171 |
return filterMode; |
|
172 |
} |
|
173 |
|
|
174 |
public void setFilterMode(int filterMode) { |
|
175 |
this.filterMode = filterMode; |
|
176 |
} |
|
177 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/dateFilter/IndexFilter.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.dateFilter; |
|
2 |
|
|
3 |
import com.hardcode.gdbms.engine.values.NullValue; |
|
4 |
import com.hardcode.gdbms.engine.values.NumericValue; |
|
5 |
import com.hardcode.gdbms.engine.values.Value; |
|
6 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
7 |
import com.iver.cit.gvsig.fmap.layers.ICustomVectorialFilter; |
|
8 |
import com.iver.utiles.IPersistance; |
|
9 |
import com.iver.utiles.XMLEntity; |
|
10 |
|
|
11 |
public class IndexFilter implements ICustomVectorialFilter, IPersistance { |
|
12 |
|
|
13 |
private int filterFieldIndex=-1; |
|
14 |
private int minIndex = -1; |
|
15 |
private int maxIndex = -1; |
|
16 |
|
|
17 |
public void setFieldIndex(int index) { |
|
18 |
filterFieldIndex = index; |
|
19 |
} |
|
20 |
|
|
21 |
// if type is INTEGER, use these instead of setMinDate/setMaxDate |
|
22 |
// internally, the int value is used as year |
|
23 |
public void setMinIndex(int miniIndex) { |
|
24 |
minIndex = miniIndex; |
|
25 |
} |
|
26 |
|
|
27 |
public void setMaxIndex(int maxiIndex) { |
|
28 |
maxIndex = maxiIndex; |
|
29 |
} |
|
30 |
|
|
31 |
public boolean accepts(IFeature feature) { |
|
32 |
|
|
33 |
Value val = feature.getAttribute(filterFieldIndex); |
|
34 |
if (val instanceof NullValue) |
|
35 |
return false; |
|
36 |
|
|
37 |
if (!(val instanceof NumericValue)) |
|
38 |
return false; |
|
39 |
|
|
40 |
int intVal = ((NumericValue)val).intValue(); |
|
41 |
|
|
42 |
if (intVal < minIndex) |
|
43 |
return false; |
|
44 |
|
|
45 |
if (intVal > maxIndex) |
|
46 |
return false; |
|
47 |
|
|
48 |
return true; |
|
49 |
} |
|
50 |
|
|
51 |
public String getClassName() { |
|
52 |
return this.getClass().getName(); |
|
53 |
} |
|
54 |
|
|
55 |
public XMLEntity getXMLEntity() { |
|
56 |
XMLEntity xml = new XMLEntity(); |
|
57 |
|
|
58 |
xml.putProperty("fieldIndex", filterFieldIndex); |
|
59 |
xml.putProperty("minIndex", minIndex); |
|
60 |
xml.putProperty("maxIndex", maxIndex); |
|
61 |
|
|
62 |
return xml; |
|
63 |
} |
|
64 |
|
|
65 |
public void setXMLEntity(XMLEntity xml) { |
|
66 |
|
|
67 |
if (xml.contains("fieldIndex")) |
|
68 |
filterFieldIndex = xml.getIntProperty("fieldIndex"); |
|
69 |
|
|
70 |
if (xml.contains("minIndex")) |
|
71 |
minIndex = xml.getIntProperty("minIndex"); |
|
72 |
|
|
73 |
if (xml.contains("maxIndex")) |
|
74 |
maxIndex = xml.getIntProperty("maxIndex"); |
|
75 |
} |
|
76 |
|
|
77 |
public boolean compareTo(ICustomVectorialFilter filter) { |
|
78 |
IndexFilter filterAux = (IndexFilter) filter; |
|
79 |
|
|
80 |
return ((this.minIndex == filterAux.minIndex) && (this.maxIndex == filterAux.maxIndex)); |
|
81 |
} |
|
82 |
|
|
83 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/IAnimationTypeKeyFrame.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.keyframe; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
4 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
|
5 |
|
|
6 |
public interface IAnimationTypeKeyFrame extends IAnimationType{ |
|
7 |
|
|
8 |
public IInterpolator getInterpolator(); |
|
9 |
|
|
10 |
public void setInterpolator(IInterpolator interpolator); |
|
11 |
|
|
12 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/interpolator/FuntionFactory.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.keyframe.interpolator; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
|
|
7 |
/* |
|
8 |
* factoria para el registro y la creacion de funciones de animacion de tiempo |
|
9 |
* |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class FuntionFactory { |
|
13 |
|
|
14 |
// private static Map<String, IInterpolatorFuntion> objectsList; |
|
15 |
private static Map objectsList; |
|
16 |
|
|
17 |
static { |
|
18 |
// objectsList = new HashMap<String, IInterpolatorFuntion>(); |
|
19 |
objectsList = new HashMap(); |
|
20 |
LinearFuntion lf = new LinearFuntion(); |
|
21 |
lf.setName("LinearFuntion"); |
|
22 |
lf.setDescription("Funcion para el tiempo lineal"); |
|
23 |
FuntionFactory.register(lf); |
|
24 |
} |
|
25 |
|
|
26 |
public static void register(IInterpolatorFuntion funtion) { |
|
27 |
objectsList.put(funtion.getClassName(), funtion); |
|
28 |
} |
|
29 |
|
|
30 |
public static IInterpolatorFuntion createObject(String type) { |
|
31 |
IInterpolatorFuntion funtion = null; |
|
32 |
try { |
|
33 |
System.out.println("existe el tipo " + type + " " |
|
34 |
+ objectsList.containsKey(type)); |
|
35 |
if ((objectsList.containsKey(type)) == false) |
|
36 |
return null; |
|
37 |
// funtion = objectsList.get(type).getClass().newInstance(); |
|
38 |
funtion = (IInterpolatorFuntion) objectsList.get(type).getClass().newInstance(); |
|
39 |
} catch (InstantiationException e) { |
|
40 |
e.printStackTrace(); |
|
41 |
} catch (IllegalAccessException e) { |
|
42 |
e.printStackTrace(); |
|
43 |
} |
|
44 |
return funtion; |
|
45 |
} |
|
46 |
|
|
47 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/interpolator/IInterpolator.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.keyframe.interpolator; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame; |
|
6 |
|
|
7 |
public interface IInterpolator { |
|
8 |
|
|
9 |
public IKeyFrame interpolate(List kfList, int index, double time); |
|
10 |
|
|
11 |
public void setAnimatedObject(Object ani); |
|
12 |
|
|
13 |
public Object getAnimatedObject(); |
|
14 |
|
|
15 |
public void setFuntion(IInterpolatorFuntion funtion); |
|
16 |
|
|
17 |
public IInterpolatorFuntion getFuntion(); |
|
18 |
|
|
19 |
|
|
20 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/interpolator/LinearFuntion.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.keyframe.interpolator; |
|
2 |
|
|
3 |
|
|
4 |
public class LinearFuntion implements IInterpolatorFuntion { |
|
5 |
|
|
6 |
private String name; |
|
7 |
private String description; |
|
8 |
|
|
9 |
public String getName() { |
|
10 |
return name; |
|
11 |
} |
|
12 |
|
|
13 |
public void setName(String name) { |
|
14 |
this.name = name; |
|
15 |
} |
|
16 |
|
|
17 |
public String getClassName() { |
|
18 |
return this.getClass().getName(); |
|
19 |
} |
|
20 |
|
|
21 |
public String getDescription() { |
|
22 |
return this.description; |
|
23 |
} |
|
24 |
|
|
25 |
public void setDescription(String name) { |
|
26 |
this.description = name; |
|
27 |
} |
|
28 |
|
|
29 |
public double interpolate(double T) { |
|
30 |
return T*T; |
|
31 |
} |
|
32 |
|
|
33 |
public double[] interpolate(double[] T) { |
|
34 |
return T; |
|
35 |
} |
|
36 |
|
|
37 |
public IInterpolatorFuntion create() { |
|
38 |
return this; |
|
39 |
} |
|
40 |
|
|
41 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/interpolator/IInterpolatorFuntion.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.keyframe.interpolator; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
public interface IInterpolatorFuntion { |
|
6 |
|
|
7 |
// Identification of the class |
|
8 |
public void setName(String name); |
|
9 |
|
|
10 |
public void setDescription(String name); |
|
11 |
|
|
12 |
public String getName(); |
|
13 |
|
|
14 |
public String getDescription(); |
|
15 |
|
|
16 |
public String getClassName(); |
|
17 |
|
|
18 |
// Interpolation funcion |
|
19 |
public double interpolate(double T); |
|
20 |
|
|
21 |
public double[] interpolate(double T[]); |
|
22 |
|
|
23 |
public IInterpolatorFuntion create(); |
|
24 |
|
|
25 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/AnimationFunction.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.keyframe; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.iver.utiles.IPersistence; |
|
6 |
import com.iver.utiles.XMLEntity; |
|
7 |
|
|
8 |
public class AnimationFunction implements IPersistence{ |
|
9 |
|
|
10 |
private List AnimationFunctionList; |
|
11 |
private String className; |
|
12 |
|
|
13 |
//private AnimationFunction animationFunctionItem; |
|
14 |
|
|
15 |
public List getAnimationFuntionList() { |
|
16 |
return AnimationFunctionList; |
|
17 |
} |
|
18 |
|
|
19 |
public void setAnimationFuntionList(List animationFuntionList) { |
|
20 |
AnimationFunctionList = animationFuntionList; |
|
21 |
} |
|
22 |
|
|
23 |
public String toString() { |
|
24 |
|
|
25 |
String result = ""; |
|
26 |
|
|
27 |
return result; |
|
28 |
} |
|
29 |
|
|
30 |
|
|
31 |
public String getClassName() { |
|
32 |
// TODO Auto-generated method stub |
|
33 |
return this.getClass().getName(); |
|
34 |
} |
|
35 |
|
|
36 |
|
|
37 |
public XMLEntity getXMLEntity() { |
|
38 |
// TODO Auto-generated method stub |
|
39 |
XMLEntity xml = new XMLEntity(); |
|
40 |
|
|
41 |
xml.putProperty("class_name", this.getClassName()); |
|
42 |
for (int i = 0; i < this.AnimationFunctionList.size(); i++) { |
|
43 |
AnimationFunction animationFunctionItem = (AnimationFunction) this.AnimationFunctionList.get(i); |
|
44 |
return null;//provisional |
|
45 |
} |
|
46 |
return null; |
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
public void setXMLEntity(XMLEntity xml) { |
|
51 |
// TODO Auto-generated method stub |
|
52 |
|
|
53 |
if (xml.contains("class_name")) |
|
54 |
className = xml.getStringProperty("class_name"); |
|
55 |
for (int i = 0; i < this.AnimationFunctionList.size(); i++) { |
|
56 |
AnimationFunction animationFunctionItem = (AnimationFunction) this.AnimationFunctionList.get(i); |
|
57 |
return; //provisional |
|
58 |
} |
|
59 |
|
|
60 |
} |
|
61 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/keyframe/IKeyFrame.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.keyframe; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.iver.utiles.IPersistence; |
|
6 |
|
|
7 |
public interface IKeyFrame extends IPersistence { |
|
8 |
|
|
9 |
public void setName(String name); |
|
10 |
public String getName(); |
|
11 |
|
|
12 |
public void setTime(double time); |
|
13 |
public double getTime(); |
|
14 |
|
|
15 |
public void setPropertiesList(List list); |
|
16 |
public List getPropertiesList(); |
|
17 |
|
|
18 |
public void CapturesProperties(); |
|
19 |
public void Interpolate(Object p1,Object p2, double time); |
|
20 |
public void Apply(double Tini); |
|
21 |
|
|
22 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/interval/AnimationKeyFrameInterval.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.interval; |
|
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 |
|
|
8 |
import com.iver.cit.gvsig.animation.keyframe.IAnimationTypeKeyFrame; |
|
9 |
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame; |
|
10 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
|
11 |
import com.iver.cit.gvsig.project.ProjectExtent; |
|
12 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
|
13 |
import com.iver.utiles.XMLEntity; |
|
14 |
|
|
15 |
public class AnimationKeyFrameInterval implements IAnimationTimeInterval { |
|
16 |
|
|
17 |
private List KeyFrameList; |
|
18 |
|
|
19 |
private double initialTime = 0; |
|
20 |
|
|
21 |
private double endTime = 1; |
|
22 |
|
|
23 |
private double intervalTime = endTime - initialTime; |
|
24 |
|
|
25 |
private String className; |
|
26 |
|
|
27 |
public List getKeyFrameList() { |
|
28 |
return KeyFrameList; |
|
29 |
} |
|
30 |
|
|
31 |
public void setKeyFrameList(List keyFrameList) { |
|
32 |
KeyFrameList = keyFrameList; |
|
33 |
} |
|
34 |
|
|
35 |
public double getEndTime() { |
|
36 |
return endTime; |
|
37 |
} |
|
38 |
|
|
39 |
public double getInitialTime() { |
|
40 |
return initialTime; |
|
41 |
} |
|
42 |
|
|
43 |
public double getIntervalTime() { |
|
44 |
return (endTime - initialTime); |
|
45 |
} |
|
46 |
|
|
47 |
public void setEndTime(double time) { |
|
48 |
this.endTime = time; |
|
49 |
|
|
50 |
} |
|
51 |
|
|
52 |
public void setInitialTime(double time) { |
|
53 |
this.initialTime = time; |
|
54 |
} |
|
55 |
|
|
56 |
public void setIntervalTime(double time) { |
|
57 |
this.intervalTime = time; |
|
58 |
} |
|
59 |
|
|
60 |
public String toString() { |
|
61 |
|
|
62 |
String result; |
|
63 |
List KFL = this.KeyFrameList; |
|
64 |
if (KFL != null) { |
|
65 |
result = "Mostrando lista de KeyFrames del intervalo Tini:" |
|
66 |
+ this.getInitialTime() + " Tend" + this.getEndTime(); |
|
67 |
for (Iterator iter = KFL.iterator(); iter.hasNext();) { |
|
68 |
Object element = (Object) iter.next(); |
|
69 |
result += "\n" + element; |
|
70 |
} |
|
71 |
} else { |
|
72 |
result = "Lista de key frame vacia"; |
|
73 |
} |
|
74 |
return result; |
|
75 |
} |
|
76 |
|
|
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 |
boolean asigned = false; |
|
93 |
if (KFtime <= tini) { |
|
94 |
if (previus != null) { |
|
95 |
if (KFtime > previus.getTime()) |
|
96 |
previus = element; |
|
97 |
} else { |
|
98 |
previus = element; |
|
99 |
} |
|
100 |
asigned = true; |
|
101 |
} |
|
102 |
if ((KFtime > tini) && (!asigned)) { |
|
103 |
if (next != null) { |
|
104 |
if (KFtime < previus.getTime()) |
|
105 |
next = element; |
|
106 |
} else { |
|
107 |
next = element; |
|
108 |
} |
|
109 |
|
|
110 |
} |
|
111 |
|
|
112 |
} |
|
113 |
KFLInterpolate.add(previus); |
|
114 |
KFLInterpolate.add(next); |
|
115 |
} |
|
116 |
|
|
117 |
IKeyFrame frame = null; |
|
118 |
if (KFLInterpolate != null) { |
|
119 |
// IInterpolator in = (IInterpolator) interpolator; |
|
120 |
frame = interpolator.interpolate(KFLInterpolate, 0, tini); |
|
121 |
} |
|
122 |
if (frame != null) |
|
123 |
animationType.AppliesToObject(frame); |
|
124 |
|
|
125 |
} |
|
126 |
|
|
127 |
public XMLEntity getXMLEntity() { |
|
128 |
// TODO Auto-generated method stub |
|
129 |
XMLEntity xml = new XMLEntity(); |
|
130 |
|
|
131 |
xml.putProperty("class_name", this.getClassName()); |
|
132 |
xml.putProperty("begin_time", initialTime); |
|
133 |
xml.putProperty("end_time", endTime); |
|
134 |
xml.putProperty("interval_time", intervalTime); |
|
135 |
|
|
136 |
/* for (int i = 0; i < this.KeyFrameList.size(); i++) { |
|
137 |
IKeyFrame keyFrameItem = (IKeyFrame) this.KeyFrameList.get(i); |
|
138 |
keyFrameItem.getXMLEntity(); |
|
139 |
} */ |
|
140 |
return xml; |
|
141 |
|
|
142 |
} |
|
143 |
|
|
144 |
public void setXMLEntity(XMLEntity xml) { |
|
145 |
// TODO Auto-generated method stub |
|
146 |
|
|
147 |
if (xml.contains("class_name")) |
|
148 |
className= xml.getStringProperty("class_name"); |
|
149 |
if (xml.contains("begin_time")) |
|
150 |
initialTime = xml.getDoubleProperty("begin_time"); |
|
151 |
if (xml.contains("end_time")) |
|
152 |
endTime = xml.getDoubleProperty("end_time"); |
|
153 |
if (xml.contains("interval_time")) |
|
154 |
intervalTime = xml.getDoubleProperty("interval_time"); |
|
155 |
|
|
156 |
/* for (int i = 0; i < this.KeyFrameList.size(); i++) { |
|
157 |
IKeyFrame keyFrameItem = (IKeyFrame) this.KeyFrameList.get(i); |
|
158 |
keyFrameItem.setXMLEntity(xml); |
|
159 |
}*/ |
|
160 |
|
|
161 |
} |
|
162 |
|
|
163 |
public String getClassName() { |
|
164 |
// TODO Auto-generated method stub |
|
165 |
return this.getClass().getName(); |
|
166 |
} |
|
167 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/interval/AnimationFunctionInterval.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.interval; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
4 |
import com.iver.cit.gvsig.animation.keyframe.AnimationFunction; |
|
5 |
import com.iver.utiles.XMLEntity; |
|
6 |
|
|
7 |
public class AnimationFunctionInterval implements IAnimationTimeInterval { |
|
8 |
|
|
9 |
//private List animationFuncionList; |
|
10 |
private AnimationFunction animationFunctionItem; |
|
11 |
|
|
12 |
private double initialTime = 0; |
|
13 |
|
|
14 |
private double endTime = 1; |
|
15 |
|
|
16 |
private double intervalTime = endTime - initialTime; |
|
17 |
|
|
18 |
private String className; |
|
19 |
|
|
20 |
public AnimationFunction getAnimationFuncionItem() { |
|
21 |
return animationFunctionItem; |
|
22 |
} |
|
23 |
|
|
24 |
public void setAnimationFuncionList(AnimationFunction animationFuncionItem) { |
|
25 |
this.animationFunctionItem = animationFuncionItem; |
|
26 |
} |
|
27 |
|
|
28 |
public double getEndTime() { |
|
29 |
return this.endTime; |
|
30 |
} |
|
31 |
|
|
32 |
public double getInitialTime() { |
|
33 |
return this.initialTime; |
|
34 |
} |
|
35 |
|
|
36 |
public double getIntervalTime() { |
|
37 |
return endTime - initialTime; |
|
38 |
} |
|
39 |
|
|
40 |
public void setEndTime(double time) { |
|
41 |
this.endTime = time; |
|
42 |
|
|
43 |
} |
|
44 |
|
|
45 |
public void setInitialTime(double time) { |
|
46 |
this.initialTime = time; |
|
47 |
} |
|
48 |
|
|
49 |
public void setIntervalTime(double time) { |
|
50 |
this.intervalTime = time; |
|
51 |
} |
|
52 |
|
|
53 |
public String toString() { |
|
54 |
|
|
55 |
String result; |
|
56 |
//List AFL = this.animationFuncionList; |
|
57 |
result = "Mostrando lista de funciones de animacion del intervalo Tini:" |
|
58 |
+ this.getInitialTime() + " Tend" + this.getEndTime(); |
|
59 |
|
|
60 |
result+= this.animationFunctionItem; // ESTO NO SE SI ES ASI |
|
61 |
|
|
62 |
// for (Iterator iter = AFL.iterator(); iter.hasNext();) { |
|
63 |
// Object element = (Object) iter.next(); |
|
64 |
// result += "\n" + element; |
|
65 |
// } |
|
66 |
return result; |
|
67 |
} |
|
68 |
|
|
69 |
public void apply(double tini, double tend, IAnimationType animationType, |
|
70 |
Object animated) { |
|
71 |
// TODO Auto-generated method stub |
|
72 |
} |
|
73 |
|
|
74 |
public String getClassName() { |
|
75 |
// TODO Auto-generated method stub |
|
76 |
return this.getClass().getName(); |
|
77 |
} |
|
78 |
|
|
79 |
|
|
80 |
public XMLEntity getXMLEntity() { |
|
81 |
// TODO Auto-generated method stub |
|
82 |
XMLEntity xml = new XMLEntity(); |
|
83 |
xml.putProperty("class_name", this.getClassName()); |
|
84 |
xml.putProperty("begin_time", initialTime); |
|
85 |
xml.putProperty("end_time", endTime); |
|
86 |
xml.putProperty("interval_time", intervalTime); |
|
87 |
//this.animationFunctionItem.getXMLEntity(); |
|
88 |
|
|
89 |
return xml; |
|
90 |
} |
|
91 |
|
|
92 |
|
|
93 |
public void setXMLEntity(XMLEntity xml) { |
|
94 |
// TODO Auto-generated method stub |
|
95 |
if (xml.contains("class_name")) |
|
96 |
className= xml.getStringProperty("class_name"); |
|
97 |
if (xml.contains("begin_time")) |
|
98 |
initialTime = xml.getDoubleProperty("begin_time"); |
|
99 |
if (xml.contains("end_time")) |
|
100 |
endTime = xml.getDoubleProperty("end_time"); |
|
101 |
if (xml.contains("interval_time")) |
|
102 |
intervalTime = xml.getDoubleProperty("interval_time"); |
|
103 |
//this.animationFunctionItem.setXMLEntity(xml); |
|
104 |
|
|
105 |
} |
|
106 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/interval/IAnimationTimeInterval.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.interval; |
|
2 |
|
|
3 |
import com.iver.utiles.IPersistence; |
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
public interface IAnimationTimeInterval extends IAnimationInterval, IPersistence { |
|
8 |
|
|
9 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/interval/IAnimationInterval.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.interval; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
4 |
|
|
5 |
public interface IAnimationInterval { |
|
6 |
|
|
7 |
public double getIntervalTime(); |
|
8 |
|
|
9 |
public void setIntervalTime(double time); |
|
10 |
|
|
11 |
public double getInitialTime(); |
|
12 |
|
|
13 |
public void setInitialTime(double time); |
|
14 |
|
|
15 |
public double getEndTime(); |
|
16 |
|
|
17 |
public void setEndTime(double time); |
|
18 |
|
|
19 |
public void apply(double tini, double tend, IAnimationType animationType, |
|
20 |
Object animated); |
|
21 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/interval/AnimationDatedInterval.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.interval; |
|
2 |
|
|
3 |
import java.sql.Date; |
|
4 |
import java.text.SimpleDateFormat; |
|
5 |
import java.util.Calendar; |
|
6 |
import java.util.Locale; |
|
7 |
|
|
8 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
9 |
import com.iver.cit.gvsig.animation.dateFilter.DateFilter; |
|
10 |
import com.iver.utiles.DateTime; |
|
11 |
import com.iver.utiles.IPersistence; |
|
12 |
import com.iver.utiles.XMLEntity; |
|
13 |
|
|
14 |
public class AnimationDatedInterval implements IAnimationInterval, IPersistence { |
|
15 |
|
|
16 |
private Date beginDateInterval; |
|
17 |
|
|
18 |
private Date endDateInterval; |
|
19 |
|
|
20 |
private String beginDateString = new String(); |
|
21 |
|
|
22 |
private String endDateString = new String(); |
|
23 |
|
|
24 |
private String sFormat = new String("Y-m-d"); |
|
25 |
|
|
26 |
private String className; |
|
27 |
|
|
28 |
static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
29 |
|
|
30 |
public Date getBeginDateInterval() { |
|
31 |
return beginDateInterval; |
|
32 |
} |
|
33 |
|
|
34 |
public void setBeginDateInterval(Date beginDateInterval) { |
|
35 |
this.beginDateInterval = beginDateInterval; |
|
36 |
} |
|
37 |
|
|
38 |
public Date getEndDateInterval() { |
|
39 |
return endDateInterval; |
|
40 |
} |
|
41 |
|
|
42 |
public void setEndDateInterval(Date endDateInterval) { |
|
43 |
this.endDateInterval = endDateInterval; |
|
44 |
} |
|
45 |
|
|
46 |
public String toString() { |
|
47 |
String result = "Intervalo de " + this.beginDateInterval + " a " |
|
48 |
+ this.endDateInterval; |
|
49 |
return result; |
|
50 |
} |
|
51 |
|
|
52 |
public double getEndTime() { |
|
53 |
return this.endDateInterval.getTime(); |
|
54 |
} |
|
55 |
|
|
56 |
public double getInitialTime() { |
|
57 |
return this.beginDateInterval.getTime(); |
|
58 |
} |
|
59 |
|
|
60 |
public double getIntervalTime() { |
|
61 |
return (this.endDateInterval.getTime() - this.beginDateInterval |
|
62 |
.getTime()); |
|
63 |
} |
|
64 |
|
|
65 |
public void setEndTime(double time) { |
|
66 |
this.endDateInterval.setTime((long) time); |
|
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
public void setInitialTime(double time) { |
|
71 |
this.beginDateInterval.setTime((long) time); |
|
72 |
|
|
73 |
} |
|
74 |
|
|
75 |
public void setIntervalTime(double time) { |
|
76 |
// TODO generate method to calculate interval time |
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
public void apply(double tini, double tend, IAnimationType animationType, |
|
81 |
Object animated) { |
|
82 |
// falta completar la funcion |
|
83 |
// System.out.println("PINTANDO OBJETO"); |
|
84 |
// System.out.println("milisegundos del inicio del intervalo " |
|
85 |
// + this.dateToSeconds(this.getBeginDateInterval())); |
|
86 |
|
|
87 |
int day1 = this.getBeginDateInterval().getDate(); |
|
88 |
int day2 = this.getEndDateInterval().getDate(); |
|
89 |
int result = linearInterpolate(day1, day2, 0.0, 1.0, tini); |
|
90 |
// System.out.println("fecha resultante " + result); |
|
91 |
int min = (int) (result - 1); |
|
92 |
// System.out.println("fehca minima " + "2000-01-" + min ); |
|
93 |
int max = (int) (result + 1); |
|
94 |
// System.out.println("fehca minima " + "2000-01-" + max ); |
|
95 |
|
|
96 |
DateFilter filter = new DateFilter(); |
|
97 |
filter.setFieldIndex(0); // Date field in com_aut data sample |
|
98 |
filter.setFieldType(DateFilter.FIELDTYPE_DATESTRING); |
|
99 |
// filter.setMinDate(Date.valueOf("2000-01-1")); |
|
100 |
filter.setMinDate(Date.valueOf("2000-01-" + min)); |
|
101 |
filter.setMaxDate(Date.valueOf("2000-01-" + max)); |
|
102 |
|
|
103 |
animationType.AppliesToObject(filter); |
|
104 |
|
|
105 |
} |
|
106 |
|
|
107 |
private int linearInterpolate(int minX, int minX2, double timePos, |
|
108 |
double timePos2, double time) { |
|
109 |
// P1 + (P2-P1)*((t-t1)/(t2-t1)) |
|
110 |
|
|
111 |
double result = ((minX + (minX2 - minX)) * time); |
|
112 |
|
|
113 |
return (int) Math.ceil(result); |
|
114 |
} |
|
115 |
|
|
116 |
private double dateToSeconds(Date date) { |
|
117 |
Calendar ca = Calendar.getInstance(Locale.US); |
|
118 |
ca.setTime(date); |
|
119 |
return ca.getTimeInMillis(); |
|
120 |
} |
|
121 |
|
|
122 |
/* |
|
123 |
* IPersistance methods. |
|
124 |
*/ |
|
125 |
|
|
126 |
public String getClassName() { |
|
127 |
// TODO Auto-generated method stub |
|
128 |
return null; |
|
129 |
} |
|
130 |
|
|
131 |
public XMLEntity getXMLEntity() { |
|
132 |
|
|
133 |
XMLEntity xml = new XMLEntity(); |
|
134 |
xml.putProperty("className", this.getClassName()); |
|
135 |
// xml.putProperty("beginDateInterval", beginDateString); |
|
136 |
// xml.putProperty("endDateInterval", endDateString); |
|
137 |
|
|
138 |
beginDateString = DateTime.dateToString(beginDateInterval, sFormat); |
|
139 |
endDateString = DateTime.dateToString(endDateInterval, sFormat); |
|
140 |
|
|
141 |
xml.putProperty("begin_date", beginDateString); |
|
142 |
xml.putProperty("end_date", endDateString); |
|
143 |
|
|
144 |
return xml; |
|
145 |
} |
|
146 |
|
|
147 |
public void setXMLEntity(XMLEntity xml) { |
|
148 |
|
|
149 |
if (xml.contains("class_name")) |
|
150 |
className = xml.getStringProperty("class_name"); |
|
151 |
if (xml.contains("begin_date")) |
|
152 |
beginDateString = xml.getStringProperty("begin_date"); |
|
153 |
if (xml.contains("end_date")) |
|
154 |
endDateString = xml.getStringProperty("end_date"); |
|
155 |
|
|
156 |
} |
|
157 |
} |
import/ext3D/branches/ext3D_v1.1/libraries/libAnimation/src/com/iver/cit/gvsig/animation/traks/IAnimationTrack.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.animation.traks; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
6 |
import com.iver.cit.gvsig.animation.interval.IAnimationInterval; |
|
7 |
import com.iver.utiles.IPersistence; |
|
8 |
|
|
9 |
public interface IAnimationTrack extends IPersistence{ |
|
10 |
|
|
11 |
// class information |
|
12 |
public String getName(); |
|
13 |
|
|
14 |
public String getDescription(); |
|
15 |
|
|
16 |
public boolean isEnable(); |
|
17 |
|
|
18 |
public void setEnabale(boolean enable); |
|
19 |
|
|
20 |
public IAnimationType getAnimationType(); |
|
21 |
|
|
22 |
// Interval methods |
|
23 |
public List getIntervalList(); |
|
24 |
|
|
25 |
public void setIntervalList(List intervalList); |
|
26 |
|
Also available in: Unified diff