1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.statcvs.reports;
24
25 import java.util.ArrayList;
26 import java.util.Collections;
27 import java.util.Iterator;
28 import java.util.List;
29 import java.util.SortedSet;
30
31 import net.sf.statcvs.Messages;
32 import net.sf.statcvs.model.Revision;
33 import net.sf.statcvs.model.VersionedFile;
34 import net.sf.statcvs.reportmodel.TimeLine;
35
36
37
38
39
40
41
42 public class AvgFileSizeTimeLineReport {
43 private final TimeLine timeLine;
44
45
46
47
48
49 public AvgFileSizeTimeLineReport(final SortedSet files) {
50 timeLine = new TimeLine(Messages.getString("AVERAGE_FILE_SIZE_TITLE"), Messages.getString("RANGE_LOC_PER_FILE"));
51 final List revisions = new ArrayList();
52 final Iterator filesIt = files.iterator();
53 while (filesIt.hasNext()) {
54 final VersionedFile file = (VersionedFile) filesIt.next();
55 revisions.addAll(file.getRevisions());
56 }
57 Collections.sort(revisions);
58 final Iterator it = revisions.iterator();
59 int loc = 0;
60 int fileCount = 0;
61 while (it.hasNext()) {
62 final Revision rev = (Revision) it.next();
63 loc += rev.getLinesDelta();
64 fileCount += rev.getFileCountDelta();
65 final int ratio = (fileCount == 0) ? 0 : loc / fileCount;
66 timeLine.addTimePoint(rev.getDate(), ratio);
67 }
68 }
69
70
71
72
73
74 public TimeLine getTimeLine() {
75 return timeLine;
76 }
77 }