Revision 43610
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.timesupport/org.gvsig.timesupport.swing/org.gvsig.timesupport.swing.api/src/main/java/org/gvsig/timesupport/swing/api/panel/TimeSelectorPanel.java | ||
---|---|---|
52 | 52 |
*/ |
53 | 53 |
public abstract void initialize(Interval interval); |
54 | 54 |
|
55 |
/* |
|
56 |
* Set the selected time |
|
57 |
* @param time |
|
58 |
* the time to select |
|
59 |
* |
|
60 |
public abstract void setSeletedTime(Time start); |
|
61 |
|
|
62 |
/** |
|
63 |
* @return |
|
64 |
* the selected time |
|
65 |
* |
|
66 |
public abstract Time getSelectedTime();*/ |
|
67 |
|
|
68 | 55 |
/** |
69 | 56 |
* Set valid instants |
57 |
* @param instants |
|
70 | 58 |
*/ |
71 | 59 |
public abstract void setInstants(List<Instant> instants); |
72 | 60 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.timesupport/org.gvsig.timesupport.swing/org.gvsig.timesupport.swing.impl/src/main/java/org/gvsig/timesupport/swing/impl/panel/TimePanel.java | ||
---|---|---|
18 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
19 | 19 |
* MA 02110-1301, USA. |
20 | 20 |
* |
21 |
*/ |
|
21 |
*/
|
|
22 | 22 |
|
23 |
/* |
|
23 |
/*
|
|
24 | 24 |
* AUTHORS (In addition to CIT): |
25 | 25 |
* 2010 {Prodevelop} {Task} |
26 |
*/ |
|
26 |
*/
|
|
27 | 27 |
package org.gvsig.timesupport.swing.impl.panel; |
28 | 28 |
|
29 |
|
|
30 | 29 |
import java.awt.Component; |
31 | 30 |
import java.util.List; |
32 | 31 |
|
33 | 32 |
import javax.swing.BoxLayout; |
34 | 33 |
import javax.swing.JPanel; |
34 |
import org.apache.commons.collections4.CollectionUtils; |
|
35 | 35 |
|
36 | 36 |
import org.gvsig.i18n.Messages; |
37 | 37 |
import org.gvsig.timesupport.AbsoluteInstant; |
... | ... | |
48 | 48 |
import org.gvsig.timesupport.swing.impl.rdv.TimeAdjustmentListener; |
49 | 49 |
import org.gvsig.timesupport.swing.impl.rdv.TimeEvent; |
50 | 50 |
import org.gvsig.timesupport.swing.impl.rdv.TimeSlider; |
51 |
|
|
51 | 52 |
/** |
52 | 53 |
* Window main panel (control Relative and Absolute time instances) |
54 |
* |
|
53 | 55 |
* @author <a href="mailto:Pablo.Viciano@uji.es">Pablo Viciano Negre</a> |
54 | 56 |
* @version $Id$ |
55 | 57 |
* |
56 | 58 |
*/ |
57 | 59 |
public class TimePanel extends JPanel implements TimeAdjustmentListener { |
60 |
|
|
58 | 61 |
private static final long serialVersionUID = -1711925095164453822L; |
62 |
|
|
59 | 63 |
/** |
60 | 64 |
* Time mode {Relative or absolute} |
61 | 65 |
*/ |
62 |
public static enum TIME_MODE {RELATIVE, ABSOLUTE}; |
|
66 |
public static enum TIME_MODE { |
|
67 |
RELATIVE, ABSOLUTE |
|
68 |
}; |
|
63 | 69 |
private TIME_MODE _mode; |
64 | 70 |
private TimeSlider slider = null; |
65 | 71 |
private ITemporalComponent jComponentStart = null; |
... | ... | |
77 | 83 |
private Instant instAux = null; |
78 | 84 |
private boolean updateSlider = false; |
79 | 85 |
private static TimeSupportManager timeSupportManager = TimeSupportLocator |
80 |
.getManager(); |
|
86 |
.getManager();
|
|
81 | 87 |
|
82 | 88 |
private TimeAdjustmentListener listener = null; |
83 | 89 |
|
84 |
public TimePanel() |
|
85 |
{ |
|
90 |
public TimePanel() { |
|
86 | 91 |
super(); |
87 | 92 |
_mode = TIME_MODE.RELATIVE; |
88 | 93 |
} |
89 | 94 |
|
90 | 95 |
/** |
91 | 96 |
* Intializes the panel |
92 |
*
|
|
97 |
* |
|
93 | 98 |
* @param start |
94 | 99 |
* @param end |
95 | 100 |
*/ |
96 |
public void initialize(Instant start, Instant end) |
|
97 |
{ |
|
98 |
|
|
101 |
public void initialize(Instant start, Instant end) { |
|
102 |
|
|
99 | 103 |
createComponents(start, end); |
100 | 104 |
startBackupForInterval = start; |
101 | 105 |
endBackupForInterval = end; |
102 | 106 |
} |
103 |
|
|
107 |
|
|
104 | 108 |
/** |
105 | 109 |
* Set instants to all controls |
110 |
* |
|
106 | 111 |
* @param start |
107 | 112 |
* @param end |
108 | 113 |
*/ |
109 | 114 |
public void setInstants(Instant start, Instant end) { |
110 |
startDate = start;
|
|
111 |
endDate = end;
|
|
115 |
startDate = start; |
|
116 |
endDate = end; |
|
112 | 117 |
|
113 |
getJComponentStart().setTimes(Messages.getText("lbl_begin_position"),
|
|
114 |
startDate, startDate, endDate);
|
|
118 |
getJComponentStart().setTimes(Messages.getText("lbl_begin_position"), |
|
119 |
startDate, startDate, endDate); |
|
115 | 120 |
|
116 |
getJComponentEnd().setTimes(Messages.getText("lbl_end_position"),
|
|
117 |
endDate, startDate, endDate);
|
|
121 |
getJComponentEnd().setTimes(Messages.getText("lbl_end_position"), |
|
122 |
endDate, startDate, endDate); |
|
118 | 123 |
|
119 |
|
|
120 |
getTimeSlider().setValues(startDate, endDate); |
|
124 |
getTimeSlider().setValues(startDate, endDate); |
|
121 | 125 |
} |
122 | 126 |
|
123 | 127 |
/** |
124 | 128 |
* Set the time Mode |
129 |
* |
|
125 | 130 |
* @param mode |
126 | 131 |
* @param start |
127 | 132 |
* @param end |
128 | 133 |
*/ |
129 |
public void setTimeMode(TIME_MODE mode, Instant start, Instant end) |
|
130 |
{ |
|
131 |
_mode = mode; |
|
132 |
initialize(start,end); |
|
134 |
public void setTimeMode(TIME_MODE mode, Instant start, Instant end) { |
|
135 |
_mode = mode; |
|
136 |
initialize(start, end); |
|
133 | 137 |
} |
134 |
|
|
138 |
|
|
135 | 139 |
/** |
136 | 140 |
* Get the current TIME_MODE |
141 |
* |
|
137 | 142 |
* @return |
138 | 143 |
*/ |
139 |
public TIME_MODE getTimeMode() |
|
140 |
{ |
|
141 |
return _mode; |
|
144 |
public TIME_MODE getTimeMode() { |
|
145 |
return _mode; |
|
142 | 146 |
} |
143 |
|
|
147 |
|
|
144 | 148 |
/** |
145 | 149 |
* Set the listener to capture all events {@link TimeAdjustmentListener} |
150 |
* |
|
146 | 151 |
* @param listener |
147 | 152 |
*/ |
148 | 153 |
public void setListener(TimeAdjustmentListener listener) { |
... | ... | |
151 | 156 |
|
152 | 157 |
/** |
153 | 158 |
* Get the listener {@link TimeAdjustmentListener} |
159 |
* |
|
154 | 160 |
* @return |
155 | 161 |
*/ |
156 | 162 |
public TimeAdjustmentListener getListener() { |
... | ... | |
159 | 165 |
|
160 | 166 |
/** |
161 | 167 |
* Set if works with instants (true) or interval (false) |
168 |
* |
|
162 | 169 |
* @param changeable |
163 | 170 |
*/ |
164 | 171 |
public void setValueChangeableSlider(boolean changeable) { |
165 |
if(changeable == true) |
|
166 |
{ //Instant |
|
167 |
if(interval != null) |
|
168 |
{ |
|
172 |
if( changeable == true ) { //Instant |
|
173 |
if( interval != null ) { |
|
169 | 174 |
startBackupForInterval = startDate; |
170 | 175 |
startBackupForInterval = endDate; |
171 | 176 |
setInstants(interval.getStart(), interval.getEnd()); |
172 | 177 |
} |
173 |
}else |
|
174 |
{ //Interval |
|
175 |
if(interval != null) |
|
176 |
{ |
|
178 |
} else { //Interval |
|
179 |
if( interval != null ) { |
|
177 | 180 |
setInstants(startBackupForInterval, endBackupForInterval); |
178 | 181 |
} |
179 | 182 |
} |
... | ... | |
182 | 185 |
|
183 | 186 |
/** |
184 | 187 |
* Set the valid instants |
188 |
* |
|
185 | 189 |
* @param instants |
186 | 190 |
*/ |
187 |
public void setInstants(List<Instant> instants) |
|
188 |
{ |
|
191 |
public void setInstants(List<Instant> instants) { |
|
189 | 192 |
this.instants = instants; |
190 | 193 |
instantsPosition = 0; |
191 | 194 |
actual = null; |
192 | 195 |
} |
193 |
|
|
196 |
|
|
194 | 197 |
public void timeChanged(TimeEvent event) { |
195 | 198 |
// TODO Auto-generated method stub |
196 |
if(!isUpdating()) |
|
197 |
{ |
|
198 |
setUpdating(true); |
|
199 |
if (event.getSource() instanceof TimeSlider) { |
|
200 |
if(getTimeSlider().getValueChangeable()) |
|
201 |
{ |
|
202 |
if(this.instants != null && !updateSlider) |
|
203 |
{ |
|
204 |
updateSlider = true; |
|
205 |
if(!getTimeSlider().isValueAdjusting()) |
|
206 |
{ |
|
207 |
getTimeSlider().setCurrentInstant(getApproximateInstant(getTimeSlider().getCurrentInstant())); |
|
208 |
getJComponentStart().setCurrentInstant(getTimeSlider().getCurrentInstant()); |
|
209 |
} |
|
210 |
updateSlider = false; |
|
211 |
}else |
|
212 |
{ |
|
213 |
getJComponentStart().setCurrentInstant(getTimeSlider().getCurrentInstant()); |
|
214 |
} |
|
215 |
|
|
216 |
} |
|
217 |
|
|
218 |
} else if (event.getSource() instanceof ITemporalComponent) { |
|
219 |
|
|
220 |
ITemporalComponent calendar = (ITemporalComponent) event.getSource(); |
|
221 |
if (calendar == getJComponentStart()) { |
|
222 |
if (!getTimeSlider().getValueChangeable()) { |
|
223 |
|
|
224 |
try {// this try is for the daylight saving (it creates |
|
225 |
// exceptions) |
|
226 |
if(!updateSlider) |
|
227 |
getTimeSlider().setStartInstant((Instant)getJComponentStart().getTime()); |
|
228 |
} catch (IllegalArgumentException e) { |
|
229 |
e.printStackTrace(); |
|
230 |
} |
|
231 |
} |
|
232 |
} else { |
|
233 |
if (!getTimeSlider().getValueChangeable()) { |
|
234 |
|
|
235 |
try {// this try is for the daylight saving (it creates |
|
236 |
// exceptions) |
|
237 |
if(!updateSlider) |
|
238 |
getTimeSlider().setEndInstant((Instant)getJComponentEnd().getTime()); |
|
239 |
} catch (IllegalArgumentException e) { |
|
240 |
e.printStackTrace(); |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
updateCalendars(); |
|
245 |
|
|
246 |
} else { |
|
247 |
try {// this try is for the daylight saving (it creates exceptions) |
|
248 |
if(instants == null) |
|
249 |
getTimeSlider().setCurrentInstant((Instant) |
|
250 |
getJComponentStart().getTime()); |
|
251 |
} catch (IllegalArgumentException e) { |
|
252 |
} finally { |
|
253 |
} |
|
254 |
} |
|
255 |
if (getTimeSlider().getValueChangeable() && listener != null) |
|
256 |
listener.timeChanged(new TimeEvent(this)); |
|
257 |
setUpdating(false); |
|
258 |
} |
|
199 |
if( !isUpdating() ) { |
|
200 |
setUpdating(true); |
|
201 |
if( event.getSource() instanceof TimeSlider ) { |
|
202 |
if( getTimeSlider().getValueChangeable() ) { |
|
203 |
if( CollectionUtils.isNotEmpty(this.instants) && !updateSlider ) { |
|
204 |
updateSlider = true; |
|
205 |
if( !getTimeSlider().isValueAdjusting() ) { |
|
206 |
getTimeSlider().setCurrentInstant(getApproximateInstant(getTimeSlider().getCurrentInstant())); |
|
207 |
getJComponentStart().setCurrentInstant(getTimeSlider().getCurrentInstant()); |
|
208 |
} |
|
209 |
updateSlider = false; |
|
210 |
} else { |
|
211 |
getJComponentStart().setCurrentInstant(getTimeSlider().getCurrentInstant()); |
|
212 |
} |
|
213 |
|
|
214 |
} |
|
215 |
|
|
216 |
} else if( event.getSource() instanceof ITemporalComponent ) { |
|
217 |
|
|
218 |
ITemporalComponent calendar = (ITemporalComponent) event.getSource(); |
|
219 |
if( calendar == getJComponentStart() ) { |
|
220 |
if( !getTimeSlider().getValueChangeable() ) { |
|
221 |
|
|
222 |
try {// this try is for the daylight saving (it creates |
|
223 |
// exceptions) |
|
224 |
if( !updateSlider ) { |
|
225 |
getTimeSlider().setStartInstant((Instant) getJComponentStart().getTime()); |
|
226 |
} |
|
227 |
} catch (IllegalArgumentException e) { |
|
228 |
e.printStackTrace(); |
|
229 |
} |
|
230 |
} |
|
231 |
} else { |
|
232 |
if( !getTimeSlider().getValueChangeable() ) { |
|
233 |
|
|
234 |
try {// this try is for the daylight saving (it creates |
|
235 |
// exceptions) |
|
236 |
if( !updateSlider ) { |
|
237 |
getTimeSlider().setEndInstant((Instant) getJComponentEnd().getTime()); |
|
238 |
} |
|
239 |
} catch (IllegalArgumentException e) { |
|
240 |
e.printStackTrace(); |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
updateCalendars(); |
|
245 |
|
|
246 |
} else { |
|
247 |
try {// this try is for the daylight saving (it creates exceptions) |
|
248 |
if( CollectionUtils.isEmpty(this.instants) ) { |
|
249 |
getTimeSlider().setCurrentInstant((Instant) getJComponentStart().getTime()); |
|
250 |
} |
|
251 |
} catch (IllegalArgumentException e) { |
|
252 |
} finally { |
|
253 |
} |
|
254 |
} |
|
255 |
if( getTimeSlider().getValueChangeable() && listener != null ) { |
|
256 |
listener.timeChanged(new TimeEvent(this)); |
|
257 |
} |
|
258 |
setUpdating(false); |
|
259 |
} |
|
259 | 260 |
} |
260 | 261 |
|
261 | 262 |
public void rangeChanged(TimeEvent event) { |
262 | 263 |
// TODO Auto-generated method stub |
263 |
if (event.getSource() instanceof TimeSlider) {
|
|
264 |
if( event.getSource() instanceof TimeSlider ) {
|
|
264 | 265 |
getJComponentStart().setCurrentInstant(getTimeSlider().getStartInstant()); |
265 | 266 |
getJComponentEnd().setCurrentInstant(getTimeSlider().getEndInstant()); |
266 | 267 |
} |
267 |
if (!getTimeSlider().getValueChangeable() && listener != null)
|
|
268 |
if( !getTimeSlider().getValueChangeable() && listener != null ) {
|
|
268 | 269 |
listener.rangeChanged(new TimeEvent(this)); |
270 |
} |
|
269 | 271 |
} |
270 | 272 |
|
271 | 273 |
/** |
... | ... | |
307 | 309 |
|
308 | 310 |
/** |
309 | 311 |
* Get the current interval |
312 |
* |
|
310 | 313 |
* @return |
311 | 314 |
*/ |
312 | 315 |
public Interval getInterval() { |
313 | 316 |
|
314 |
if (datesCorrect()) { |
|
315 |
if(_mode == TIME_MODE.RELATIVE) |
|
316 |
{ |
|
317 |
return timeSupportManager.createRelativeInterval( |
|
318 |
(RelativeInstant)getJComponentStart().getTime(),(RelativeInstant) getJComponentEnd() |
|
319 |
.getTime()); |
|
320 |
}else |
|
321 |
{ |
|
322 |
try { |
|
323 |
AbsoluteInstant start = (AbsoluteInstant) getJComponentStart().getTime(); |
|
324 |
AbsoluteInstant end = (AbsoluteInstant) getJComponentEnd().getTime(); |
|
325 |
return createAbsoluteInterval(start, end); |
|
326 |
} catch (AbsoluteIntervalTypeNotRegisteredException e) { |
|
327 |
// TODO Auto-generated catch block |
|
328 |
e.printStackTrace(); |
|
329 |
return null; |
|
330 |
} |
|
331 |
} |
|
332 |
} else |
|
317 |
if( datesCorrect() ) { |
|
318 |
if( _mode == TIME_MODE.RELATIVE ) { |
|
319 |
return timeSupportManager.createRelativeInterval( |
|
320 |
(RelativeInstant) getJComponentStart().getTime(), (RelativeInstant) getJComponentEnd() |
|
321 |
.getTime()); |
|
322 |
} else { |
|
323 |
try { |
|
324 |
AbsoluteInstant start = (AbsoluteInstant) getJComponentStart().getTime(); |
|
325 |
AbsoluteInstant end = (AbsoluteInstant) getJComponentEnd().getTime(); |
|
326 |
return createAbsoluteInterval(start, end); |
|
327 |
} catch (AbsoluteIntervalTypeNotRegisteredException e) { |
|
328 |
// TODO Auto-generated catch block |
|
329 |
e.printStackTrace(); |
|
330 |
return null; |
|
331 |
} |
|
332 |
} |
|
333 |
} else { |
|
333 | 334 |
return null; |
335 |
} |
|
334 | 336 |
|
335 | 337 |
} |
336 | 338 |
|
337 | 339 |
/** |
338 | 340 |
* Get the current instant |
341 |
* |
|
339 | 342 |
* @return |
340 | 343 |
*/ |
341 | 344 |
public Instant getInstant() { |
342 | 345 |
|
343 |
if (datesCorrect()) {
|
|
346 |
if( datesCorrect() ) {
|
|
344 | 347 |
try {// this try is for the daylight saving (it creates exceptions) |
345 | 348 |
return (Instant) getJComponentStart().getTime(); |
346 | 349 |
} catch (IllegalArgumentException e) { |
347 | 350 |
return null; |
348 | 351 |
} |
349 |
} else |
|
352 |
} else {
|
|
350 | 353 |
return null; |
354 |
} |
|
351 | 355 |
|
352 | 356 |
} |
353 | 357 |
|
354 |
public void setInterval(Interval interval) |
|
355 |
{ |
|
358 |
public void setInterval(Interval interval) { |
|
356 | 359 |
this.interval = interval; |
357 | 360 |
} |
358 |
|
|
361 |
|
|
359 | 362 |
/* |
360 | 363 |
* PRIVATE METHODS |
361 | 364 |
*/ |
362 | 365 |
private void createUI() { |
363 | 366 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
364 |
|
|
365 |
add((Component)getJComponentStart()); |
|
367 |
|
|
368 |
add((Component) getJComponentStart());
|
|
366 | 369 |
add(getTimeSlider()); |
367 |
add((Component)getJComponentEnd()); |
|
368 |
|
|
370 |
add((Component) getJComponentEnd());
|
|
371 |
|
|
369 | 372 |
getTimeSlider().setValueChangeable(false); |
370 | 373 |
|
371 | 374 |
getJComponentStart().setListener(this); |
372 | 375 |
getJComponentEnd().setListener(this); |
373 | 376 |
getTimeSlider().addTimeAdjustmentListener(this); |
374 | 377 |
} |
375 |
|
|
376 |
private void createComponents(Instant start, Instant end) |
|
377 |
{ |
|
378 |
removeAll(); |
|
379 |
revalidate(); |
|
380 |
repaint(); |
|
381 |
jComponentStart = null; |
|
382 |
jComponentEnd = null; |
|
383 |
slider = null; |
|
384 |
setInstants(start, end); |
|
385 |
createUI(); |
|
386 |
|
|
378 |
|
|
379 |
private void createComponents(Instant start, Instant end) { |
|
380 |
removeAll(); |
|
381 |
revalidate(); |
|
382 |
repaint(); |
|
383 |
jComponentStart = null; |
|
384 |
jComponentEnd = null; |
|
385 |
slider = null; |
|
386 |
setInstants(start, end); |
|
387 |
createUI(); |
|
388 |
|
|
387 | 389 |
} |
388 | 390 |
|
389 | 391 |
@SuppressWarnings("unused") |
390 | 392 |
private boolean datesCorrect() { |
391 |
if (getJComponentStart().isEnabled() && getJComponentEnd().isEnabled()) {
|
|
393 |
if( getJComponentStart().isEnabled() && getJComponentEnd().isEnabled() ) {
|
|
392 | 394 |
try { |
393 | 395 |
Instant init = (Instant) getJComponentStart().getTime(); |
394 | 396 |
Instant end = (Instant) getJComponentEnd().getTime(); |
... | ... | |
401 | 403 |
} |
402 | 404 |
|
403 | 405 |
private TimeSlider getTimeSlider() { |
404 |
if (slider == null) |
|
405 |
if(_mode == TIME_MODE.RELATIVE) |
|
406 |
slider = new TimeSlider(false); |
|
407 |
else |
|
408 |
slider = new TimeSlider(true); |
|
406 |
if( slider == null ) { |
|
407 |
if( _mode == TIME_MODE.RELATIVE ) { |
|
408 |
slider = new TimeSlider(false); |
|
409 |
} else { |
|
410 |
slider = new TimeSlider(true); |
|
411 |
} |
|
412 |
} |
|
409 | 413 |
return slider; |
410 | 414 |
} |
411 | 415 |
|
412 | 416 |
private ITemporalComponent getJComponentStart() { |
413 |
if (jComponentStart == null) |
|
414 |
if(_mode == TIME_MODE.RELATIVE) |
|
415 |
jComponentStart = new RelativeTemporalComponent(); |
|
416 |
else |
|
417 |
jComponentStart = new AbsoluteTemporalComponent(); |
|
418 |
|
|
417 |
if( jComponentStart == null ) { |
|
418 |
if( _mode == TIME_MODE.RELATIVE ) { |
|
419 |
jComponentStart = new RelativeTemporalComponent(); |
|
420 |
} else { |
|
421 |
jComponentStart = new AbsoluteTemporalComponent(); |
|
422 |
} |
|
423 |
} |
|
424 |
|
|
419 | 425 |
return jComponentStart; |
420 | 426 |
} |
421 | 427 |
|
422 | 428 |
private ITemporalComponent getJComponentEnd() { |
423 |
if (jComponentEnd == null) |
|
424 |
if(_mode == TIME_MODE.RELATIVE) |
|
425 |
jComponentEnd = new RelativeTemporalComponent(); |
|
426 |
else |
|
427 |
jComponentEnd = new AbsoluteTemporalComponent(); |
|
429 |
if( jComponentEnd == null ) { |
|
430 |
if( _mode == TIME_MODE.RELATIVE ) { |
|
431 |
jComponentEnd = new RelativeTemporalComponent(); |
|
432 |
} else { |
|
433 |
jComponentEnd = new AbsoluteTemporalComponent(); |
|
434 |
} |
|
435 |
} |
|
428 | 436 |
return jComponentEnd; |
429 | 437 |
} |
430 | 438 |
|
431 | 439 |
private void updateCalendars() { |
432 | 440 |
try { |
433 |
Instant start = (Instant)getJComponentStart().getTime(); |
|
434 |
Instant end = (Instant)getJComponentEnd().getTime(); |
|
441 |
Instant start = (Instant) getJComponentStart().getTime();
|
|
442 |
Instant end = (Instant) getJComponentEnd().getTime();
|
|
435 | 443 |
getJComponentStart().setEndTime(end); |
436 | 444 |
getJComponentEnd().setStartTime(start); |
437 | 445 |
} catch (IllegalArgumentException e) { |
438 | 446 |
} |
439 | 447 |
} |
440 |
|
|
441 |
private boolean isUpdating() |
|
442 |
{ |
|
443 |
return eventSynchronized; |
|
448 |
|
|
449 |
private boolean isUpdating() { |
|
450 |
return eventSynchronized; |
|
444 | 451 |
} |
445 |
|
|
446 |
private void setUpdating(boolean value) |
|
447 |
{ |
|
448 |
eventSynchronized = value; |
|
452 |
|
|
453 |
private void setUpdating(boolean value) { |
|
454 |
eventSynchronized = value; |
|
449 | 455 |
} |
450 |
|
|
451 |
private AbsoluteInterval createAbsoluteInterval(AbsoluteInstant start, AbsoluteInstant end) throws AbsoluteIntervalTypeNotRegisteredException |
|
452 |
{ |
|
453 |
long millisStart = start.toStandardDuration().getMillis(); |
|
454 |
long millisEnd = end.toStandardDuration().getMillis(); |
|
455 |
|
|
456 |
long millisInterval = millisEnd - millisStart; |
|
457 |
|
|
458 |
int years = 0, months = 0, weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0, millis = 0; |
|
459 |
|
|
460 |
long mod = millisInterval % TimeSlider.MILLIS_BY_YEAR; |
|
461 |
if((millisInterval / TimeSlider.MILLIS_BY_YEAR) > 0) |
|
462 |
{ |
|
463 |
years = (int) (millisInterval / TimeSlider.MILLIS_BY_YEAR); |
|
464 |
millisInterval = mod; |
|
465 |
} |
|
466 |
|
|
467 |
mod = millisInterval % TimeSlider.MILLIS_BY_MONTH; |
|
468 |
if((millisInterval / TimeSlider.MILLIS_BY_MONTH) > 0) |
|
469 |
{ |
|
470 |
months = (int) (millisInterval / TimeSlider.MILLIS_BY_MONTH); |
|
471 |
millisInterval = mod; |
|
472 |
} |
|
473 |
|
|
474 |
mod = millisInterval % TimeSlider.MILLIS_BY_WEEK; |
|
475 |
if((millisInterval / TimeSlider.MILLIS_BY_WEEK) > 0) |
|
476 |
{ |
|
477 |
weeks = (int) (millisInterval / TimeSlider.MILLIS_BY_WEEK); |
|
478 |
millisInterval = mod; |
|
479 |
} |
|
480 |
|
|
481 |
mod = millisInterval % TimeSlider.MILLIS_BY_DAY; |
|
482 |
if ((millisInterval / TimeSlider.MILLIS_BY_DAY) > 0){ |
|
483 |
if((int)(millisInterval / TimeSlider.MILLIS_BY_DAY) > 0) |
|
484 |
{ |
|
485 |
days = (int)(millisInterval / TimeSlider.MILLIS_BY_DAY); |
|
486 |
} |
|
487 |
millisInterval = mod; |
|
488 |
} |
|
489 |
|
|
490 |
mod = millisInterval % TimeSlider.MILLIS_BY_HOUR; |
|
491 |
if ((millisInterval / TimeSlider.MILLIS_BY_HOUR) > 0){ |
|
492 |
hours = (int)(millisInterval / TimeSlider.MILLIS_BY_HOUR); |
|
493 |
millisInterval = mod; |
|
494 |
} |
|
495 |
|
|
496 |
mod = millisInterval % TimeSlider.MILLIS_BY_MINUTE; |
|
497 |
if ((millisInterval / TimeSlider.MILLIS_BY_MINUTE) > 0){ |
|
498 |
seconds =(int)(millisInterval / TimeSlider.MILLIS_BY_MINUTE); |
|
499 |
millisInterval = mod; |
|
500 |
} |
|
501 |
|
|
502 |
mod = millisInterval % TimeSlider.MILLIS_BY_SECOND; |
|
503 |
if ((millisInterval / TimeSlider.MILLIS_BY_SECOND) > 0){ |
|
504 |
seconds = (int)(millisInterval / TimeSlider.MILLIS_BY_SECOND); |
|
505 |
millisInterval = mod; |
|
506 |
} |
|
507 |
|
|
508 |
mod = millisInterval; |
|
509 |
if (mod > 0){ |
|
510 |
millis = (int) mod; |
|
511 |
} |
|
512 |
|
|
513 |
return timeSupportManager.createAbsoluteInterval(years, months, weeks, days, hours, minutes, seconds, millis); |
|
514 |
|
|
515 |
|
|
456 |
|
|
457 |
private AbsoluteInterval createAbsoluteInterval(AbsoluteInstant start, AbsoluteInstant end) throws AbsoluteIntervalTypeNotRegisteredException { |
|
458 |
long millisStart = start.toStandardDuration().getMillis(); |
|
459 |
long millisEnd = end.toStandardDuration().getMillis(); |
|
460 |
|
|
461 |
long millisInterval = millisEnd - millisStart; |
|
462 |
|
|
463 |
int years = 0, months = 0, weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0, millis = 0; |
|
464 |
|
|
465 |
long mod = millisInterval % TimeSlider.MILLIS_BY_YEAR; |
|
466 |
if( (millisInterval / TimeSlider.MILLIS_BY_YEAR) > 0 ) { |
|
467 |
years = (int) (millisInterval / TimeSlider.MILLIS_BY_YEAR); |
|
468 |
millisInterval = mod; |
|
469 |
} |
|
470 |
|
|
471 |
mod = millisInterval % TimeSlider.MILLIS_BY_MONTH; |
|
472 |
if( (millisInterval / TimeSlider.MILLIS_BY_MONTH) > 0 ) { |
|
473 |
months = (int) (millisInterval / TimeSlider.MILLIS_BY_MONTH); |
|
474 |
millisInterval = mod; |
|
475 |
} |
|
476 |
|
|
477 |
mod = millisInterval % TimeSlider.MILLIS_BY_WEEK; |
|
478 |
if( (millisInterval / TimeSlider.MILLIS_BY_WEEK) > 0 ) { |
|
479 |
weeks = (int) (millisInterval / TimeSlider.MILLIS_BY_WEEK); |
|
480 |
millisInterval = mod; |
|
481 |
} |
|
482 |
|
|
483 |
mod = millisInterval % TimeSlider.MILLIS_BY_DAY; |
|
484 |
if( (millisInterval / TimeSlider.MILLIS_BY_DAY) > 0 ) { |
|
485 |
if( (int) (millisInterval / TimeSlider.MILLIS_BY_DAY) > 0 ) { |
|
486 |
days = (int) (millisInterval / TimeSlider.MILLIS_BY_DAY); |
|
487 |
} |
|
488 |
millisInterval = mod; |
|
489 |
} |
|
490 |
|
|
491 |
mod = millisInterval % TimeSlider.MILLIS_BY_HOUR; |
|
492 |
if( (millisInterval / TimeSlider.MILLIS_BY_HOUR) > 0 ) { |
|
493 |
hours = (int) (millisInterval / TimeSlider.MILLIS_BY_HOUR); |
|
494 |
millisInterval = mod; |
|
495 |
} |
|
496 |
|
|
497 |
mod = millisInterval % TimeSlider.MILLIS_BY_MINUTE; |
|
498 |
if( (millisInterval / TimeSlider.MILLIS_BY_MINUTE) > 0 ) { |
|
499 |
seconds = (int) (millisInterval / TimeSlider.MILLIS_BY_MINUTE); |
|
500 |
millisInterval = mod; |
|
501 |
} |
|
502 |
|
|
503 |
mod = millisInterval % TimeSlider.MILLIS_BY_SECOND; |
|
504 |
if( (millisInterval / TimeSlider.MILLIS_BY_SECOND) > 0 ) { |
|
505 |
seconds = (int) (millisInterval / TimeSlider.MILLIS_BY_SECOND); |
|
506 |
millisInterval = mod; |
|
507 |
} |
|
508 |
|
|
509 |
mod = millisInterval; |
|
510 |
if( mod > 0 ) { |
|
511 |
millis = (int) mod; |
|
512 |
} |
|
513 |
|
|
514 |
return timeSupportManager.createAbsoluteInterval(years, months, weeks, days, hours, minutes, seconds, millis); |
|
515 |
|
|
516 | 516 |
} |
517 |
|
|
518 |
private Instant getApproximateInstant(Instant instant) |
|
519 |
{ |
|
520 |
|
|
517 |
|
|
518 |
private Instant getApproximateInstant(Instant instant) { |
|
519 |
|
|
521 | 520 |
int index = 0; |
522 |
|
|
523 |
if(instant.isBefore(instants.get(0)))
|
|
521 |
|
|
522 |
if( instant.isBefore(instants.get(0)) ) {
|
|
524 | 523 |
return instants.get(0); |
525 |
|
|
526 |
for(Instant ins : instants) |
|
527 |
{ |
|
528 |
if(ins.isEqual(instant))
|
|
524 |
} |
|
525 |
|
|
526 |
for( Instant ins : instants ) {
|
|
527 |
if( ins.isEqual(instant) ) {
|
|
529 | 528 |
return ins; |
530 |
else if(ins.isAfter(instant)) |
|
531 |
{ |
|
529 |
} else if( ins.isAfter(instant) ) { |
|
532 | 530 |
break; |
533 | 531 |
} |
534 | 532 |
index++; |
535 | 533 |
} |
536 |
if(index == instants.size()) |
|
537 |
return instants.get(instants.size()-1); |
|
538 |
|
|
534 |
if( index == instants.size() ) { |
|
535 |
return instants.get(instants.size() - 1); |
|
536 |
} |
|
537 |
|
|
539 | 538 |
return instants.get(index); |
540 | 539 |
} |
541 | 540 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.timesupport/org.gvsig.timesupport.swing/org.gvsig.timesupport.swing.impl/src/main/java/org/gvsig/timesupport/swing/impl/panel/DefaultTimeSliderPanel.java | ||
---|---|---|
59 | 59 |
|
60 | 60 |
/** |
61 | 61 |
* Creates a panel with slider and time control calendars |
62 |
* |
|
63 |
* @author <a href="mailto:Pablo.Viciano@uji.es">Pablo Viciano Negre</a> |
|
64 |
* |
|
65 | 62 |
*/ |
66 | 63 |
public class DefaultTimeSliderPanel extends TimeSelectorPanel implements |
67 | 64 |
TimeAdjustmentListener { |
... | ... | |
79 | 76 |
|
80 | 77 |
public DefaultTimeSliderPanel() { |
81 | 78 |
super(); |
82 |
observers = new ArrayList<Observer>();
|
|
79 |
observers = new ArrayList<>(); |
|
83 | 80 |
} |
84 | 81 |
|
85 | 82 |
@Override |
... | ... | |
101 | 98 |
revalidate(); |
102 | 99 |
repaint(); |
103 | 100 |
createUI(); |
104 |
if(start.isAbsolute()) |
|
105 |
timePanel.setTimeMode(TIME_MODE.ABSOLUTE, start, end); |
|
106 |
else |
|
107 |
timePanel.setTimeMode(TIME_MODE.RELATIVE, start, end); |
|
101 |
if(start.isAbsolute()) { |
|
102 |
timePanel.setTimeMode(TIME_MODE.ABSOLUTE, start, end); |
|
103 |
} else { |
|
104 |
timePanel.setTimeMode(TIME_MODE.RELATIVE, start, end); |
|
105 |
} |
|
108 | 106 |
} |
109 | 107 |
|
108 |
@Override |
|
110 | 109 |
public void timeChanged(TimeEvent event) { |
111 | 110 |
if (getInstantRadioButton().isSelected()) { |
112 | 111 |
Instant instante = timePanel.getInstant(); |
113 |
if (this.observers.size() != 0) |
|
114 |
for (Observer o : this.observers) |
|
115 |
o.update(this, new UpdateTimeNotification(instante)); |
|
112 |
if (!this.observers.isEmpty()) { |
|
113 |
for (Observer o : this.observers) { |
|
114 |
o.update(this, new UpdateTimeNotification(instante)); |
|
115 |
} |
|
116 |
} |
|
116 | 117 |
} |
117 | 118 |
} |
118 | 119 |
|
120 |
@Override |
|
119 | 121 |
public void rangeChanged(TimeEvent event) { |
120 | 122 |
if (getIntervalRadioButton().isSelected()) { |
121 |
if (this.observers.size() != 0) |
|
122 |
for (Observer o : this.observers) |
|
123 |
o.update(this, new UpdateTimeNotification(timePanel.getInterval())); |
|
123 |
if (!this.observers.isEmpty()) { |
|
124 |
for (Observer o : this.observers) { |
|
125 |
o.update(this, new UpdateTimeNotification(timePanel.getInterval())); |
|
126 |
} |
|
127 |
} |
|
124 | 128 |
} |
125 | 129 |
} |
126 | 130 |
|
131 |
@Override |
|
127 | 132 |
public void boundsChanged(TimeEvent event) { |
128 | 133 |
|
129 | 134 |
} |
... | ... | |
135 | 140 |
|
136 | 141 |
|
137 | 142 |
public boolean isInterval() { |
138 |
// TODO Auto-generated method stub |
|
139 | 143 |
return getIntervalRadioButton().isSelected(); |
140 | 144 |
} |
141 | 145 |
|
142 | 146 |
public boolean isInstant() { |
143 |
// TODO Auto-generated method stub |
|
144 | 147 |
return getInstantRadioButton().isSelected(); |
145 | 148 |
} |
146 | 149 |
|
147 | 150 |
public boolean isNone() { |
148 |
// TODO Auto-generated method stub |
|
149 | 151 |
return getNoneRadioButton().isSelected(); |
150 | 152 |
} |
151 | 153 |
|
154 |
@Override |
|
152 | 155 |
public void addObserver(Observer o) { |
153 | 156 |
// TODO Auto-generated method stub |
154 | 157 |
observers.add(o); |
155 | 158 |
} |
156 | 159 |
|
160 |
@Override |
|
157 | 161 |
public void deleteObserver(Observer o) { |
158 | 162 |
// TODO Auto-generated method stub |
159 | 163 |
observers.remove(o); |
160 | 164 |
} |
161 | 165 |
|
166 |
@Override |
|
162 | 167 |
public void deleteObservers() { |
163 | 168 |
// TODO Auto-generated method stub |
164 | 169 |
observers.clear(); |
... | ... | |
323 | 328 |
|
324 | 329 |
@Override |
325 | 330 |
public void setInstants(List<Instant> instants) { |
326 |
// TODO Auto-generated method stub |
|
327 | 331 |
java.util.Collections.sort(instants, new InstantComparator()); |
328 | 332 |
//Delete duplicates |
329 | 333 |
Iterator<Instant> iterador = instants.iterator(); |
330 |
List<Instant> sortedList = new ArrayList<Instant>();
|
|
334 |
List<Instant> sortedList = new ArrayList<>(); |
|
331 | 335 |
Instant obj; |
332 | 336 |
while(iterador.hasNext()){ |
333 | 337 |
obj = iterador.next(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.timesupport/org.gvsig.timesupport.swing/org.gvsig.timesupport.swing.impl/pom.xml | ||
---|---|---|
35 | 35 |
<artifactId>org.gvsig.i18n</artifactId> |
36 | 36 |
<scope>compile</scope> |
37 | 37 |
</dependency> |
38 |
<dependency> |
|
39 |
<groupId>org.apache.commons</groupId> |
|
40 |
<artifactId>commons-collections4</artifactId> |
|
41 |
<scope>compile</scope> |
|
42 |
</dependency> |
|
38 | 43 |
</dependencies> |
39 | 44 |
</project> |
40 | 45 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/IntersectsTimeEvaluator.java | ||
---|---|---|
48 | 48 |
|
49 | 49 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
50 | 50 |
Feature feature = ((Feature) data.getContextValue("feature")); |
51 |
Time featureTime = (Time)feature.get(timeAttributeName);
|
|
52 |
if( featureTime==null ) {
|
|
53 |
return Boolean.FALSE;
|
|
51 |
Object value = feature.get(timeAttributeName);
|
|
52 |
if( !(value instanceof Time) ) {
|
|
53 |
return false;
|
|
54 | 54 |
} |
55 |
return new Boolean(time.intersects(featureTime)); |
|
55 |
Time featureTime = (Time)value; |
|
56 |
return time.intersects(featureTime); |
|
56 | 57 |
} |
57 | 58 |
|
58 | 59 |
public String getName() { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/LayersIterator.java | ||
---|---|---|
38 | 38 |
* if a layer will be in the iteration list. |
39 | 39 |
* <P> |
40 | 40 |
* @author jmvivo |
41 |
* @deprecated use layers.deepiterator |
|
41 | 42 |
* |
42 | 43 |
*/ |
43 | 44 |
public class LayersIterator implements Iterator { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultEditableFeatureType.java | ||
---|---|---|
139 | 139 |
return source; |
140 | 140 |
} |
141 | 141 |
|
142 |
private long getCRC() { |
|
143 |
StringBuffer buffer = new StringBuffer(); |
|
144 |
for (int i = 0; i < this.size(); i++) { |
|
145 |
FeatureAttributeDescriptor x = this.getAttributeDescriptor(i); |
|
146 |
buffer.append(x.getName()); |
|
147 |
buffer.append(x.getDataTypeName()); |
|
148 |
buffer.append(x.getSize()); |
|
149 |
} |
|
150 |
CRC32 crc = new CRC32(); |
|
151 |
byte[] data = buffer.toString().getBytes(); |
|
152 |
crc.update(data); |
|
153 |
return crc.getValue(); |
|
154 |
} |
|
155 |
|
|
156 | 142 |
public FeatureType getNotEditableCopy() { |
157 | 143 |
this.fixAll(); |
158 | 144 |
DefaultFeatureType copy = new DefaultFeatureType(this, false); |
... | ... | |
259 | 245 |
return attr; |
260 | 246 |
} |
261 | 247 |
|
248 |
@Override |
|
262 | 249 |
protected void fixAll() { |
263 |
int i = 0; |
|
264 |
Iterator iter = super.iterator(); |
|
265 |
DefaultFeatureAttributeDescriptor attr; |
|
266 |
|
|
267 |
while (iter.hasNext()) { |
|
268 |
attr = (DefaultFeatureAttributeDescriptor) iter |
|
269 |
.next(); |
|
270 |
attr.setIndex(i++); |
|
271 |
if (attr instanceof DefaultEditableFeatureAttributeDescriptor) { |
|
272 |
((DefaultEditableFeatureAttributeDescriptor) attr).fixAll(); |
|
273 |
} |
|
274 |
if (attr.getEvaluator() != null) { |
|
275 |
this.hasEvaluators = true; |
|
276 |
} |
|
277 |
if (attr.getFeatureAttributeEmulator() != null) { |
|
278 |
this.hasEmulators = true; |
|
279 |
} |
|
280 |
if (this.defaultGeometryAttributeName == null && attr.getType() == DataTypes.GEOMETRY) { |
|
281 |
this.defaultGeometryAttributeName = attr.getName(); |
|
282 |
} |
|
283 |
} |
|
284 |
if (this.defaultGeometryAttributeName != null) { |
|
285 |
this.defaultGeometryAttributeIndex = this.getIndex(this.defaultGeometryAttributeName); |
|
286 |
} |
|
287 |
this.internalID = Long.toHexString(this.getCRC()); |
|
250 |
super.fixAll(); |
|
288 | 251 |
} |
289 | 252 |
|
290 | 253 |
public void checkIntegrity() throws DataListException { |
... | ... | |
385 | 348 |
this.allowAtomaticValues = value; |
386 | 349 |
} |
387 | 350 |
|
388 |
public void setDefaultTimeAttributeName(String name) { |
|
389 |
if (name == null || name.length() == 0) { |
|
390 |
this.defaultTimeAttributeIndex = -1; |
|
391 |
return; |
|
392 |
} |
|
393 |
DefaultFeatureAttributeDescriptor attr = (DefaultFeatureAttributeDescriptor) this |
|
394 |
.get(name); |
|
395 |
if (attr == null) { |
|
396 |
throw new IllegalArgumentException("Attribute '" + name |
|
397 |
+ "' not found."); |
|
398 |
} |
|
399 |
|
|
400 |
this.defaultTimeAttributeIndex = attr.getIndex(); |
|
401 |
} |
|
402 | 351 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureType.java | ||
---|---|---|
29 | 29 |
import java.util.Collections; |
30 | 30 |
import java.util.Iterator; |
31 | 31 |
import java.util.List; |
32 |
import java.util.zip.CRC32; |
|
32 | 33 |
import org.apache.commons.lang3.ArrayUtils; |
33 | 34 |
import org.apache.commons.lang3.StringUtils; |
34 | 35 |
|
... | ... | |
777 | 778 |
return (FeatureAttributeDescriptor) super |
778 | 779 |
.get(this.defaultTimeAttributeIndex); |
779 | 780 |
} |
781 |
|
|
782 |
public void setDefaultTimeAttributeName(String name) { |
|
783 |
if (name == null || name.length() == 0) { |
|
784 |
this.defaultTimeAttributeIndex = -1; |
|
785 |
return; |
|
786 |
} |
|
787 |
DefaultFeatureAttributeDescriptor attr = (DefaultFeatureAttributeDescriptor) this.get(name); |
|
788 |
if (attr == null) { |
|
789 |
throw new IllegalArgumentException("Attribute '" + name + "' not found."); |
|
790 |
} |
|
791 |
if( attr.getIndex()<0 ) { |
|
792 |
fixAll(); |
|
793 |
} |
|
794 |
this.defaultTimeAttributeIndex = attr.getIndex(); |
|
795 |
} |
|
796 |
|
|
797 |
protected void fixAll() { |
|
798 |
int i = 0; |
|
799 |
Iterator iter = super.iterator(); |
|
800 |
DefaultFeatureAttributeDescriptor attr; |
|
801 |
|
|
802 |
while (iter.hasNext()) { |
|
803 |
attr = (DefaultFeatureAttributeDescriptor) iter.next(); |
|
804 |
attr.setIndex(i++); |
|
805 |
if (attr instanceof DefaultEditableFeatureAttributeDescriptor) { |
|
806 |
((DefaultEditableFeatureAttributeDescriptor) attr).fixAll(); |
|
807 |
} |
|
808 |
if (attr.getEvaluator() != null) { |
|
809 |
this.hasEvaluators = true; |
|
810 |
} |
|
811 |
if (attr.getFeatureAttributeEmulator() != null) { |
|
812 |
this.hasEmulators = true; |
|
813 |
} |
|
814 |
if (this.defaultGeometryAttributeName == null && attr.getType() == DataTypes.GEOMETRY) { |
|
815 |
this.defaultGeometryAttributeName = attr.getName(); |
|
816 |
} |
|
817 |
} |
|
818 |
if (this.defaultGeometryAttributeName != null) { |
|
819 |
this.defaultGeometryAttributeIndex = this.getIndex(this.defaultGeometryAttributeName); |
|
820 |
} |
|
821 |
this.internalID = Long.toHexString(this.getCRC()); |
|
822 |
|
|
823 |
} |
|
824 |
|
|
825 |
protected long getCRC() { |
|
826 |
StringBuffer buffer = new StringBuffer(); |
|
827 |
for (int i = 0; i < this.size(); i++) { |
|
828 |
FeatureAttributeDescriptor x = this.getAttributeDescriptor(i); |
|
829 |
buffer.append(x.getName()); |
|
830 |
buffer.append(x.getDataTypeName()); |
|
831 |
buffer.append(x.getSize()); |
|
832 |
} |
|
833 |
CRC32 crc = new CRC32(); |
|
834 |
byte[] data = buffer.toString().getBytes(); |
|
835 |
crc.update(data); |
|
836 |
return crc.getValue(); |
|
837 |
} |
|
780 | 838 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java | ||
---|---|---|
61 | 61 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
62 | 62 |
import org.gvsig.fmap.dal.exception.WriteException; |
63 | 63 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
64 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
64 | 65 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
65 | 66 |
import org.gvsig.fmap.dal.feature.Feature; |
66 | 67 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
... | ... | |
2531 | 2532 |
} |
2532 | 2533 |
|
2533 | 2534 |
public void setTimeSupport(FeatureStoreTimeSupport timeSupport) { |
2534 |
FeatureAttributeDescriptor attr; |
|
2535 |
DefaultFeatureType ft; |
|
2536 |
try { |
|
2537 |
ft = (DefaultFeatureType) this.getDefaultFeatureType(); |
|
2538 |
} catch (DataException ex) { |
|
2539 |
throw new RuntimeException("Can't add time support, can't get the default feature type.", ex); |
|
2535 |
if( this.isEditing() ) { |
|
2536 |
throw new RuntimeException("Can't add time support over attribute '"+timeSupport.getAttributeName()+"' while store is editing."); |
|
2540 | 2537 |
} |
2541 |
attr = ft.getAttributeDescriptor(timeSupport.getAttributeName()); |
|
2542 |
if( attr != null ) { |
|
2543 |
throw new RuntimeException("Can't add time support, attribute '"+timeSupport.getAttributeName()+"'already exists."); |
|
2538 |
if( !this.transforms.isEmpty() ) { |
|
2539 |
throw new RuntimeException("Can't add time support over attribute '"+timeSupport.getAttributeName()+"' if has transforms."); |
|
2544 | 2540 |
} |
2545 |
attr = ft.getAttributeDescriptor(timeSupport.getRequiredFieldNames()[0]); |
|
2546 |
if( attr != null ) { |
|
2541 |
FeatureType ft = this.defaultFeatureType; |
|
2542 |
FeatureAttributeDescriptor attr = ft.getAttributeDescriptor(timeSupport.getRequiredFieldNames()[0]); |
|
2543 |
if( attr == null ) { |
|
2547 | 2544 |
throw new RuntimeException("Can't add time support over attribute '"+timeSupport.getAttributeName()+"', this attribute don't exists."); |
2548 | 2545 |
} |
2549 |
DefaultEditableFeatureAttributeDescriptor attr2 = new DefaultEditableFeatureAttributeDescriptor(); |
|
2550 |
attr2.setDataType(timeSupport.getDataType()); |
|
2551 |
attr2.setIsTime(true); |
|
2552 |
attr2.setFeatureAttributeEmulator(timeSupport); |
|
2553 |
ft.add(attr2); |
|
2554 |
|
|
2546 |
EditableFeatureType eft = ft.getEditable(); |
|
2547 |
attr = eft.getAttributeDescriptor(timeSupport.getAttributeName()); |
|
2548 |
if( attr != null ) { |
|
2549 |
if( !(attr.getFeatureAttributeEmulator() instanceof FeatureStoreTimeSupport) ) { |
|
2550 |
throw new RuntimeException("Can't add time support, attribute '"+timeSupport.getAttributeName()+"'already exists."); |
|
2551 |
} |
|
2552 |
eft.remove(attr.getName()); |
|
2553 |
} |
|
2554 |
EditableFeatureAttributeDescriptor attrTime = eft.add( |
|
2555 |
timeSupport.getAttributeName(), |
|
2556 |
timeSupport.getDataType() |
|
2557 |
); |
|
2558 |
attrTime.setIsTime(true); |
|
2559 |
attrTime.setFeatureAttributeEmulator(timeSupport); |
|
2560 |
eft.setDefaultTimeAttributeName(timeSupport.getAttributeName()); |
|
2561 |
this.defaultFeatureType = eft.getNotEditableCopy(); |
|
2562 |
|
|
2555 | 2563 |
this.timeSupport = timeSupport; |
2556 | 2564 |
} |
2557 | 2565 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureAttributeEmulator.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.fmap.dal.feature; |
25 | 25 |
|
26 |
import org.gvsig.tools.dataTypes.DataType; |
|
27 | 26 |
|
28 |
|
|
29 | 27 |
/** |
30 | 28 |
* @author gvSIG Team |
31 | 29 |
* @version $Id$ |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.timesupport.app/org.gvsig.timesupport.app.animation/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
47 | 47 |
</fileSet> |
48 | 48 |
</fileSets> |
49 | 49 |
|
50 |
<!-- |
|
51 | 50 |
<dependencySets> |
52 | 51 |
<dependencySet> |
53 | 52 |
<useProjectArtifact>false</useProjectArtifact> |
54 | 53 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
55 | 54 |
<outputDirectory>lib</outputDirectory> |
56 | 55 |
<includes> |
57 |
<include>xxx:xxx</include>
|
|
56 |
<include>com.toedter:jcalendar</include>
|
|
58 | 57 |
</includes> |
59 | 58 |
</dependencySet> |
60 | 59 |
</dependencySets> |
61 |
--> |
|
62 | 60 |
</assembly> |
63 | 61 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.timesupport.app/org.gvsig.timesupport.app.animation/src/main/resources-plugin/text.properties | ||
---|---|---|
1 |
animation=Animaci?n |
|
2 |
creates_time_animation=Crea una animaci?n usando la varible temporal |
|
3 |
animation_preferences=Preferencias de animaci?n |
|
4 |
animation_bar=Barra de animaci?n |
|
5 |
step=Paso |
|
6 |
interval=Intervalo |
|
7 |
windowtime=Ventana de tiempo |
|
8 |
timestep=Paso de tiempo |
|
9 |
visualization=Visualizaci?n |
|
10 |
speed=Velocidad |
|
11 |
loop=Loop |
|
12 |
iterations=Iteraciones |
|
13 |
day=D?a |
|
14 |
month=Mes |
|
15 |
week=Semana |
|
16 |
year=A?o |
|
17 |
hour=Hora |
|
18 |
minute=Minuto |
|
19 |
second=Segundo |
|
20 |
millisecond=Milisegundo |
|
21 |
noloop=No loop |
|
22 |
loop_once=Loop una vez |
|
23 |
loop_n=Loop N veces |
|
24 |
speedofprogress=Velocidad de progreso |
|
25 |
lbl_begin_position=Fecha de inicio |
|
26 |
lbl_end_position=Fecha de fin |
|
27 |
Time=Tiempo |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.timesupport.app/org.gvsig.timesupport.app.animation/src/main/resources-plugin/text_en.properties | ||
---|---|---|
1 |
animation=Animation |
|
2 |
creates_time_animation=Creates a animation using time varible |
|
3 |
animation_preferences=Animation preferences |
|
4 |
animation_bar=Animation bar |
|
5 |
step=Step |
|
6 |
interval=Interval |
|
7 |
windowtime=Window time |
|
8 |
timestep=Time step |
|
9 |
visualization=Visualization |
|
10 |
speed=Speed |
|
11 |
loop=Loop |
|
12 |
iterations=Iterations |
|
13 |
day=Day |
|
14 |
month=Month |
|
15 |
week=Week |
|
16 |
year=Year |
|
17 |
hour=Hour |
|
18 |
minute=Minute |
|
19 |
second=Second |
|
20 |
millisecond=Millisecond |
|
21 |
noloop=No loop |
|
22 |
loop_once=Loop once |
|
23 |
loop_n=Loop N |
|
24 |
speedofprogress=Speed of progress |
|
25 |
lbl_begin_position=Initial date |
|
26 |
lbl_end_position=End date |
|
27 |
Time=Time |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.timesupport.app/org.gvsig.timesupport.app.animation/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<depends plugin-name="org.gvsig.app" /> |
|
4 |
<resourceBundle name="text"/> |
|
5 |
<libraries library-dir="lib"/> |
|
6 |
<extensions> |
|
7 |
<extension class-name="org.gvsig.timesupport.app.animation.extension.AnimationSupportExtension" |
|
8 |
description="" |
|
9 |
active="true" |
|
10 |
priority="1"> |
|
11 |
<menu text="View/Time/animation" |
|
12 |
tooltip="creates_time_animation" |
|
13 |
position="11" |
|
14 |
action-command="AnimationSupport"/> |
|
15 |
</extension> |
|
16 |
</extensions> |
|
17 |
</plugin-config> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.timesupport.app/org.gvsig.timesupport.app.animation/pom.xml | ||
---|---|---|
33 | 33 |
<artifactId>org.gvsig.timesupport.swing.impl</artifactId> |
34 | 34 |
<scope>runtime</scope> |
35 | 35 |
</dependency> |
36 |
<dependency> |
|
37 |
<groupId>com.toedter</groupId> |
|
38 |
<artifactId>jcalendar</artifactId> |
|
39 |
<scope>runtime</scope> |
|
40 |
</dependency> |
|
36 | 41 |
</dependencies> |
37 | 42 |
<properties> |
38 | 43 |
<gvsig.package.info.name>Tools: Animation by time</gvsig.package.info.name> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.timesupport.app/org.gvsig.timesupport.app.viewfilter/pom.xml | ||
---|---|---|
53 | 53 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
54 | 54 |
<scope>compile</scope> |
55 | 55 |
</dependency> |
56 |
<dependency> |
|
57 |
<groupId>com.toedter</groupId> |
|
58 |
<artifactId>jcalendar</artifactId> |
|
59 |
<scope>runtime</scope> |
|
60 |
</dependency> |
|
56 | 61 |
</dependencies> |
57 | 62 |
<properties> |
58 | 63 |
<gvsig.package.info.name>Tools: Filter a view by time</gvsig.package.info.name> |
59 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
60 | 64 |
</properties> |
61 | 65 |
</project> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.timesupport.app/org.gvsig.timesupport.app.viewfilter/src/main/java/org/gvsig/timesupport/app/extension/TimeSupportExtension.java | ||
---|---|---|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.timesupport.app.extension; |
23 | 23 |
|
24 |
import org.apache.commons.lang3.mutable.MutableBoolean; |
|
24 |
import java.util.Collection; |
|
25 |
import java.util.Date; |
|
26 |
import java.util.Iterator; |
|
25 | 27 |
import org.gvsig.andami.plugins.Extension; |
26 | 28 |
import org.gvsig.app.ApplicationLocator; |
27 | 29 |
import org.gvsig.app.ApplicationManager; |
28 | 30 |
import org.gvsig.app.project.documents.view.ViewDocument; |
29 | 31 |
import org.gvsig.app.project.documents.view.ViewManager; |
30 | 32 |
import org.gvsig.fmap.dal.DataStore; |
33 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
34 |
import org.gvsig.fmap.dal.feature.Feature; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureStoreTimeSupport; |
|
31 | 36 |
import org.gvsig.fmap.mapcontext.MapContext; |
37 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
38 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
32 | 39 |
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer; |
33 | 40 |
import org.gvsig.timesupport.AbsoluteIntervalTypeNotRegisteredException; |
41 |
import org.gvsig.timesupport.Interval; |
|
34 | 42 |
import org.gvsig.timesupport.swing.api.TimeSupportSwingException; |
35 | 43 |
import org.gvsig.timesupport.swing.api.TimeSupportSwingLocator; |
36 | 44 |
import org.gvsig.timesupport.swing.api.TimeSupportSwingManager; |
37 | 45 |
import org.gvsig.timesupport.swing.api.panel.TimeSelectorPanel; |
38 |
import org.gvsig.tools.exception.BaseException; |
|
39 | 46 |
import org.gvsig.tools.locator.LocatorException; |
40 | 47 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
41 | 48 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
42 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
43 |
import org.gvsig.tools.visitor.Visitor; |
|
44 |
import org.slf4j.Logger; |
|
45 |
import org.slf4j.LoggerFactory; |
|
46 | 49 |
|
47 | 50 |
/** |
48 | 51 |
* Andami extension to show TimeSupport in the application. |
... | ... | |
51 | 54 |
* @version $Id$ |
52 | 55 |
*/ |
53 | 56 |
public class TimeSupportExtension extends Extension { |
54 |
|
|
55 |
private static final Logger logger = LoggerFactory.getLogger(TimeSupportExtension.class); |
|
56 |
|
|
57 |
|
|
58 |
@Override |
|
57 | 59 |
public void initialize() { |
58 | 60 |
// Do nothing |
59 | 61 |
} |
... | ... | |
63 | 65 |
super.postInitialize(); |
64 | 66 |
} |
65 | 67 |
|
68 |
@Override |
|
66 | 69 |
public void execute(String actionCommand) { |
67 | 70 |
try { |
68 | 71 |
showTimeSupport(); |
... | ... | |
72 | 75 |
} |
73 | 76 |
|
74 | 77 |
public void showTimeSupport() throws CloneNotSupportedException, LocatorException, TimeSupportSwingException, AbsoluteIntervalTypeNotRegisteredException { |
75 |
|
|
76 | 78 |
ApplicationManager application = ApplicationLocator.getManager(); |
77 | 79 |
ViewDocument viewDocument = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
78 | 80 |
if( viewDocument == null ) { |
79 | 81 |
return; |
80 |
} |
|
81 |
|
|
82 |
} |
|
82 | 83 |
TimeSupportSwingManager swingManager = TimeSupportSwingLocator.getSwingManager(); |
83 | 84 |
|
84 | 85 |
MapContext mapContext = viewDocument.getMapContext(); |
... | ... | |
94 | 95 |
windowManager.showWindow(timeSelectorPanel, viewDocument.getName(), WindowManager.MODE.TOOL); |
95 | 96 |
} |
96 | 97 |
|
97 |
public boolean isEnabled() {
|
|
98 |
|
|
98 |
@Override
|
|
99 |
public boolean isEnabled() { |
|
99 | 100 |
ApplicationManager application = ApplicationLocator.getManager(); |
100 | 101 |
ViewDocument viewDocument = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
101 | 102 |
if( viewDocument == null ) { |
102 | 103 |
return false; |
103 | 104 |
} |
104 |
final MutableBoolean enabled = new MutableBoolean(false); |
|
105 |
|
|
106 |
MapContext mapContext = viewDocument.getMapContext(); |
|
107 |
try { |
|
108 |
mapContext.getLayers().accept(new Visitor() { |
|
109 |
public void visit(Object layer) throws VisitCanceledException, BaseException { |
|
110 |
if (layer instanceof SingleLayer){ |
|
111 |
DataStore dataStore = ((SingleLayer)layer).getDataStore(); |
|
112 |
if (dataStore.getInterval() != null){ |
|
113 |
enabled.setValue(true); |
|
114 |
throw new VisitCanceledException(); |
|
115 |
} |
|
116 |
} |
|
105 |
FLayers layers = viewDocument.getMapContext().getLayers(); |
|
106 |
for( Iterator<FLayer> iterator = layers.deepiterator(); iterator.hasNext(); ) { |
|
107 |
FLayer layer = iterator.next(); |
|
108 |
if (layer instanceof SingleLayer){ |
|
109 |
DataStore dataStore = ((SingleLayer)layer).getDataStore(); |
|
110 |
if (dataStore.getInterval() != null){ |
|
111 |
return true; |
|
117 | 112 |
} |
118 |
}); |
|
119 |
} catch (Exception ex) { |
|
120 |
logger.warn("Unable to determine if there are layers with temporal information.",ex); |
|
113 |
} |
|
121 | 114 |
} |
122 |
|
|
123 |
return enabled.getValue(); |
|
115 |
return false; |
|
124 | 116 |
} |
125 | 117 |
|
118 |
@Override |
|
126 | 119 |
public boolean isVisible() { |
127 | 120 |
return true; |
128 | 121 |
} |
129 |
|
|
122 |
|
|
130 | 123 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.timesupport.app/org.gvsig.timesupport.app.viewfilter/src/main/java/org/gvsig/timesupport/app/extension/MapContextToInterval.java | ||
---|---|---|
22 | 22 |
package org.gvsig.timesupport.app.extension; |
23 | 23 |
|
24 | 24 |
import java.util.ArrayList; |
25 |
import java.util.Iterator; |
|
25 | 26 |
import java.util.List; |
26 | 27 |
|
27 | 28 |
import org.slf4j.Logger; |
... | ... | |
30 | 31 |
import org.gvsig.fmap.dal.DataStore; |
31 | 32 |
import org.gvsig.fmap.mapcontext.MapContext; |
32 | 33 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
33 |
import org.gvsig.fmap.mapcontext.layers.LayersIterator;
|
|
34 |
import org.gvsig.fmap.mapcontext.layers.FLayers;
|
|
34 | 35 |
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer; |
35 | 36 |
import org.gvsig.timesupport.AbsoluteInstant; |
36 | 37 |
import org.gvsig.timesupport.AbsoluteIntervalTypeNotRegisteredException; |
... | ... | |
50 | 51 |
public class MapContextToInterval { |
51 | 52 |
private static final Logger LOG = LoggerFactory.getLogger(MapContextToInterval.class); |
52 | 53 |
|
53 |
private static final TimeSupportManager TIME_SUPPORT_MANAGER = TimeSupportLocator.getManager(); |
|
54 |
|
|
55 |
private MapContext mapContext; |
|
54 |
private final MapContext mapContext; |
|
56 | 55 |
private Interval interval = null; |
57 |
private List<Time> times; |
|
56 |
private final List<Time> times;
|
|
58 | 57 |
|
59 | 58 |
public MapContextToInterval(MapContext mapContext) { |
60 | 59 |
super(); |
... | ... | |
77 | 76 |
|
78 | 77 |
|
79 | 78 |
public void update(){ |
80 |
LayersIterator it = new LayersIterator(mapContext.getLayers()); |
|
79 |
TimeSupportManager timeSupportManager = TimeSupportLocator.getManager(); |
|
80 |
|
|
81 | 81 |
Instant minInstant = null; |
82 | 82 |
Instant maxInstant = null; |
83 | 83 |
times.clear(); |
84 | 84 |
interval = null; |
85 | 85 |
|
86 | 86 |
//TODO Separate absolute and relative time |
87 |
while (it.hasNext()){ |
|
88 |
FLayer layer = it.nextLayer(); |
|
87 |
FLayers layers = mapContext.getLayers(); |
|
88 |
for( Iterator<FLayer> iterator = layers.deepiterator(); iterator.hasNext(); ) { |
|
89 |
FLayer layer = iterator.next(); |
|
89 | 90 |
if (layer instanceof SingleLayer){ |
90 | 91 |
DataStore dataStore = ((SingleLayer)layer).getDataStore(); |
91 | 92 |
if (dataStore.getInterval() != null){ |
... | ... | |
99 | 100 |
if (minInstant.isAfter(startInstant)){ |
100 | 101 |
minInstant = startInstant; |
101 | 102 |
} |
102 |
if (maxInstant.isBefore(endInstant)) |
|
103 |
if (maxInstant.isBefore(endInstant)) {
|
|
103 | 104 |
maxInstant = endInstant; |
105 |
} |
|
104 | 106 |
} |
105 | 107 |
} |
106 | 108 |
} |
... | ... | |
109 | 111 |
if (minInstant != null){ |
110 | 112 |
if (minInstant.isAbsolute()){ |
111 | 113 |
try { |
112 |
interval = TIME_SUPPORT_MANAGER.createAbsoluteInterval((AbsoluteInstant)minInstant, (AbsoluteInstant)maxInstant);
|
|
114 |
interval = timeSupportManager.createAbsoluteInterval((AbsoluteInstant)minInstant, (AbsoluteInstant)maxInstant);
|
|
113 | 115 |
} catch (AbsoluteIntervalTypeNotRegisteredException e) { |
114 |
LOG.error("Error creating the time interval", e);
|
|
116 |
LOG.warn("Error creating the time interval", e);
|
|
115 | 117 |
} |
116 | 118 |
}else{ |
117 |
interval = TIME_SUPPORT_MANAGER.createRelativeInterval(((RelativeInstant)minInstant).toMillis(), ((RelativeInstant)maxInstant).toMillis()); |
|
119 |
interval = timeSupportManager.createRelativeInterval(((RelativeInstant)minInstant).toMillis(), ((RelativeInstant)maxInstant).toMillis()); |
Also available in: Unified diff