Coverage details for net.sf.tourviewer.lib.Tour

LineHitsSource
1 package net.sf.tourviewer.lib;
2  
3 import java.util.ArrayList;
4 import java.util.Date;
5 import java.util.List;
6  
7 public class Tour implements Comparable {
8  
90    private boolean autoStatistics = true;
10     double avgAltitudeInc;
11     double avgPulse;
12     double avgSlope;
13     double avgSpeed;
14     double avgTemperature;
15     private Bike bike;
16     private long distance;
17     private String endLocation;
18     private Date endTime;
190    private List<Marker> markers = new ArrayList<Marker>();
20     int maxAltitude;
21     private String note;
220    private List<TourRecord> records = new ArrayList<TourRecord>();
23     private String startLocation;
24     private Date startTime;
25     private String title;
26     int totalAltitudeDown;
27     int totalAltitudeUp;
28     private long travelTime;
29     private Type type;
30         
31     public Tour()
320    {
330    }
34     
35     public void addMarker(Marker marker)
36     {
370        markers.add(marker);
380    }
39  
40     public void addRecord(TourRecord record)
41     {
420        if (!records.isEmpty()) {
430            TourRecord previous = records.get(records.size() - 1);
440            previous.setNext(record);
450            record.setPrevious(previous);
46  
470            if (isAutoStatistics()) {
480                maxAltitude = Math.max(maxAltitude, record.getAltitude());
490                updateStatistics(previous, record);
50             }
510        }
520        else if (isAutoStatistics()) {
530            maxAltitude = record.getAltitude();
54         }
550        records.add(record);
560    }
57     
58     public int compareTo(Object o)
59     {
600        return getStartTime().compareTo(((Tour)o).getStartTime());
61     }
62  
63     public double getAvgAltitudeInc()
64     {
650        return avgAltitudeInc;
66     }
67     
68     public double getAvgPulse()
69     {
700        return avgPulse;
71     }
72  
73     public double getAvgSlope()
74     {
750        return avgSlope;
76     }
77  
78     public double getAvgSpeed()
79     {
800        return avgSpeed;
81     }
82  
83     public double getAvgTemperature()
84     {
850        return avgTemperature;
86     }
87     
88     public Bike getBike()
89     {
900        return bike;
91     }
92     
93     public long getDistance()
94     {
950        return distance;
96     }
97     
98     public String getEndLocation()
99     {
1000        return endLocation;
101     }
102     
103     public Date getEndTime()
104     {
1050        return endTime;
106     }
107     
108     public int getMaxAltitude()
109     {
1100        return maxAltitude;
111     }
112  
113     public String getNote()
114     {
1150        return note;
116     }
117     
118     public TourRecord[] getRecords() {
1190        return records.toArray(new TourRecord[0]);
120     }
121  
122     public String getStartLocation()
123     {
1240        return startLocation;
125     }
126     
127     public Date getStartTime()
128     {
1290        return startTime;
130     }
131     
132     public String getTitle()
133     {
1340        return title;
135     }
136  
137     public int getTotalAltitudeDown()
138     {
1390        return totalAltitudeDown;
140     }
141  
142     
143     public int getTotalAltitudeUp()
144     {
1450        return totalAltitudeUp;
146     }
147  
148     public long getTravelTime()
149     {
1500        return travelTime;
151     }
152  
153     
154     public Type getType()
155     {
1560        return type;
157     }
158     
159     public boolean isAutoStatistics()
160     {
1610        return autoStatistics;
162     }
163  
164     public void setAutoStatistics(boolean autoStatistics)
165     {
1660        this.autoStatistics = autoStatistics;
1670    }
168     
169     public void setAvgAltitudeInc(double avgAltitudeInc)
170     {
1710        this.avgAltitudeInc = avgAltitudeInc;
1720    }
173     
174     public void setAvgPulse(double avgPulse)
175     {
1760        this.avgPulse = avgPulse;
1770    }
178  
179     public void setAvgSlope(double avgSlope)
180     {
1810        this.avgSlope = avgSlope;
1820    }
183  
184     public void setAvgSpeed(double avgSpeed)
185     {
1860        this.avgSpeed = avgSpeed;
1870    }
188     
189     public void setAvgTemperature(double avgTemperature)
190     {
1910        this.avgTemperature = avgTemperature;
1920    }
193  
194     public void setBike(Bike bike)
195     {
1960        this.bike = bike;
1970    }
198  
199     
200     public void setDistance(long distance)
201     {
2020        this.distance = distance;
2030    }
204     
205     public void setEndLocation(String endLocation)
206     {
2070        this.endLocation = endLocation;
2080    }
209     
210     public void setEndTime(Date endTime)
211     {
2120        this.endTime = endTime;
2130    }
214     
215     public void setMaxAltitude(int maxAltitude)
216     {
2170        this.maxAltitude = maxAltitude;
2180    }
219     
220     public void setNote(String note)
221     {
2220        this.note = note;
2230    }
224     
225     public void setStartLocation(String startLocation)
226     {
2270        this.startLocation = startLocation;
2280    }
229  
230     public void setStartTime(Date startTime)
231     {
2320        this.startTime = startTime;
2330    }
234     
235     public void setTitle(String title)
236     {
2370        this.title = title;
2380    }
239     
240     public void setTotalAltitudeDown(int totalAltitudeDown)
241     {
2420        this.totalAltitudeDown = totalAltitudeDown;
2430    }
244     
245     public void setTotalAltitudeUp(int totalAltitudeUp)
246     {
2470        this.totalAltitudeUp = totalAltitudeUp;
2480    }
249  
250     public void setTravelTime(long travelTime)
251     {
2520        this.travelTime = travelTime;
2530    }
254     
255     public void setType(Type type)
256     {
2570        this.type = type;
2580    }
259     
260     @Override
261     public String toString()
262     {
2630        return getClass().getName() + String.format("[type=%s,distance=%d,startTime=%tF %tT,endTime=%tF %tT]",
264                 type, distance, startTime, startTime, endTime, endTime);
265     }
266  
267     
268     private void updateStatistics(TourRecord previous, TourRecord current)
269     {
2700        int altitudeDiff = current.getAltitude() - previous.getAltitude();
2710        avgAltitudeInc = current.getAltitude();
2720        if (altitudeDiff > 0) {
2730            totalAltitudeUp += altitudeDiff;
2740        }
275         else {
2760            totalAltitudeDown += -altitudeDiff;
277         }
278  
2790        long timeDiff = (current.getTime().getTime() - previous.getTime().getTime()) / 1000;
2800        long distanceDiff = current.getDistance() - previous.getDistance();
2810        if (distanceDiff != 0 && timeDiff > 0) {
2820            long newTravelTime = travelTime + timeDiff;
2830            double leftShare = travelTime / newTravelTime;
2840            double rightShare = timeDiff / newTravelTime;
285             
2860            long slope = (altitudeDiff > 0) ? distanceDiff / altitudeDiff : 0;
2870            avgSlope = avgSlope * leftShare + slope * rightShare;
2880            double speed = (distanceDiff / timeDiff) * 3.6;
2890            avgSpeed = avgSpeed * leftShare + speed * rightShare;
2900            avgTemperature = avgTemperature * leftShare + current.getTemperature() * rightShare;
2910            avgPulse = avgPulse * leftShare + current.getPulse() * rightShare;
292             
2930            travelTime = newTravelTime;
294         }
2950    }
296  
297     
298     public enum Type { BIKE, JOGGING, SKI, SKI_BIKE, OTHER }
299  
300 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.