Class XYImageBuilder

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

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

    Modifier and Type
    Method
    Description
    org.jfree.chart.ui.RectangleAnchor
    Gets the image rectangle's position anchor
    anchor(org.jfree.chart.ui.RectangleAnchor anchor)
    Sets the image rectangle's position anchor
    org.jfree.chart.annotations.XYAnnotation
    Builds the XYAnnotation from all configured data and properties.
    get()
    Factory method for obtaining new instances of this class.
    Gets the Image to be annotated.
    image(Image image)
    Sets the Image to be annotated.
    void
    mapXToTimeIndex(long[] timeData, int indexRangeStartIndex, int indexRangeEndIndex)
    Uses Arrays.binarySearch() to search the source array for the date value.
    double
    x()
    Gets the x-axis data coordinate that is set.
    x(double x)
    Sets the image's x-axis data coordinate.
    double
    y()
    Gets the y-axis data coordinate that is set.
    y(double y)
    Sets the image'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 XYImageBuilder get()
      Factory method for obtaining new instances of this class.
      Returns:
      New instance of this class
    • x

      public XYImageBuilder x(double x)
      Sets the image'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 XYImageBuilder y(double y)
      Sets the image'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
    • image

      public XYImageBuilder image(Image image)
      Sets the Image to be annotated.
      Parameters:
      image - The image object to annotate
      Returns:
      Reference to this builder instance for method chaining
    • image

      public Image image()
      Gets the Image to be annotated.
      Returns:
      The image object to annotate
    • anchor

      public XYImageBuilder anchor(org.jfree.chart.ui.RectangleAnchor anchor)
      Sets the image rectangle's position anchor
      Parameters:
      anchor - The anchor to be set
      Returns:
      Reference to this builder instance for method chaining
      See Also:
      • XYImageAnnotation.getImageAnchor()
    • anchor

      public org.jfree.chart.ui.RectangleAnchor anchor()
      Gets the image rectangle's position anchor
      Returns:
      The anchor
      See Also:
      • XYImageAnnotation.getImageAnchor()
    • 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<XYImageBuilder>
      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<XYImageBuilder>
      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