| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AvgFileSizeTimeLineReport |
|
| 2.0;2 |
| 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: AvgFileSizeTimeLineReport.java,v $ | |
| 21 | $Date: 2008/04/02 11:22:15 $ | |
| 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 | * Time line for the average file size from a specified file list. | |
| 38 | * | |
| 39 | * @author Richard Cyganiak <rcyg@gmx.de> | |
| 40 | * @version $Id: AvgFileSizeTimeLineReport.java,v 1.6 2008/04/02 11:22:15 benoitx Exp $ | |
| 41 | */ | |
| 42 | public class AvgFileSizeTimeLineReport { | |
| 43 | private final TimeLine timeLine; | |
| 44 | ||
| 45 | /** | |
| 46 | * Creates a new file count time line for a specified list of files. | |
| 47 | * @param files a list of {@link net.sf.statcvs.model.VersionedFile}s | |
| 48 | */ | |
| 49 | 0 | public AvgFileSizeTimeLineReport(final SortedSet files) { |
| 50 | 0 | timeLine = new TimeLine(Messages.getString("AVERAGE_FILE_SIZE_TITLE"), Messages.getString("RANGE_LOC_PER_FILE")); |
| 51 | 0 | final List revisions = new ArrayList(); |
| 52 | 0 | final Iterator filesIt = files.iterator(); |
| 53 | 0 | while (filesIt.hasNext()) { |
| 54 | 0 | final VersionedFile file = (VersionedFile) filesIt.next(); |
| 55 | 0 | revisions.addAll(file.getRevisions()); |
| 56 | 0 | } |
| 57 | 0 | Collections.sort(revisions); |
| 58 | 0 | final Iterator it = revisions.iterator(); |
| 59 | 0 | int loc = 0; |
| 60 | 0 | int fileCount = 0; |
| 61 | 0 | while (it.hasNext()) { |
| 62 | 0 | final Revision rev = (Revision) it.next(); |
| 63 | 0 | loc += rev.getLinesDelta(); |
| 64 | 0 | fileCount += rev.getFileCountDelta(); |
| 65 | 0 | final int ratio = (fileCount == 0) ? 0 : loc / fileCount; |
| 66 | 0 | timeLine.addTimePoint(rev.getDate(), ratio); |
| 67 | 0 | } |
| 68 | 0 | } |
| 69 | ||
| 70 | /** | |
| 71 | * Returns the result time line | |
| 72 | * @return the result time line | |
| 73 | */ | |
| 74 | public TimeLine getTimeLine() { | |
| 75 | 0 | return timeLine; |
| 76 | } | |
| 77 | } |