Class XYBoxBuilder

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

public class XYBoxBuilder extends Object implements IXYAnnotationBuilder<XYBoxBuilder>
Builder for producing XYBoxAnnotation objects.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Color
    The outline color to use if none is specified.
    static final Stroke
    The outline style to use if none is specified.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.jfree.chart.annotations.XYAnnotation
    Builds the XYAnnotation from all configured data and properties.
    Gets the fill color of the box.
    fillColor(Paint fillColor)
    Sets the fill color of the box.
    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 outline color of the box.
    outlineColor(Paint outlineColor)
    Sets the outline color of the box.
    Gets the outline style of the box.
    outlineStyle(Stroke outlineStyle)
    Sets outline style of the box.
    double
    x1()
    Gets the x-axis data coordinate of the first corner of the box.
    x1(double x1)
    Sets the x-axis data coordinate of the first corner of the box.
    double
    x2()
    Gets the x-axis data coordinate of the second corner of the box.
    x2(double x2)
    Sets the x-axis data coordinate of the second corner of the box.
    double
    y1()
    Gets the y-axis data coordinate of the first corner of the box.
    y1(double y1)
    Sets the y-axis data coordinate of the first corner of the box.
    double
    y2()
    Gets the y-axis data coordinate of the second corner of the box.
    y2(double y2)
    Sets the y-axis data coordinate of the second corner of the box.

    Methods inherited from class java.lang.Object

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

    • DEFAULT_OUTLINE_COLOR

      public static final Color DEFAULT_OUTLINE_COLOR
      The outline color to use if none is specified.
    • DEFAULT_OUTLINE_STYLE

      public static final Stroke DEFAULT_OUTLINE_STYLE
      The outline style to use if none is specified.
  • Method Details

    • get

      public static XYBoxBuilder 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 first corner of the box.
      Returns:
      The data coordinate value
    • x1

      public XYBoxBuilder x1(double x1)
      Sets the x-axis data coordinate of the first corner of the box.
      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 first corner of the box.
      Returns:
      The data coordinate value
    • y1

      public XYBoxBuilder y1(double y1)
      Sets the y-axis data coordinate of the first corner of the box.
      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 second corner of the box.
      Returns:
      The data coordinate value
    • x2

      public XYBoxBuilder x2(double x2)
      Sets the x-axis data coordinate of the second corner of the box.
      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 second corner of the box.
      Returns:
      The data coordinate value
    • y2

      public XYBoxBuilder y2(double y2)
      Sets the y-axis data coordinate of the second corner of the box.
      Parameters:
      y2 - The data coordinate to set
      Returns:
      Reference to this builder instance for method chaining
    • outlineStyle

      public Stroke outlineStyle()
      Gets the outline style of the box.
      Returns:
      The outline's style
    • outlineStyle

      public XYBoxBuilder outlineStyle(Stroke outlineStyle)
      Sets outline style of the box.
      Parameters:
      outlineStyle - The style to set
      Returns:
      Reference to this builder instance for method chaining
    • outlineColor

      public Paint outlineColor()
      Gets the outline color of the box.
      Returns:
      The color
    • outlineColor

      public XYBoxBuilder outlineColor(Paint outlineColor)
      Sets the outline color of the box.
      Parameters:
      outlineColor - The color to set
      Returns:
      Reference to this builder instance for method chaining
    • fillColor

      public Paint fillColor()
      Gets the fill color of the box.
      Returns:
      The fill color
    • fillColor

      public XYBoxBuilder fillColor(Paint fillColor)
      Sets the fill color of the box.
      Parameters:
      fillColor - 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<XYBoxBuilder>
      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<XYBoxBuilder>
      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