The PitchforkAnnotationCreationModifier
The PitchforkAnnotationCreationModifier is a chart modifier that allows for interactive creation of PitchforkAnnotation instances using a 3-tap workflow.
Overview
When this modifier is enabled, users can place the 3 required points (Handle, High, Low) by tapping on the chart.
- Each tap confirms the position of the next point.
- A "rubber-band" dashed line provides a preview of the next segment between the last confirmed point and the current touch position.
- Once the third point is placed, the annotation is finalized, and the modifier automatically resets to create the next one.
Properties
The following properties can be used to configure the PitchforkAnnotationCreationModifier:
| Property | Description |
|---|---|
| xAxisId | Sets the ID of the X-Axis that the created annotations should be measured against. |
| yAxisId | Sets the ID of the Y-Axis that the created annotations should be measured against. |
| rubberBandStroke | Sets the pen style for the preview line shown during creation. |
Event Listeners
You can receive a notification when an annotation is fully created by setting an OnAnnotationCreatedListener:
- setAnnotationCreationListener(OnAnnotationCreatedListener listener): Passes the newly created annotation instance to the listener.
Using PitchforkAnnotationCreationModifier
The following code demonstrates how to add and configure a PitchforkAnnotationCreationModifier:
// Create a PitchforkAnnotationCreationModifier
final PitchforkAnnotationCreationModifier pitchforkCreationModifier = new PitchforkAnnotationCreationModifier();
// Optional: Set a listener to be notified when an annotation is created
pitchforkCreationModifier.setAnnotationCreationListener(newAnnotation -> {
// Configure the newly created annotation if needed
newAnnotation.setIsEditable(true);
});
// Add the modifier to the surface
surface.getChartModifiers().add(pitchforkCreationModifier);
Customizing the Modifier
The PitchforkAnnotationCreationModifier is designed for extensibility. You can customize its behavior by extending it and overriding its protected methods.
// Define a custom PitchforkAnnotationCreationModifier
private static class CustomPitchforkAnnotationCreationModifier extends PitchforkAnnotationCreationModifier {
@Override
protected void configureRubberBandAnnotation(IAnnotation annotation) {
super.configureRubberBandAnnotation(annotation);
// Customize the rubber-band styling
if (annotation instanceof LineAnnotation) {
((LineAnnotation) annotation).setStroke(new SolidPenStyle(Color.YELLOW, true, 2f, new float[]{10, 5}));
}
}
@Override
protected void onAnnotationCreated(IAnnotation newAnnotation) {
super.onAnnotationCreated(newAnnotation);
// Custom logic after annotation is fully created
newAnnotation.setIsEditable(true);
}
}
void useCustomPitchforkAnnotationCreationModifier(@NonNull SciChartSurface surface) {
// Use the custom modifier
final CustomPitchforkAnnotationCreationModifier customModifier = new CustomPitchforkAnnotationCreationModifier();
surface.getChartModifiers().add(customModifier);
}
Note
To learn more about other Annotation Types, available out of the box in SciChart, please find the comprehensive list in the Annotation APIs article.