1 /* 2 StatCvs - CVS statistics generation 3 Copyright (C) 2002 Lukasz Pekacki <lukasz@pekacki.de> 4 http://statcvs.sf.net/ 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License as published by the Free Software Foundation; either 9 version 2.1 of the License, or (at your option) any later version. 10 11 This library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with this library; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 20 $RCSfile: FileCountTimeLineReport.java,v $ 21 $Date: 2008/04/02 11:22:15 $ 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 }