Record Class ChartFocus
java.lang.Object
java.lang.Record
com.arbergashi.charts.api.ChartFocus
public record ChartFocus(Point pixel, double x, double y, int index, ChartModel model, Instant timestamp, Map<String,Object> values)
extends Record
Represents the current "focus" state of a chart interaction.
Focus is typically driven by the crosshair/mouse position and is used to power interactive legends, tooltips and synchronized multi-panel cursors.
This is intentionally a small immutable value object. Renderers may contribute additional
values (e.g., OHLC, volume, indicators) via values().
- Since:
- 2025-06-01
- Version:
- 1.0.0
- Author:
- Arber Gashi
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionChartFocus(Point pixel, double x, double y, int index, ChartModel model, Instant timestamp, Map<String, Object> values) Creates an instance of aChartFocusrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intindex()Returns the value of theindexrecord component.booleanisActive()Returns whether the focus represents a valid, active cursor.model()Returns the value of themodelrecord component.pixel()Returns the value of thepixelrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.Returns a focus value by key (renderer/model-supplied).values()Returns the value of thevaluesrecord component.Returns a new focus instance with an additional value.doublex()Returns the value of thexrecord component.doubley()Returns the value of theyrecord component.
-
Field Details
-
EMPTY
-
-
Constructor Details
-
ChartFocus
public ChartFocus(Point pixel, double x, double y, int index, ChartModel model, Instant timestamp, Map<String, Object> values) Creates an instance of aChartFocusrecord class.- Parameters:
pixel- the value for thepixelrecord componentx- the value for thexrecord componenty- the value for theyrecord componentindex- the value for theindexrecord componentmodel- the value for themodelrecord componenttimestamp- the value for thetimestamprecord componentvalues- the value for thevaluesrecord component
-
-
Method Details
-
isActive
public boolean isActive()Returns whether the focus represents a valid, active cursor.- Returns:
- true if pixel/x/y are set to concrete values.
-
value
-
withValue
Returns a new focus instance with an additional value.- Parameters:
key- value key (non-null)value- value to add- Returns:
- a new
ChartFocusinstance
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
pixel
Returns the value of thepixelrecord component.- Returns:
- the value of the
pixelrecord component
-
x
public double x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public double y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-
index
public int index()Returns the value of theindexrecord component.- Returns:
- the value of the
indexrecord component
-
model
Returns the value of themodelrecord component.- Returns:
- the value of the
modelrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-
values
-