Class XYArrowBuilder

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

public class XYArrowBuilder extends Object implements IXYAnnotationBuilder<XYArrowBuilder>
Builder for producing XYPointerAnnotation (arrow) objects.
  • Method Details

    • get

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

      public XYArrowBuilder x(double x)
      Sets the arrow'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 XYArrowBuilder y(double y)
      Sets the arrow'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 XYArrowBuilder angle(double degrees)
      Sets the arrow's orientation angle in degrees.
      Parameters:
      degrees - The angle to be set
      Returns:
      Reference to this builder instance for method chaining
    • text

      public XYArrowBuilder text(String text)
      Sets the arrow's text
      Parameters:
      text - The text to be set
      Returns:
      Reference to this builder instance for method chaining
    • textPaddingLeft

      public XYArrowBuilder 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 XYArrowBuilder 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
    • textAlign

      public XYArrowBuilder 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 XYArrowBuilder color(Color color)
      Sets the arrow color.
      Parameters:
      color - The color to be set
      Returns:
      Reference to this builder instance for method chaining
    • arrowLength

      public XYArrowBuilder arrowLength(double length)
      Sets the arrow length.
      Parameters:
      length - The length to be set in Java2D units
      Returns:
      Reference to this builder instance for method chaining
      See Also:
      • XYPointerAnnotation.setBaseRadius(double)
    • tipRadius

      public XYArrowBuilder tipRadius(double radius)
      Sets the arrow tip's radius in Java2D units (effectively the tip size)
      Parameters:
      radius - The radius to be set in Java2D units
      Returns:
      Reference to this builder instance for method chaining
      See Also:
      • XYPointerAnnotation.setTipRadius(double)
    • 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<XYArrowBuilder>
      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<XYArrowBuilder>
      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