Revision 43610 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

View differences:

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());  
118 120
            }               
119 121
        }        
120 122
    }

Also available in: Unified diff