Class XYDrawableBuilder

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

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

    Fields
    Modifier and Type
    Field
    Description
    static final double
    The drawing scale factor 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.
    double
    Gets the height of the area into which to draw the Drawable.
    displayHeight(double h)
    Sets the height of the area into which to draw the Drawable.
    double
    Gets the width of the area into which to draw the Drawable.
    displayWidth(double w)
    Sets the width of the area into which to draw the Drawable.
    org.jfree.chart.ui.Drawable
    Gets the Drawable object to be annotated.
    drawable(org.jfree.chart.ui.Drawable d)
    Sets the Drawable object to be annotated.
    double
    Gets the draw scale factor to be used
    drawScaleFactor(double f)
    Sets the draw scale factor to use.
    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.
    double
    x()
    Gets the x-coordinate that is set.
    x(double x)
    Sets the drawable's x-coordinate.
    double
    y()
    Gets the y-coordinate that is set.
    y(double y)
    Sets the drawable's y-coordinate.

    Methods inherited from class java.lang.Object

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

    • DEFAULT_DRAW_SCALE_FACTOR

      public static final double DEFAULT_DRAW_SCALE_FACTOR
      The drawing scale factor to use if none is specified.
      See Also:
  • Method Details

    • get

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

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

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

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

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

      public XYDrawableBuilder displayWidth(double w)
      Sets the width of the area into which to draw the Drawable.
      Parameters:
      w - The width to be set (Java2D units)
      Returns:
      Reference to this builder instance for method chaining
    • displayWidth

      public double displayWidth()
      Gets the width of the area into which to draw the Drawable.
      Returns:
      The width (Java2D units)
    • displayHeight

      public XYDrawableBuilder displayHeight(double h)
      Sets the height of the area into which to draw the Drawable.
      Parameters:
      h - The height to be set (Java2D units)
      Returns:
      Reference to this builder instance for method chaining
    • displayHeight

      public double displayHeight()
      Gets the height of the area into which to draw the Drawable.
      Returns:
      The height (Java2D units)
    • drawable

      public XYDrawableBuilder drawable(org.jfree.chart.ui.Drawable d)
      Sets the Drawable object to be annotated.
      Parameters:
      d - The Drawable
      Returns:
      Reference to this builder instance for method chaining
    • drawable

      public org.jfree.chart.ui.Drawable drawable()
      Gets the Drawable object to be annotated.
      Returns:
      The Drawable
    • drawScaleFactor

      public XYDrawableBuilder drawScaleFactor(double f)
      Sets the draw scale factor to use.
      Parameters:
      f - The scale factor
      Returns:
      Reference to this builder instance for method chaining
    • drawScaleFactor

      public double drawScaleFactor()
      Gets the draw scale factor to be used
      Returns:
      The scale factor
    • 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<XYDrawableBuilder>
      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<XYDrawableBuilder>
      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