KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > japex > TrendReport


1 /*
2  * TrendReport.java
3  *
4  * Created on April 6, 2005, 5:48 PM
5  */

6
7 package com.sun.japex;
8 import com.sun.japex.report.*;
9
10 import java.io.File JavaDoc;
11 import java.util.Date JavaDoc;
12 import java.util.Calendar JavaDoc;
13 import java.util.GregorianCalendar JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.xml.sax.*;
17 import org.xml.sax.helpers.DefaultHandler JavaDoc;
18
19 import javax.xml.parsers.SAXParserFactory JavaDoc;
20 import javax.xml.parsers.ParserConfigurationException JavaDoc;
21 import javax.xml.parsers.SAXParser JavaDoc;
22
23 import org.jfree.chart.ChartUtilities;
24 import org.jfree.chart.JFreeChart;
25 import org.jfree.data.xy.XYDataset;
26
27 public class TrendReport {
28     
29     /** Creates a new instance of TrendReport */
30     public TrendReport() {
31     }
32     /**
33      * @param args the command line arguments
34      */

35     public static void main(String JavaDoc[] args) {
36         if (args.length < 4) {
37             displayUsageAndExit(args);
38         }
39         String JavaDoc reportPath = "/projects/fws/WSTest/Java/src/reports";
40         String JavaDoc separator = System.getProperty("file.separator");
41         try {
42 // File cwd = new File(reportPath);
43
// File[] reportDirs = cwd.listFiles(new ReportFilter("2005-03-18", "2005-03-22"));
44

45             TrendReportParams params = new TrendReportParams(args);
46             //parse reports under the Report direction
47
ParseReports testReports = new ParseReports(params);
48
49             //get Trend datasets
50
TrendDataset dataset = new TrendDataset(params, testReports);
51             JFreeChart chart1 = LineChart.createChart(params.title(), dataset.getDataset());
52
53             // Converts chart in JPEG file named chart.jpg
54
String JavaDoc chartName = null;
55             if (!params.isTestSpecified()) {
56                 chartName = "means.jpg";
57             } else {
58                 chartName = params.test()[0]+".jpg";
59             }
60 System.out.println("chartname: "+chartName);
61 System.out.println("test specified: "+params.isTestSpecified());
62
63             System.out.println(params.outputPath()+"/"+chartName);
64             ChartUtilities.saveChartAsJPEG(new File JavaDoc(params.outputPath()+"/"+chartName), chart1, 500, 300);
65             new IndexPage(params, chartName).report();
66             
67         } catch (Exception JavaDoc e) {
68             e.printStackTrace();
69         }
70         
71
72         System.exit(0);
73
74         
75     }
76
77     private static void displayUsageAndExit(String JavaDoc[] args) {
78         System.err.println("Usage: TrendReport Title reportPath outputPath date offset [driver] [test]");
79         System.err.println("Arguments passed in: \n");
80         for (int i=0; i<args.length; i++) {
81             System.err.println(i + " = " + args[i]);
82         }
83         System.exit(1);
84     }
85      
86 }
87
Popular Tags