Package com.jfcbuilder.builders
Class XYDrawableBuilder
java.lang.Object
com.jfcbuilder.builders.XYDrawableBuilder
- All Implemented Interfaces:
IXYAnnotationBuilder<XYDrawableBuilder>
Builder for producing
XYDrawableAnnotation objects.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe drawing scale factor to use if none is specified. -
Method Summary
Modifier and TypeMethodDescriptionorg.jfree.chart.annotations.XYAnnotationbuild()Builds the XYAnnotation from all configured data and properties.doubleGets the height of the area into which to draw theDrawable.displayHeight(double h) Sets the height of the area into which to draw theDrawable.doubleGets the width of the area into which to draw theDrawable.displayWidth(double w) Sets the width of the area into which to draw theDrawable.org.jfree.chart.ui.Drawabledrawable()Gets theDrawableobject to be annotated.drawable(org.jfree.chart.ui.Drawable d) Sets theDrawableobject to be annotated.doubleGets the draw scale factor to be useddrawScaleFactor(double f) Sets the draw scale factor to use.static XYDrawableBuilderget()Factory method for obtaining new instances of this class.voidmapXToTimeIndex(long[] timeData, int indexRangeStartIndex, int indexRangeEndIndex) UsesArrays.binarySearch()to search the source array for the date value.doublex()Gets the x-coordinate that is set.x(double x) Sets the drawable's x-coordinate.doubley()Gets the y-coordinate that is set.y(double y) Sets the drawable's y-coordinate.
-
Field Details
-
DEFAULT_DRAW_SCALE_FACTOR
public static final double DEFAULT_DRAW_SCALE_FACTORThe drawing scale factor to use if none is specified.- See Also:
-
-
Method Details
-
get
Factory method for obtaining new instances of this class.- Returns:
- New instance of this class
-
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
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
Sets the width of the area into which to draw theDrawable.- 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 theDrawable.- Returns:
- The width (Java2D units)
-
displayHeight
Sets the height of the area into which to draw theDrawable.- 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 theDrawable.- Returns:
- The height (Java2D units)
-
drawable
Sets theDrawableobject to be annotated.- Parameters:
d- TheDrawable- Returns:
- Reference to this builder instance for method chaining
-
drawable
public org.jfree.chart.ui.Drawable drawable()Gets theDrawableobject to be annotated.- Returns:
- The
Drawable
-
drawScaleFactor
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
Description copied from interface:IXYAnnotationBuilderBuilds the XYAnnotation from all configured data and properties.- Specified by:
buildin interfaceIXYAnnotationBuilder<XYDrawableBuilder>- 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()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 perArrays.binarySearch().- Specified by:
mapXToTimeIndexin interfaceIXYAnnotationBuilder<XYDrawableBuilder>- Parameters:
timeData- The array of source time valuesindexRangeStartIndex- The start index of the series index rangeindexRangeEndIndex- The end index of the series index range
-