1 package net.sf.statcvs.reports;
2
3 import java.util.Iterator;
4
5 import net.sf.statcvs.Messages;
6 import net.sf.statcvs.model.Author;
7 import net.sf.statcvs.output.ReportConfig;
8 import net.sf.statcvs.reportmodel.AuthorColumn;
9 import net.sf.statcvs.reportmodel.IntegerColumn;
10 import net.sf.statcvs.reportmodel.Table;
11
12
13
14
15
16
17
18
19 public class TopDevelopersTableReport extends AbstractLocTableReport implements TableReport {
20 private Table table = null;
21
22
23
24
25
26
27 public TopDevelopersTableReport(final ReportConfig config) {
28 super(config);
29 }
30
31
32
33
34 public void calculate() {
35 if (this.table != null) {
36 return;
37 }
38 String summary;
39 if (getDeveloperCount() > 10) {
40 summary = Messages.getString("TOP_AUTHORS_TABLE_SUMMARY1");
41 } else {
42 summary = Messages.getString("TOP_AUTHORS_TABLE_SUMMARY2");
43 }
44 table = new Table(summary);
45 final AuthorColumn authors = new AuthorColumn();
46 final IntegerColumn linesOfCode = new IntegerColumn(Messages.getString("COLUMN_LOC"));
47 linesOfCode.setShowPercentages(true);
48 table.addColumn(authors);
49 table.addColumn(linesOfCode);
50 table.setKeysInFirstColumn(true);
51
52 calculateChangesAndLinesPerDeveloper(getContent().getRevisions());
53 int lines = 0;
54 final Iterator it = getLinesMap().iteratorSortedByValueReverse();
55 while (it.hasNext()) {
56 final Author author = (Author) it.next();
57 authors.addValue(author);
58 linesOfCode.addValue(getLinesMap().get(author));
59 lines++;
60 if (lines == 10) {
61 break;
62 }
63 }
64 linesOfCode.setSum(getLinesMap().sum());
65 }
66
67
68
69
70 public Table getTable() {
71 return table;
72 }
73 }