net.sf.clichart.chart
Class AbstractChartBuilder

java.lang.Object
  extended by net.sf.clichart.chart.AbstractChartBuilder
All Implemented Interfaces:
DataSink
Direct Known Subclasses:
TimeSeriesChartBuilder, XYChartBuilder

public abstract class AbstractChartBuilder
extends java.lang.Object
implements DataSink

Base class for objects that can build and return a chart based on a data series provided by the DataSink interface. Note that these objects can also be used to add a second axis to an existing chart, so when adding a second axis, should create two of the same subclass (one for each axis), call getChart() on the first, and addSecondAxis() on the second WARNING: Not threadsafe

Author:
johnd

Field Summary
protected  Options m_options
           
protected  java.lang.String[] m_seriesTitles
           
 
Constructor Summary
protected AbstractChartBuilder(Options options, java.lang.String[] seriesTitles)
           
 
Method Summary
 void addSecondAxis(org.jfree.chart.JFreeChart chart, Options options)
          Add the data set as the second axis to this chart
protected abstract  void addYValue(int columnNumber, java.lang.Object xValue, java.lang.Object yValue)
          Called for subclass to add this yValue to the appropriate series
 void dataParsed(java.lang.Object xValue, java.lang.Object[] yValues, int lineNumber)
          Provides the data from a line of tabular data that has been parsed from some source.
 org.jfree.chart.JFreeChart getChart(Options options)
          Must be called *after* all parsing is finished
protected abstract  org.jfree.chart.JFreeChart getChartImpl(Options options)
          Called for subclass to create the required chart object, containing all the data provided
protected abstract  org.jfree.data.xy.XYDataset getDataset()
          Return the dataset containing all the data provided - used to add the second axis
protected abstract  org.jfree.chart.labels.XYToolTipGenerator getToolTipGenerator()
          Return an appropriate tooltip generator for a new renderer
 void headerParsed(java.lang.String[] headers)
          Provides a column header for tabular data that has been parsed from some source
protected abstract  void initialiseSeriesColumn(java.lang.String title)
          Called for subclass to create and register the appropriate data series for the column with this title
 void parsingFinished()
          Advice that parsing of the source has been completed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_options

protected final Options m_options

m_seriesTitles

protected final java.lang.String[] m_seriesTitles
Constructor Detail

AbstractChartBuilder

protected AbstractChartBuilder(Options options,
                               java.lang.String[] seriesTitles)
Method Detail

headerParsed

public void headerParsed(java.lang.String[] headers)
                  throws InvalidDataException
Description copied from interface: DataSink
Provides a column header for tabular data that has been parsed from some source

Specified by:
headerParsed in interface DataSink
Parameters:
headers - String headers for each column of interest (elements may be an empty string, but not null). Note that there should be as many headers as there are yValues in dataParsed()
Throws:
InvalidDataException

dataParsed

public void dataParsed(java.lang.Object xValue,
                       java.lang.Object[] yValues,
                       int lineNumber)
                throws InvalidDataException
Description copied from interface: DataSink
Provides the data from a line of tabular data that has been parsed from some source. Values are represented as (hopefully) useful objects, e.g. Long, Integer, Double, Date

Specified by:
dataParsed in interface DataSink
Parameters:
xValue - The X axis value for the data (often a date/time).
yValues - An array of size (headers.length - 1)
lineNumber - The 1-based line number for this line in the data source
Throws:
InvalidDataException

parsingFinished

public void parsingFinished()
Description copied from interface: DataSink
Advice that parsing of the source has been completed

Specified by:
parsingFinished in interface DataSink

getChart

public org.jfree.chart.JFreeChart getChart(Options options)
Must be called *after* all parsing is finished

Returns:
the chart ready to be embellished and displayed

addSecondAxis

public void addSecondAxis(org.jfree.chart.JFreeChart chart,
                          Options options)
Add the data set as the second axis to this chart


initialiseSeriesColumn

protected abstract void initialiseSeriesColumn(java.lang.String title)
Called for subclass to create and register the appropriate data series for the column with this title

Parameters:
title -

addYValue

protected abstract void addYValue(int columnNumber,
                                  java.lang.Object xValue,
                                  java.lang.Object yValue)
Called for subclass to add this yValue to the appropriate series

Parameters:
columnNumber - The 0-based index into the dataColumnIndexes array
xValue - The x axis value for this row
yValue - The y axis value for this row and column number

getChartImpl

protected abstract org.jfree.chart.JFreeChart getChartImpl(Options options)
Called for subclass to create the required chart object, containing all the data provided

Returns:
the chart ready to be embellished and displayed

getDataset

protected abstract org.jfree.data.xy.XYDataset getDataset()
Return the dataset containing all the data provided - used to add the second axis


getToolTipGenerator

protected abstract org.jfree.chart.labels.XYToolTipGenerator getToolTipGenerator()
Return an appropriate tooltip generator for a new renderer