Class XYTextBuilder

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

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

    Modifier and Type
    Method
    Description
    angle(double degrees)
    Sets the text's orientation angle in degrees.
    org.jfree.chart.annotations.XYAnnotation
    Builds the XYAnnotation from all configured data and properties.
    color(Color color)
    Sets the text color.
    get()
    Factory method for obtaining new instances of this class.
    void
    mapXToTimeIndex(long[] timeData, int indexRangeStartIndex, int indexRangeEndIndex)
    Uses Arrays.binarySearch() to search the source array for the date value.
    text(String text)
    Sets the text
    textAlign(org.jfree.chart.ui.TextAnchor alignment)
    Sets the anchor alignment method of the text.
    Sets a number of padding space characters to insert to the left of the configured text.
    Sets a number of padding space characters to insert to the right of the configured text.
    double
    x()
    Gets the x-axis data coordinate that is set.
    x(double x)
    Sets the text's x-axis data coordinate.
    double
    y()
    Gets the y-axis data coordinate that is set.
    y(double y)
    Sets the text's y-axis data coordinate.

    Methods inherited from class java.lang.Object

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

    • get

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

      public XYTextBuilder x(double x)
      Sets the text's x-axis data coordinate.
      Parameters:
      x - The data coordinate to set
      Returns:
      Reference to this builder instance for method chaining
    • x

      public double x()
      Gets the x-axis data coordinate that is set.
      Returns:
      The data coordinate value
    • y

      public XYTextBuilder y(double y)
      Sets the text's y-axis data coordinate.
      Parameters:
      y - The data coordinate to set
      Returns:
      Reference to this builder instance for method chaining
    • y

      public double y()
      Gets the y-axis data coordinate that is set.
      Returns:
      The data coordinate value
    • angle

      public XYTextBuilder angle(double degrees)
      Sets the text's orientation angle in degrees.
      Parameters:
      degrees - The angle to be set
      Returns:
      Reference to this builder instance for method chaining
    • text

      public XYTextBuilder text(String text)
      Sets the text
      Parameters:
      text - The text to be set
      Returns:
      Reference to this builder instance for method chaining
    • textAlign

      public XYTextBuilder textAlign(org.jfree.chart.ui.TextAnchor alignment)
      Sets the anchor alignment method of the text.
      Parameters:
      alignment - The alignment anchor to use for the text
      Returns:
      Reference to this builder instance for method chaining
      See Also:
      • XYTextAnnotation.setTextAnchor(TextAnchor)
    • color

      public XYTextBuilder color(Color color)
      Sets the text color.
      Parameters:
      color - The color to set
      Returns:
      Reference to this builder instance for method chaining
    • textPaddingLeft

      public XYTextBuilder textPaddingLeft(int n)
      Sets a number of padding space characters to insert to the left of the configured text.
      Parameters:
      n - The number of padding characters
      Returns:
      Reference to this builder instance for method chaining
    • textPaddingRight

      public XYTextBuilder textPaddingRight(int n)
      Sets a number of padding space characters to insert to the right of the configured text.
      Parameters:
      n - The number of padding characters
      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<XYTextBuilder>
      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() to search the source array for the date value. If found, replaces that value 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<XYTextBuilder>
      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