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.Iterator;
26 import java.util.SortedSet;
27
28 import net.sf.statcvs.Messages;
29 import net.sf.statcvs.model.Revision;
30 import net.sf.statcvs.model.VersionedFile;
31 import net.sf.statcvs.reportmodel.TimeLine;
32
33 /**
34 * Time line for the number of non-dead files from a specified file list.
35 *
36 * @author Richard Cyganiak <rcyg@gmx.de>
37 * @version $Id: FileCountTimeLineReport.java,v 1.6 2008/04/02 11:22:15 benoitx Exp $
38 */
39 public class FileCountTimeLineReport {
40 private final TimeLine timeLine;
41
42 /**
43 * Creates a new file count time line for a specified list of files.
44 * @param files a list of {@link net.sf.statcvs.model.VersionedFile}s
45 */
46 public FileCountTimeLineReport(final SortedSet files) {
47 timeLine = new TimeLine(Messages.getString("FILE_COUNT_TITLE"), Messages.getString("RANGE_FILES"));
48 timeLine.setInitialValue(0);
49 final Iterator filesIt = files.iterator();
50 while (filesIt.hasNext()) {
51 final VersionedFile file = (VersionedFile) filesIt.next();
52 addRevisions(file);
53 }
54 }
55
56 /**
57 * Returns the result time line
58 * @return the result time line
59 */
60 public TimeLine getTimeLine() {
61 return timeLine;
62 }
63
64 private void addRevisions(final VersionedFile file) {
65 final Iterator it = file.getRevisions().iterator();
66 while (it.hasNext()) {
67 final Revision revision = (Revision) it.next();
68 if (revision.getFileCountDelta() != 0 || !it.hasNext()) {
69 this.timeLine.addChange(revision.getDate(), revision.getFileCountDelta());
70 }
71 }
72 }
73 }