Package com.jfcbuilder.builders
Class ChartBuilder
java.lang.Object
com.jfcbuilder.builders.ChartBuilder
The top-level builder for creating JFreeChart instances using configured parameters.
-
Method Summary
Modifier and TypeMethodDescriptionorg.jfree.chart.JFreeChart
build()
Builds the JFreeChart using all configured settings.dateFormat
(DateFormat format) Overrides the time axis tick label format.static ChartBuilder
get()
Factory method for obtaining new instances of this class.indexRange
(int startIndex, int endIndex) Sets the zero-based indexes defining what elements to actually use in all the configured data sets.sharedAxisColor
(Paint color) Sets the shared axis color to use when building the chart.sharedAxisFontColor
(Paint color) Sets the shared axis font color to use when building the chart.boolean
Gets whether to render time gaps.showTimeGaps
(boolean showTimeGaps) Sets whether or not time gaps should be rendered.timeData
(long[] timeData) Sets the epoch milliseconds date-time data common to all plots.Sets the main title of the chart.verticalTickLabels
(boolean useVertical) Override the time axis flag specifying if tick labels should be drawn vertical or horizontal.xyPlot
(IXYTimeSeriesPlotBuilder<?> builder) Registers an IXYTimeSeriesPlotBuilder whosebuild()
method will be called to generate its plot when this chart builder'sbuild()
method is called.
-
Method Details
-
get
Factory method for obtaining new instances of this class.- Returns:
- New instance of this class
-
title
Sets the main title of the chart.- Parameters:
title
- The title to be set- Returns:
- Same instance of this builder for chaining calls
-
indexRange
Sets the zero-based indexes defining what elements to actually use in all the configured data sets. If you don't call this method the full range of elements in the timeData array will be used.- Parameters:
startIndex
- Zero based index of the start of the rangeendIndex
- Zero based index of the end of the range- Returns:
- Same instance of this builder for chaining method calls
- Throws:
IllegalArgumentException
- If startIndex or endIndex are negative, or if startIndex is greater than endIndex
-
timeData
Sets the epoch milliseconds date-time data common to all plots. You can also specify a start and end index defining what parts of this data to use (seeindexRange(int, int)
method). This is to allow use of an existing data set without having to create a truncated copy of it just to be able to use the builder. The result is less computational and memory usage. This class will not modify the date-time data passed to it but be warned it will access it without any thread-safe protections. If you require thread-safety your code should not further modify the data passed-in here, or you should supply a copy of your data.- Parameters:
timeData
- Array of date-time instances represented at milliseconds since the epoch- Returns:
- Same instance of this builder for chaining method calls
- Throws:
NullPointerException
- If timeData is null
-
dateFormat
Overrides the time axis tick label format.- Parameters:
format
- TheDateFormat
to use.null
is accepted to use the default format.- Returns:
- Same instance of this builder for chaining method calls
-
verticalTickLabels
Override the time axis flag specifying if tick labels should be drawn vertical or horizontal.- Parameters:
useVertical
- True to draw vertical labels, false for horizontal- Returns:
- Same instance of this builder for chaining method calls
-
showTimeGaps
Sets whether or not time gaps should be rendered.- Parameters:
showTimeGaps
- True to render time gaps, false otherwise- Returns:
- Same instance of this builder for chaining method calls
-
showTimeGaps
public boolean showTimeGaps()Gets whether to render time gaps.- Returns:
- True if time gaps should be rendered, false otherwise
-
xyPlot
Registers an IXYTimeSeriesPlotBuilder whosebuild()
method will be called to generate its plot when this chart builder'sbuild()
method is called.- Parameters:
builder
- The series builder representing the series that it will build- Returns:
- Same instance of this builder for chaining method calls
-
build
public org.jfree.chart.JFreeChart build()Builds the JFreeChart using all configured settings.- Returns:
- New instance of a JFreeChart corresponding to all configured data sets and settings
- Throws:
IllegalStateException
- If time data to be shared by all plots was not set
-