Class XYPolygonBuilder

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

public class XYPolygonBuilder extends Object implements IXYAnnotationBuilder<XYPolygonBuilder>
Builder for producing XYPolygonAnnotation objects.
  • Field Details

    • DEFAULT_OUTLINE_COLOR

      public static final Color DEFAULT_OUTLINE_COLOR
      The default outline color to use if none is specified.
    • DEFAULT_OUTLINE_STYLE

      public static final Stroke DEFAULT_OUTLINE_STYLE
      The default outline style to use if none is specified.
  • Method Details

    • get

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

      public double[] polygon()
      Gets the copy of the polygon array, which was possibly mutated by mapXToTimeIndex().
      Returns:
      The serialized polygon (x,y) pairs.
    • polygon

      public XYPolygonBuilder polygon(double[] polygon)
      Sets the polygon array by storying a copy of the supplied array.

      The copy is because mapXToTimeIndex() will mutate the array.

      Parameters:
      polygon - The serialized polygon (x,y) pairs to be copied.
      Returns:
      Reference to this builder instance for method chaining
    • outlineStyle

      public Stroke outlineStyle()
      Gets the polygon outline style.
      Returns:
      The outline style
    • outlineStyle

      public XYPolygonBuilder outlineStyle(Stroke outlineStyle)
      Sets the polygon outline style.
      Parameters:
      outlineStyle - The style to set
      Returns:
      Reference to this builder instance for method chaining
    • outlineColor

      public Paint outlineColor()
      Gets the color of the polygon outline.
      Returns:
      The color
    • outlineColor

      public XYPolygonBuilder outlineColor(Paint outlineColor)
      Sets the color of the polygon outline.
      Parameters:
      outlineColor - The color to set
      Returns:
      Reference to this builder instance for method chaining
    • fillColor

      public Paint fillColor()
      Gets the polygon fill color.
      Returns:
      The fill color
    • fillColor

      public XYPolygonBuilder fillColor(Paint fillColor)
      Sets the polygon fill color.
      Parameters:
      fillColor - The color to set
      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<XYPolygonBuilder>
      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() for each polygon vertex to search the source array for the X date values. If found, replaces the values 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<XYPolygonBuilder>
      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