planetj.chart
Class ChartManager

java.lang.Object
  |
  +--planetj.chart.ChartManager
All Implemented Interfaces:
IChartTypes

public class ChartManager
extends Object
implements IChartTypes

Helper class that may be used to create charts and graphs from given RowCollections or Rows. Properties that are needed to create the charts are contained within a chart specification property group. This class uses JFreeChart behind the scenes.

Author:
PlanetJ Corporation
See Also:
ChartSpecificationPG, IChartTypes

Field Summary
 
Fields inherited from interface planetj.chart.IChartTypes
HORIZONTAL_BAR, HORIZONTAL_BAR_3D, HORIZONTAL_BAR_3D_KEY, HORIZONTAL_BAR_KEY, LINE, LINE_KEY, PIE, PIE_3D, PIE_3D_KEY, PIE_KEY, UNKNOWN, VERTICAL_BAR, VERTICAL_BAR_3D, VERTICAL_BAR_3D_KEY, VERTICAL_BAR_KEY
 
Method Summary
 com.jrefinery.chart.JFreeChart createCategoryChart(RowCollection data, ChartSpecificationPG chartSpecs)
           
 com.jrefinery.chart.JFreeChart createChart(RowCollection data, ChartSpecificationPG chartSpecs)
          Convience method to create a JFreeChart given the data and chart specifications.
 com.jrefinery.data.CategoryDataset getCategoryDataset(RowCollection rc, ChartSpecificationPG chartSpecs)
          Creates a CategoryDataset using the given chart specifications and data.
 ChartSpecificationPG getChartSpecifications(String chartId, RowCollection rc)
          Convience method to retrieve a chart specification property group that has the given chart id from a given RowCollection.
 int getType(String type)
          Gets the type of chart to generate from the given chart abbreviation key.
static void setSingleton(ChartManager singleton)
          Allow subclasses to be set as the signleton instance to use.
static ChartManager singleton()
          Gets the singleton instance of ChartManager.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createCategoryChart

public com.jrefinery.chart.JFreeChart createCategoryChart(RowCollection data,
                                                          ChartSpecificationPG chartSpecs)
                                                   throws CMException
CMException

createChart

public com.jrefinery.chart.JFreeChart createChart(RowCollection data,
                                                  ChartSpecificationPG chartSpecs)
                                           throws CMException
Convience method to create a JFreeChart given the data and chart specifications.

Parameters:
data - RowCollection containing data to chart.
chartSpecs - properties on how the chart should be generated.
Returns:
JFreeChart generated from the given data and chart specifications.
CMException

getCategoryDataset

public com.jrefinery.data.CategoryDataset getCategoryDataset(RowCollection rc,
                                                             ChartSpecificationPG chartSpecs)
                                                      throws CMException
Creates a CategoryDataset using the given chart specifications and data.

Returns:
dataset that may be used to create a JFreechart.
CMException

getChartSpecifications

public ChartSpecificationPG getChartSpecifications(String chartId,
                                                   RowCollection rc)
Convience method to retrieve a chart specification property group that has the given chart id from a given RowCollection. If more than one property group contains that chart id, then the first one is returned.

Parameters:
chartId - id of the chart to retrieve chart specifications for.
rc - RowCollection containing chart property groups.

getType

public int getType(String type)
Gets the type of chart to generate from the given chart abbreviation key.

Parameters:
type - chart abbreviation key used to get the chart type
Returns:
an int representing the type of chart to generate (see IChartTypes)

setSingleton

public static void setSingleton(ChartManager singleton)
Allow subclasses to be set as the signleton instance to use. The signleton instance is not synchronized, so this method must be invoked before the singleton is accessed.

Parameters:
singleton - helper class to use as the ChartManager.

singleton

public static ChartManager singleton()
Gets the singleton instance of ChartManager.

Returns:
singleton instance of the ChartManager.