View Javadoc

1   package net.sf.statcvs.pages;
2   
3   import java.util.Iterator;
4   import java.util.List;
5   
6   import net.sf.statcvs.Messages;
7   import net.sf.statcvs.charts.ChartImage;
8   import net.sf.statcvs.charts.ModuleEvolutionChartMaker;
9   import net.sf.statcvs.charts.ModuleSizePieChartMaker;
10  import net.sf.statcvs.charts.LOCChartMaker.AllModulesLOCChartMaker;
11  import net.sf.statcvs.model.Repository;
12  import net.sf.statcvs.output.ReportConfig;
13  import net.sf.statcvs.reports.ModuleTableReport;
14  import net.sf.statcvs.reports.TableReport;
15  import net.sf.statcvs.util.ModuleUtil;
16  
17  /**
18   * @author anja
19   * @author Richard Cyganiak (richard@cyganiak.de)
20   * @version $Id: ModulesPageMaker.java,v 1.3 2009/08/31 20:13:25 benoitx Exp $
21   */
22  public class ModulesPageMaker {
23      private final ReportConfig config;
24      private final Repository repository;
25  
26      public ModulesPageMaker(final ReportConfig config) {
27          this.config = config;
28          this.repository = config.getRepository();
29      }
30  
31      public NavigationNode toFile() {
32          final ChartImage allDirLOCChart = new AllModulesLOCChartMaker(this.config, 6).toFile();
33          final Page page = this.config.createPage("modules", Messages.getString("MODULES_SIZES_TITLE"), Messages.getString("MODULES_SIZES_SUBTITLE"));
34          final List moduleIds = ModuleUtil.getConfigModules();
35          final Iterator mod = moduleIds.iterator();
36          while (mod.hasNext()) {
37              final String moduleId = (String) mod.next();
38              final String pattern = ModuleUtil.getConfigModuleRegexp(moduleId);
39              final String name = ModuleUtil.getConfigModuleName(moduleId);
40              page.addAttribute(name, pattern);
41          }
42  
43          page.addSection(Messages.getString("MODULES_CURRENT_SIZES_TITLE"));
44          final ChartImage dirSizesChart = new ModuleSizePieChartMaker("modules_sizes", this.config, Messages.getString("PIE_MODSIZE_TITLE"), Messages
45                  .getString("PIE_MODSIZE_SUBTITLE"), "modules_sizes.png").toFile();
46          page.add(dirSizesChart);
47  
48          final TableReport table = new ModuleTableReport(this.repository);
49  
50          //        page.addAttribute("Total Directories", this.repository.getDirectories().size());
51          page.addSection(Messages.getString("MODULES_LOC_TITLE"));
52          page.add(allDirLOCChart);
53          page.addSection(Messages.getString("MODULES_EVO_TITLE"));
54          final ChartImage modEvoChart = new ModuleEvolutionChartMaker("modules_evolution", this.config, Messages.getString("MODULE_EVO_TITLE"),
55                  "modules_evolution.png").toFile();
56          page.add(modEvoChart);
57          page.addSection(Messages.getString("MODULES_STATS_TITLE"));
58          page.add(table);
59  
60          return page;
61      }
62  }