Package com.jfcbuilder.builders
Class XYPolygonBuilder
java.lang.Object
com.jfcbuilder.builders.XYPolygonBuilder
- All Implemented Interfaces:
IXYAnnotationBuilder<XYPolygonBuilder>
Builder for producing
XYPolygonAnnotation
objects.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionorg.jfree.chart.annotations.XYAnnotation
build()
Builds the XYAnnotation from all configured data and properties.Gets the polygon fill color.Sets the polygon fill color.static XYPolygonBuilder
get()
Factory method for obtaining new instances of this class.void
mapXToTimeIndex
(long[] timeData, int indexRangeStartIndex, int indexRangeEndIndex) UsesArrays.binarySearch()
for each polygon vertex to search the source array for the X date values.Gets the color of the polygon outline.outlineColor
(Paint outlineColor) Sets the color of the polygon outline.Gets the polygon outline style.outlineStyle
(Stroke outlineStyle) Sets the polygon outline style.double[]
polygon()
Gets the copy of the polygon array, which was possibly mutated bymapXToTimeIndex()
.polygon
(double[] polygon) Sets the polygon array by storying a copy of the supplied array.
-
Field Details
-
DEFAULT_OUTLINE_COLOR
The default outline color to use if none is specified. -
DEFAULT_OUTLINE_STYLE
The default outline style to use if none is specified.
-
-
Method Details
-
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 bymapXToTimeIndex()
.- Returns:
- The serialized polygon (x,y) pairs.
-
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
Gets the polygon outline style.- Returns:
- The outline style
-
outlineStyle
Sets the polygon outline style.- Parameters:
outlineStyle
- The style to set- Returns:
- Reference to this builder instance for method chaining
-
outlineColor
Gets the color of the polygon outline.- Returns:
- The color
-
outlineColor
Sets the color of the polygon outline.- Parameters:
outlineColor
- The color to set- Returns:
- Reference to this builder instance for method chaining
-
fillColor
Gets the polygon fill color.- Returns:
- The fill color
-
fillColor
Sets the polygon fill color.- Parameters:
fillColor
- The color to set- Returns:
- Reference to this builder instance for method chaining
-
build
Description copied from interface:IXYAnnotationBuilder
Builds the XYAnnotation from all configured data and properties.- Specified by:
build
in interfaceIXYAnnotationBuilder<XYPolygonBuilder>
- Returns:
- New instance of an XYAnnotation corresponding to all configured data and properties
- Throws:
IllegalStateException
- If the builder is missing properties whenbuild()
is called
-
mapXToTimeIndex
public void mapXToTimeIndex(long[] timeData, int indexRangeStartIndex, int indexRangeEndIndex) UsesArrays.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 perArrays.binarySearch()
.- Specified by:
mapXToTimeIndex
in interfaceIXYAnnotationBuilder<XYPolygonBuilder>
- Parameters:
timeData
- The array of source time valuesindexRangeStartIndex
- The start index of the series index rangeindexRangeEndIndex
- The end index of the series index range
-