Class XYLineBuilder

java.lang.Object
com.jfcbuilder.builders.XYLineBuilder
All Implemented Interfaces:
IXYAnnotationBuilder<XYLineBuilder>

public class XYLineBuilder extends Object implements IXYAnnotationBuilder<XYLineBuilder>
Builder for producing XYLineAnnotation objects.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.jfree.chart.annotations.XYAnnotation
    Builds the XYAnnotation from all configured data and properties.
    Gets the line's color.
    color(Paint color)
    Sets the line's color.
    get()
    Factory method for obtaining new instances of this class.
    void
    mapXToTimeIndex(long[] timeData, int indexRangeStartIndex, int indexRangeEndIndex)
    Uses Arrays.binarySearch() two times to search the source array for the x1 and x2 date value.
    Gets the line's style.
    style(Stroke style)
    Sets the line's style.
    double
    x1()
    Gets the x-axis data coordinate of the line's first point.
    x1(double x1)
    Sets the x-axis data coordinate of the line's first point.
    double
    x2()
    Gets the x-axis data coordinate of the line's second point.
    x2(double x2)
    Sets the x-axis data coordinate of the line's second point.
    double
    y1()
    Gets the y-axis data coordinate of the line's first point.
    y1(double y1)
    Sets the y-axis data coordinate of the line's first point.
    double
    y2()
    Gets the y-axis data coordinate of the line's second point.
    y2(double y2)
    Sets the y-axis data coordinate of the line's second point.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • get

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

      public double x1()
      Gets the x-axis data coordinate of the line's first point.
      Returns:
      The data coordinate value
    • x1

      public XYLineBuilder x1(double x1)
      Sets the x-axis data coordinate of the line's first point.
      Parameters:
      x1 - The data coordinate to set
      Returns:
      Reference to this builder instance for method chaining
    • y1

      public double y1()
      Gets the y-axis data coordinate of the line's first point.
      Returns:
      The data coordinate value
    • y1

      public XYLineBuilder y1(double y1)
      Sets the y-axis data coordinate of the line's first point.
      Parameters:
      y1 - The data coordinate to set
      Returns:
      Reference to this builder instance for method chaining
    • x2

      public double x2()
      Gets the x-axis data coordinate of the line's second point.
      Returns:
      The data coordinate value
    • x2

      public XYLineBuilder x2(double x2)
      Sets the x-axis data coordinate of the line's second point.
      Parameters:
      x2 - The data coordinate to set
      Returns:
      Reference to this builder instance for method chaining
    • y2

      public double y2()
      Gets the y-axis data coordinate of the line's second point.
      Returns:
      The data coordinate value
    • y2

      public XYLineBuilder y2(double y2)
      Sets the y-axis data coordinate of the line's second point.
      Parameters:
      y2 - The data coordinate to set
      Returns:
      Reference to this builder instance for method chaining
    • style

      public Stroke style()
      Gets the line's style.
      Returns:
      The style
    • style

      public XYLineBuilder style(Stroke style)
      Sets the line's style.
      Parameters:
      style - The style to set
      Returns:
      Reference to this builder instance for method chaining
    • color

      public Paint color()
      Gets the line's color.
      Returns:
      The color
    • color

      public XYLineBuilder color(Paint color)
      Sets the line's color.
      Parameters:
      color - The color to set
      Returns:
      Reference to this builder instance for method chaining
    • build

      public org.jfree.chart.annotations.XYAnnotation build() throws IllegalStateException
      Description copied from interface: IXYAnnotationBuilder
      Builds the XYAnnotation from all configured data and properties.
      Specified by:
      build in interface IXYAnnotationBuilder<XYLineBuilder>
      Returns:
      New instance of an XYAnnotation corresponding to all configured data and properties
      Throws:
      IllegalStateException - If the builder is missing properties when build() is called
    • mapXToTimeIndex

      public void mapXToTimeIndex(long[] timeData, int indexRangeStartIndex, int indexRangeEndIndex)
      Uses Arrays.binarySearch() two times to search the source array for the x1 and x2 date value. If found, replaces the values in the builder with the found array index relative to the configured index range. The source time values are assumed to be timestamps in milliseconds since the epoch start. It's also assumed these are in ascending chronologic order. Failure to provide them in sorted order will result in undefined behavior as per Arrays.binarySearch().
      Specified by:
      mapXToTimeIndex in interface IXYAnnotationBuilder<XYLineBuilder>
      Parameters:
      timeData - The array of source time values
      indexRangeStartIndex - The start index of the series index range
      indexRangeEndIndex - The end index of the series index range