ca.utoronto.JCVSReport.report
Class BasicGraph

java.lang.Object
  extended byca.utoronto.JCVSReport.report.BasicGraph
All Implemented Interfaces:
Graph
Direct Known Subclasses:
BarGraph, TimeSeriesGraph

public abstract class BasicGraph
extends Object
implements Graph

An abstract base class for representing a single graph.

This class implements:

Author:
David James

Field Summary
protected  MetricDatabase database
           
protected  MetricRevisionMap devMap
           
protected  MetricRevisionMap fileMap
           
protected  String id
           
protected  boolean incremental
           
protected  boolean perDeveloper
           
protected  ResourceBundle props
           
 
Constructor Summary
BasicGraph()
           
 
Method Summary
protected  ResultSet executeQuery()
          Execute our data gathering query If the user specifies an SQL query in the properties file for this graph, then we will use it.
protected abstract  org.jfree.chart.JFreeChart getChart()
          Build a chart from a dataset
protected abstract  org.jfree.data.general.Dataset getDataset()
          Build a dataset object from an SQL query
protected  int getHeight()
          Get the desired height of the chart
protected  String getKey(MetricRevision revision)
          Get the key attribute of a MetricRevision object.
 String[] getMetricNames()
          Get a list of the metrics supported by this graph
protected  String getProperty(String name)
          Get a property from the props resource bundle
protected  String getProperty(String name, String defaultValue)
          Get a property from the props resource bundle (return defaultValue if the property does not exist)
protected  String getSeriesLabel(MetricRevision revision)
          Get the label of a series on a graph from a MetricRevision object.
protected  double getStoredMetricValue(MetricRevision revision)
          Get the stored metric value associated with the specified MetricRevision
 String getTitle()
          Get the title of the object
protected  int getWidth()
          Get the desired width of the chart
protected  String getXLabel()
          Get the label for the x-axis
protected  String getYLabel()
          Get the label for the y-axis
 void init(MetricDatabase database, String id, ResourceBundle props)
          Initialize Graph from properties file
 void setPerDeveloper(boolean value)
          Set whether we should report this metric per developer
protected  void storeMetricValue(MetricRevision revision)
          Store the value associated with the current metric result so that it can be retreived later
 void write(PrintWriter output, File directory)
          Write a chart to disk and link to it in an HTML file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

props

protected ResourceBundle props

id

protected String id

database

protected MetricDatabase database

perDeveloper

protected boolean perDeveloper

incremental

protected boolean incremental

fileMap

protected MetricRevisionMap fileMap

devMap

protected MetricRevisionMap devMap
Constructor Detail

BasicGraph

public BasicGraph()
Method Detail

init

public void init(MetricDatabase database,
                 String id,
                 ResourceBundle props)
          throws Exception
Initialize Graph from properties file

Specified by:
init in interface Graph
Parameters:
database - Where to get our data
id - A unique ID for this graph
props - Properties of this graph
Throws:
Exception

write

public void write(PrintWriter output,
                  File directory)
           throws Exception
Write a chart to disk and link to it in an HTML file

Specified by:
write in interface Graph
Parameters:
output - Where to write the HTML report
directory - Where to store images
Throws:
Exception

getDataset

protected abstract org.jfree.data.general.Dataset getDataset()
                                                      throws Exception
Build a dataset object from an SQL query

Throws:
Exception

getChart

protected abstract org.jfree.chart.JFreeChart getChart()
                                                throws Exception
Build a chart from a dataset

Throws:
Exception

getProperty

protected String getProperty(String name)
Get a property from the props resource bundle

Parameters:
name - The name of the property

getProperty

protected String getProperty(String name,
                             String defaultValue)
Get a property from the props resource bundle (return defaultValue if the property does not exist)

Parameters:
name - The name of the property
defaultValue - The default value for the property (we return this if the property does not exist)

getTitle

public String getTitle()
Get the title of the object

Specified by:
getTitle in interface Graph

getHeight

protected int getHeight()
Get the desired height of the chart


getWidth

protected int getWidth()
Get the desired width of the chart


getXLabel

protected String getXLabel()
Get the label for the x-axis


getYLabel

protected String getYLabel()
Get the label for the y-axis


getKey

protected String getKey(MetricRevision revision)
Get the key attribute of a MetricRevision object. In this case, our key attribute is 'MetricName'

Parameters:
revision - The MetricRevision object
Returns:
the key attribute

setPerDeveloper

public void setPerDeveloper(boolean value)
Set whether we should report this metric per developer

Specified by:
setPerDeveloper in interface Graph
Parameters:
value - true or false

getSeriesLabel

protected String getSeriesLabel(MetricRevision revision)
Get the label of a series on a graph from a MetricRevision object. By default, we use the title of the metric as the label for the series.

Parameters:
revision - the MetricRevision object
Returns:
the series label

executeQuery

protected ResultSet executeQuery()
                          throws SQLException
Execute our data gathering query If the user specifies an SQL query in the properties file for this graph, then we will use it. Otherwise, we will generate a query using the provided list of metrics from the properties file.

Throws:
SQLException

storeMetricValue

protected void storeMetricValue(MetricRevision revision)
Store the value associated with the current metric result so that it can be retreived later

Parameters:
revision - The current metric result

getStoredMetricValue

protected double getStoredMetricValue(MetricRevision revision)
Get the stored metric value associated with the specified MetricRevision

Parameters:
revision - The specified MetricRevision

getMetricNames

public String[] getMetricNames()
Get a list of the metrics supported by this graph

Specified by:
getMetricNames in interface Graph


JCVSReport: Easy Progress Reports for CVS/Java Projects. By David James.