1 package net.sf.statcvs.pages;
2
3 import java.util.ArrayList;
4 import java.util.Collections;
5 import java.util.Iterator;
6 import java.util.List;
7
8 import net.sf.statcvs.charts.ChartImage;
9 import net.sf.statcvs.charts.CommitScatterChartMaker;
10 import net.sf.statcvs.charts.ModifyAddChartMaker;
11 import net.sf.statcvs.charts.LOCChartMaker.AllDevelopersLOCChartMaker;
12 import net.sf.statcvs.charts.TimeBarChartMaker.HourBarChartMaker;
13 import net.sf.statcvs.charts.TimeBarChartMaker.WeekdayBarChartMaker;
14 import net.sf.statcvs.model.Author;
15 import net.sf.statcvs.output.ReportConfig;
16 import net.sf.statcvs.reports.DevelopersOfTheMonthTable;
17 import net.sf.statcvs.reports.DevelopersTableReport;
18
19
20
21
22
23
24 public class AllDevelopersPageMaker {
25 private final ReportConfig config;
26
27 public AllDevelopersPageMaker(final ReportConfig config) {
28 this.config = config;
29 }
30
31 public NavigationNode toFile() {
32 final DevelopersTableReport developers = new DevelopersTableReport(this.config);
33
34 final Page page = this.config.createPage("developers", "Developers", this.config.getProjectName() + " Developers");
35 if (developers.getDeveloperCount() > 1) {
36 page.addAttribute("Number of Developers", developers.getDeveloperCount());
37 page.add(developers);
38 page.addRawContent(getOtherLoginsLinks());
39 page.addSection("Lines of Code");
40 final ChartImage allAuthorsLOCChart = new AllDevelopersLOCChartMaker(this.config, this.config.getLargeChartSize()).toFile();
41 page.add(allAuthorsLOCChart);
42 }
43
44 final ChartImage hoursChart = new HourBarChartMaker(this.config, this.config.getRepository().getRevisions(), "Activity by Hour of Day",
45 "activity_time.png").toFile();
46 final ChartImage weekdaysChart = new WeekdayBarChartMaker(this.config, this.config.getRepository().getRevisions(), "Activity by Day of Week",
47 "activity_day.png").toFile();
48 final ChartImage scatterChart = new CommitScatterChartMaker(this.config, this.config.getLargeChartSize().width).toFile();
49 final ChartImage modifyAddChart = new ModifyAddChartMaker(this.config, this.config.getSmallChartSize().width).toFile();
50
51 final DevelopersOfTheMonthTable developerOfTheMonth = new DevelopersOfTheMonthTable(this.config);
52 page.addSection("Developer of the Month");
53 page.add(developerOfTheMonth);
54
55 page.addSection("Developer Activity");
56 page.add(scatterChart);
57 page.add(modifyAddChart);
58
59 page.addSection("Activity by Clock Time");
60 page.add(hoursChart);
61 page.add(weekdaysChart);
62
63 if (this.config.getRepository().getAuthors().size() >= 1) {
64 final PageGroup developerPages = new PageGroup("Developers", false);
65 final Iterator it = this.config.getRepository().getAuthors().iterator();
66 while (it.hasNext()) {
67 final Author developer = (Author) it.next();
68 developerPages.add(new DeveloperPageMaker(this.config, developer).toFile());
69 }
70 page.addChild(developerPages);
71 }
72
73 return page;
74 }
75
76 private String getOtherLoginsLinks() {
77 final List nonDeveloperLogins = new ArrayList();
78 Iterator it = this.config.getRepository().getAuthors().iterator();
79 while (it.hasNext()) {
80 final Author author = (Author) it.next();
81 if (!this.config.isDeveloper(author)) {
82 nonDeveloperLogins.add(author);
83 }
84 }
85 if (nonDeveloperLogins.isEmpty()) {
86 return "";
87 }
88 Collections.sort(nonDeveloperLogins);
89 final StringBuffer s = new StringBuffer("<p>\n Other Logins:\n ");
90 it = nonDeveloperLogins.iterator();
91 while (it.hasNext()) {
92 final Author author = (Author) it.next();
93 s.append(HTML.getLink(DeveloperPageMaker.getURL(author), author.getRealName()));
94 if (it.hasNext()) {
95 s.append(", \n ");
96 }
97 }
98 s.append("</p>\n");
99 return s.toString();
100 }
101 }