Class ChartBuilder

java.lang.Object
com.jfcbuilder.builders.ChartBuilder

public class ChartBuilder extends Object
The top-level builder for creating JFreeChart instances using configured parameters.
  • Method Details

    • get

      public static ChartBuilder get()
      Factory method for obtaining new instances of this class.
      Returns:
      New instance of this class
    • title

      public ChartBuilder title(String 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

      public ChartBuilder indexRange(int startIndex, int endIndex) throws IllegalArgumentException
      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 range
      endIndex - 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

      public ChartBuilder timeData(long[] 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 (see indexRange(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

      public ChartBuilder dateFormat(DateFormat format)
      Overrides the time axis tick label format.
      Parameters:
      format - The DateFormat to use. null is accepted to use the default format.
      Returns:
      Same instance of this builder for chaining method calls
    • verticalTickLabels

      public ChartBuilder verticalTickLabels(boolean useVertical)
      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
    • sharedAxisColor

      public ChartBuilder sharedAxisColor(Paint color)
      Sets the shared axis color to use when building the chart.
      Parameters:
      color - The color to set
      Returns:
      Reference to this builder instance for method chaining
    • sharedAxisFontColor

      public ChartBuilder sharedAxisFontColor(Paint color)
      Sets the shared axis font color to use when building the chart.
      Parameters:
      color - The color to set
      Returns:
      Reference to this builder instance for method chaining
    • showTimeGaps

      public ChartBuilder showTimeGaps(boolean 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

      public ChartBuilder xyPlot(IXYTimeSeriesPlotBuilder<?> builder)
      Registers an IXYTimeSeriesPlotBuilder whose build() method will be called to generate its plot when this chart builder's build() 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