Revision 15456 import/ext3D/branches/ext3D_v1.1/libAnimation/src/com/iver/cit/gvsig/animation/interval/AnimationDatedInterval.java
AnimationDatedInterval.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.animation.interval; |
2 | 2 |
|
3 | 3 |
import java.sql.Date; |
4 |
import java.sql.SQLClientInfoException; |
|
4 | 5 |
import java.text.SimpleDateFormat; |
6 |
import java.util.Calendar; |
|
7 |
import java.util.GregorianCalendar; |
|
8 |
import java.util.Locale; |
|
9 |
|
|
10 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
11 |
import com.iver.cit.gvsig.animation.dateFilter.DateFilter; |
|
5 | 12 |
import com.iver.utiles.DateTime; |
6 |
import com.iver.cit.gvsig.animation.IAnimationType; |
|
7 |
|
|
8 | 13 |
import com.iver.utiles.IPersistance; |
9 | 14 |
import com.iver.utiles.XMLEntity; |
10 | 15 |
|
... | ... | |
13 | 18 |
private Date beginDateInterval; |
14 | 19 |
|
15 | 20 |
private Date endDateInterval; |
16 |
|
|
17 |
private String beginDateString = new String();
|
|
18 |
|
|
21 |
|
|
22 |
private String beginDateString = new String();
|
|
23 |
|
|
19 | 24 |
private String endDateString = new String(); |
20 | 25 |
|
21 |
private String sFormat = new String( "Y-m-d" );
|
|
26 |
private String sFormat = new String("Y-m-d");
|
|
22 | 27 |
|
23 | 28 |
private String className; |
24 |
|
|
25 |
static final SimpleDateFormat sdf = new SimpleDateFormat( "dd/MM/yyyy" ); |
|
26 |
|
|
27 | 29 |
|
30 |
static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
31 |
|
|
28 | 32 |
public Date getBeginDateInterval() { |
29 | 33 |
return beginDateInterval; |
30 | 34 |
} |
... | ... | |
75 | 79 |
|
76 | 80 |
} |
77 | 81 |
|
78 |
public void Apply(double tini, double tend, IAnimationType animationType, Object animated) { |
|
79 |
// TODO Auto-generated method stub |
|
80 |
|
|
82 |
public void apply(double tini, double tend, IAnimationType animationType, |
|
83 |
Object animated) { |
|
84 |
// falta completar la funcion |
|
85 |
// System.out.println("PINTANDO OBJETO"); |
|
86 |
// System.out.println("milisegundos del inicio del intervalo " |
|
87 |
// + this.dateToSeconds(this.getBeginDateInterval())); |
|
88 |
|
|
89 |
int day1 = this.getBeginDateInterval().getDate(); |
|
90 |
int day2 = this.getEndDateInterval().getDate(); |
|
91 |
int result = linearInterpolate(day1, day2, 0.0, 1.0, tini); |
|
92 |
// System.out.println("fecha resultante " + result); |
|
93 |
int min = (int) (result - 1); |
|
94 |
// System.out.println("fehca minima " + "2000-01-" + min ); |
|
95 |
int max = (int) (result + 1); |
|
96 |
// System.out.println("fehca minima " + "2000-01-" + max ); |
|
97 |
|
|
98 |
DateFilter filter = new DateFilter(); |
|
99 |
filter.setFieldIndex(0); // Date field in com_aut data sample |
|
100 |
filter.setFieldType(DateFilter.FIELDTYPE_DATESTRING); |
|
101 |
// filter.setMinDate(Date.valueOf("2000-01-1")); |
|
102 |
filter.setMinDate(Date.valueOf("2000-01-" + min)); |
|
103 |
filter.setMaxDate(Date.valueOf("2000-01-" + max)); |
|
104 |
|
|
105 |
animationType.AppliesToObject(filter); |
|
106 |
|
|
81 | 107 |
} |
82 | 108 |
|
83 |
public void apply(double tini, double tend, IAnimationType animationType, Object animated) { |
|
84 |
// falta completar la funcion |
|
85 |
System.out.println("PINTANDO OBJETO"); |
|
86 |
// animationType.AppliesToObject(animated); |
|
87 |
|
|
109 |
private int linearInterpolate(int minX, int minX2, double timePos, |
|
110 |
double timePos2, double time) { |
|
111 |
// P1 + (P2-P1)*((t-t1)/(t2-t1)) |
|
112 |
|
|
113 |
double result = ((minX + (minX2 - minX)) * time); |
|
114 |
|
|
115 |
return (int) Math.ceil(result); |
|
88 | 116 |
} |
89 | 117 |
|
90 |
|
|
91 |
/* |
|
118 |
private double dateToSeconds(Date date) { |
|
119 |
Calendar ca = Calendar.getInstance(Locale.US); |
|
120 |
ca.setTime(date); |
|
121 |
return ca.getTimeInMillis(); |
|
122 |
} |
|
123 |
|
|
124 |
/* |
|
92 | 125 |
* IPersistance methods. |
93 | 126 |
*/ |
94 | 127 |
|
... | ... | |
96 | 129 |
// TODO Auto-generated method stub |
97 | 130 |
return null; |
98 | 131 |
} |
99 |
|
|
132 |
|
|
100 | 133 |
public XMLEntity getXMLEntity() { |
101 |
|
|
134 |
|
|
102 | 135 |
XMLEntity xml = new XMLEntity(); |
103 |
xml.putProperty("className", this.getClassName());
|
|
104 |
// xml.putProperty("beginDateInterval", beginDateString);
|
|
105 |
// xml.putProperty("endDateInterval", endDateString);
|
|
106 |
|
|
136 |
xml.putProperty("className", this.getClassName()); |
|
137 |
// xml.putProperty("beginDateInterval", beginDateString);
|
|
138 |
// xml.putProperty("endDateInterval", endDateString);
|
|
139 |
|
|
107 | 140 |
beginDateString = DateTime.dateToString(beginDateInterval, sFormat); |
108 | 141 |
endDateString = DateTime.dateToString(endDateInterval, sFormat); |
109 |
|
|
142 |
|
|
110 | 143 |
xml.putProperty("begin_date", beginDateString); |
111 | 144 |
xml.putProperty("end_date", endDateString); |
112 |
|
|
113 |
|
|
145 |
|
|
114 | 146 |
return xml; |
115 | 147 |
} |
116 | 148 |
|
117 | 149 |
public void setXMLEntity(XMLEntity xml) { |
118 |
|
|
119 |
|
|
150 |
|
|
120 | 151 |
if (xml.contains("class_name")) |
121 |
className = xml.getStringProperty("class_name");
|
|
152 |
className = xml.getStringProperty("class_name");
|
|
122 | 153 |
if (xml.contains("begin_date")) |
123 | 154 |
beginDateString = xml.getStringProperty("begin_date"); |
124 | 155 |
if (xml.contains("end_date")) |
125 | 156 |
endDateString = xml.getStringProperty("end_date"); |
126 |
|
|
157 |
|
|
127 | 158 |
} |
128 | 159 |
} |
Also available in: Unified diff