Class XYTitleBuilder

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

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

    Fields
    Modifier and Type
    Field
    Description
    static final org.jfree.chart.ui.RectangleAnchor
    The default text anchor position to use if none is specified.
    static final double
    The default maximum height to use if none is specified.
    static final double
    The default maximum width to use if none is specified.
    static final double
    The default x-axis data coordinate to use if none is specified.
    static final double
    The default y-axis data coordinate to use if none is specified.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.jfree.chart.ui.RectangleAnchor
    Gets the title's position anchor
    anchor(org.jfree.chart.ui.RectangleAnchor a)
    Sets the title'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.
    void
    mapXToTimeIndex(long[] timeData, int indexRangeStartIndex, int indexRangeEndIndex)
    Helper mutation method for replacing the configured x-axis date values with corresponding source array element index value.
    double
    Gets the maximum height of the annotation.
    maxHeight(double h)
    Sets the maximum height of the annotation.
    double
    Gets the maximum width of the annotation.
    maxWidth(double w)
    Sets the maximum width of the annotation.
    org.jfree.chart.title.Title
    Gets the Title to be annotated.
    title(org.jfree.chart.title.Title t)
    Sets the Title to be annotated.
    double
    x()
    Gets the x-coordinate of the annotation.
    x(double x)
    Sets the x-coordinate of the annotation.
    double
    y()
    Gets the y-coordinate of the annotation.
    y(double y)
    Sets the y-coordinate of the annotation.

    Methods inherited from class java.lang.Object

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

    • DEFAULT_X_COORD

      public static final double DEFAULT_X_COORD
      The default x-axis data coordinate to use if none is specified.
      See Also:
    • DEFAULT_Y_COORD

      public static final double DEFAULT_Y_COORD
      The default y-axis data coordinate to use if none is specified.
      See Also:
    • DEFAULT_MAX_WIDTH

      public static final double DEFAULT_MAX_WIDTH
      The default maximum width to use if none is specified.
      See Also:
    • DEFAULT_MAX_HEIGHT

      public static final double DEFAULT_MAX_HEIGHT
      The default maximum height to use if none is specified.
      See Also:
    • DEFAULT_ANCHOR

      public static final org.jfree.chart.ui.RectangleAnchor DEFAULT_ANCHOR
      The default text anchor position to use if none is specified.
  • Method Details

    • get

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

      public XYTitleBuilder x(double x)
      Sets the x-coordinate of the annotation.

      JFreeChart XYTitleAnnotation hard-codes the coordinate type to XYCoordinateType.RELATIVE therefore the X value being set must be in range (0.0, 1.0).

      Parameters:
      x - The coordinate value to be set. Should be in range (0.0, 1.0)
      Returns:
      Reference to this builder instance for method chaining
    • x

      public double x()
      Gets the x-coordinate of the annotation.
      Returns:
      The x-coordinate
    • y

      public XYTitleBuilder y(double y)
      Sets the y-coordinate of the annotation.

      JFreeChart XYTitleAnnotation hard-codes the coordinate type to XYCoordinateType.RELATIVE therefore the Y value being set must be in range (0.0, 1.0).

      Parameters:
      y - The coordinate value to be set. Should be in range (0.0, 1.0)
      Returns:
      Reference to this builder instance for method chaining
    • y

      public double y()
      Gets the y-coordinate of the annotation.
      Returns:
      The y-coordinate
    • maxWidth

      public XYTitleBuilder maxWidth(double w)
      Sets the maximum width of the annotation.
      Parameters:
      w - The width to set
      Returns:
      Reference to this builder instance for method chaining
    • maxWidth

      public double maxWidth()
      Gets the maximum width of the annotation.
      Returns:
      The max width
    • maxHeight

      public XYTitleBuilder maxHeight(double h)
      Sets the maximum height of the annotation.
      Parameters:
      h - The height to set
      Returns:
      Reference to this builder instance for method chaining
    • maxHeight

      public double maxHeight()
      Gets the maximum height of the annotation.
      Returns:
      The max height
    • title

      public XYTitleBuilder title(org.jfree.chart.title.Title t)
      Sets the Title to be annotated.
      Parameters:
      t - The title to be set.
      Returns:
      Reference to this builder instance for method chaining
    • title

      public org.jfree.chart.title.Title title()
      Gets the Title to be annotated.
      Returns:
      The title
    • anchor

      public XYTitleBuilder anchor(org.jfree.chart.ui.RectangleAnchor a)
      Sets the title's position anchor
      Parameters:
      a - The anchor to be set
      Returns:
      Reference to this builder instance for method chaining
      See Also:
      • XYTitleAnnotation.getTitleAnchor()
    • anchor

      public org.jfree.chart.ui.RectangleAnchor anchor()
      Gets the title's position anchor
      Returns:
      The anchor
      See Also:
      • XYTitleAnnotation.getTitleAnchor()
    • 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<XYTitleBuilder>
      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)
      Description copied from interface: IXYAnnotationBuilder
      Helper mutation method for replacing the configured x-axis date values with corresponding source array element index value.

      Meant to be called internally by the framework itself, not by framework clients.

      For facilitating the removal of visible time gaps on charts.

      Different implementations may use different methods to map configured x value(s) to numeric indices, including search algorithms that may have higher order Big-O complexity.

      Specified by:
      mapXToTimeIndex in interface IXYAnnotationBuilder<XYTitleBuilder>
      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