org.keel.services.chart.jfreechart
Class JfreeChartChartFactory
java.lang.Object
org.keel.services.chart.jfreechart.JfreeChartChartFactory
- All Implemented Interfaces:
- ChartFactory, LogEnabled
- public class JfreeChartChartFactory
- extends java.lang.Object
- implements ChartFactory, LogEnabled
- Author:
- Michael Nash
| Fields inherited from interface org.keel.services.chart.ChartFactory |
AREA_CHART, AREA_XY_CHART, BAR_CHART, BAR_CHART_3D, BUBBLE_CHART, CANDLE_STICK_CHART, COMPASS_CHART, GANNT_CHART, HIGH_LOW_CHART, HISTOGRAM, LINE_CHART, LINE_XY_CHART, METER_CHART, PIE_CHART, PIE_CHART_3D, ROLE, SCATTER_PLOT_CHART, SIGNAL_CHART, STACKED_AREA_CHART, STACKED_BAR_CHART, STACKED_BAR_CHART_3D, TIME_SERIES_CHART, WIND_PLOT_CHART, XY_BAR_CHART, XY_STEP_CHART |
| Method Summary |
private JFreeChart |
areaChart()
|
private JFreeChart |
barChart()
|
private JFreeChart |
compassChart()
|
void |
enableLogging(Logger newLog)
Provide component with a logger. |
byte[] |
getChart(java.lang.String fileType, int width, int height)
|
java.lang.String |
getChartEncoded(java.lang.String fileType, int width, int height)
Return the chart as an encoded string |
private int |
getMaxPoints()
|
private boolean |
getOptionAsBoolean(java.lang.String optionName, boolean defaultValue)
|
private java.lang.Double |
getOptionAsDouble(java.lang.String optionName, java.lang.Double defaultValue)
|
private java.lang.String |
getOptionAsString(java.lang.String optionName, java.lang.String defaultValue)
|
java.util.Set |
getSupportedChartTypes()
Return a Set of integers, one for each of the support chart types for this implementation |
java.util.Set |
getSupportedFileTypes()
Return a set of strings, where each string represents the file-type extension of a type of file supported by this implementation. |
java.util.Set |
getSupportedOptions()
Once the chart type is set, getSupportedOptions can be called to determine what options (if any) this type of chart supports with this implementation. |
private JFreeChart |
meterChart()
Prepare a "Meter" style chart |
private JFreeChart |
pieChart()
|
private JFreeChart |
pieChart3D()
|
void |
saveChart(java.lang.String fileName, java.lang.String fileType, int width, int height)
Produce the chart and save it as an image in the specified file. |
void |
setChartType(int newChartType)
Specify the type of chart to be produced. |
void |
setData(ChartData theData)
Pass the data from which the chart is produced. |
void |
setOption(java.lang.String optionName, java.lang.Object option)
Set a specific chart-type-specific or implementation-specific option. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
chartType
private int chartType
-
chartData
private ChartData chartData
-
options
private java.util.Map options
-
log
private Logger log
-
JfreeChartChartFactory
public JfreeChartChartFactory()
getSupportedChartTypes
public java.util.Set getSupportedChartTypes()
- Description copied from interface:
ChartFactory
-
Return a Set of integers, one for each of the support chart types for this implementation
-
- Specified by:
getSupportedChartTypes in interface ChartFactory
-
- Returns:
- Set of supported chart types
getSupportedFileTypes
public java.util.Set getSupportedFileTypes()
- Description copied from interface:
ChartFactory
-
Return a set of strings, where each string represents the file-type extension of a type of file supported by this implementation. A supported file-type must be specified when calling "saveChart"
-
- Specified by:
getSupportedFileTypes in interface ChartFactory
-
- Returns:
setChartType
public void setChartType(int newChartType)
throws ChartException
- Description copied from interface:
ChartFactory
-
Specify the type of chart to be produced. An implementation can throw an exception if an unsupported type is requested.
-
- Specified by:
setChartType in interface ChartFactory
-
- Parameters:
newChartType -
- Throws:
ChartException
getOptionAsString
private java.lang.String getOptionAsString(java.lang.String optionName,
java.lang.String defaultValue)
-
-
getOptionAsDouble
private java.lang.Double getOptionAsDouble(java.lang.String optionName,
java.lang.Double defaultValue)
-
-
getOptionAsBoolean
private boolean getOptionAsBoolean(java.lang.String optionName,
boolean defaultValue)
-
-
getSupportedOptions
public java.util.Set getSupportedOptions()
- Description copied from interface:
ChartFactory
-
Once the chart type is set, getSupportedOptions can be called to determine what options (if any) this type of chart supports with this implementation. setOption can then be called to specify the option values before saveChart is called. This method should be called after setChartType is called, as different types of charts support different options.
-
- Specified by:
getSupportedOptions in interface ChartFactory
-
- Returns:
- A Set of strings, where each string is the name of an option recognized by this implementation and this type of chart.
setOption
public void setOption(java.lang.String optionName,
java.lang.Object option)
throws ChartException
- Description copied from interface:
ChartFactory
-
Set a specific chart-type-specific or implementation-specific option. An implementation should *not* throw an exception if an unsupported option is requested, the option should just be ignored.
-
- Specified by:
setOption in interface ChartFactory
-
- Parameters:
optionName -
option -
- Throws:
ChartException
setData
public void setData(ChartData theData)
throws ChartException
- Description copied from interface:
ChartFactory
-
Pass the data from which the chart is produced. Must be called before "saveChart" is called.
-
- Specified by:
setData in interface ChartFactory
-
- Parameters:
theData - A ChartData object containing the chart data to be plotted.
- Throws:
ChartException
pieChart
private JFreeChart pieChart()
throws ChartException
-
-
- Throws:
ChartException
pieChart3D
private JFreeChart pieChart3D()
throws ChartException
-
-
- Throws:
ChartException
areaChart
private JFreeChart areaChart()
throws ChartException
-
-
- Throws:
ChartException
getMaxPoints
private int getMaxPoints()
-
-
barChart
private JFreeChart barChart()
throws ChartException
-
-
- Throws:
ChartException
saveChart
public void saveChart(java.lang.String fileName,
java.lang.String fileType,
int width,
int height)
throws ChartException
- Description copied from interface:
ChartFactory
-
Produce the chart and save it as an image in the specified file.
-
- Specified by:
saveChart in interface ChartFactory
-
- Parameters:
fileName - Name of the file in which to save the chart
fileType - Valid file type (supported by this implementation)
width - Width of the image in pixels
height - Height of the image in pixels
- Throws:
ChartException
enableLogging
public void enableLogging(Logger newLog)
- Description copied from interface:
LogEnabled
-
Provide component with a logger.
-
- Specified by:
enableLogging in interface LogEnabled
-
- Parameters:
newLog - the logger. Must not be null.
getChart
public byte[] getChart(java.lang.String fileType,
int width,
int height)
throws ChartException
-
- Specified by:
getChart in interface ChartFactory
-
- Throws:
ChartException
getChartEncoded
public java.lang.String getChartEncoded(java.lang.String fileType,
int width,
int height)
throws ChartException
-
Return the chart as an encoded string
-
- Specified by:
getChartEncoded in interface ChartFactory
-
- Parameters:
fileType -
width -
height -
- Returns:
- Throws:
ChartException
meterChart
private JFreeChart meterChart()
-
Prepare a "Meter" style chart
-
-
- Returns:
compassChart
private JFreeChart compassChart()
-
-
Please see keelframework.org for information about new Keel releases.