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
    Modifier and Type
    Field
    Description
    static final ChartFocus
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ChartFocus(Point pixel, double x, double y, int index, ChartModel model, Instant timestamp, Map<String,Object> values)
    Creates an instance of a ChartFocus record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the index record component.
    boolean
    Returns whether the focus represents a valid, active cursor.
    Returns the value of the model record component.
    Returns the value of the pixel record component.
    Returns the value of the timestamp record component.
    final String
    Returns a string representation of this record class.
    Returns a focus value by key (renderer/model-supplied).
    Returns the value of the values record component.
    withValue(String key, Object value)
    Returns a new focus instance with an additional value.
    double
    x()
    Returns the value of the x record component.
    double
    y()
    Returns the value of the y record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • 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 a ChartFocus record class.
      Parameters:
      pixel - the value for the pixel record component
      x - the value for the x record component
      y - the value for the y record component
      index - the value for the index record component
      model - the value for the model record component
      timestamp - the value for the timestamp record component
      values - the value for the values record 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

      public Object value(String key)
      Returns a focus value by key (renderer/model-supplied).
      Parameters:
      key - value key
      Returns:
      the value or null if missing
    • withValue

      public ChartFocus withValue(String key, Object value)
      Returns a new focus instance with an additional value.
      Parameters:
      key - value key (non-null)
      value - value to add
      Returns:
      a new ChartFocus instance
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • pixel

      public Point pixel()
      Returns the value of the pixel record component.
      Returns:
      the value of the pixel record component
    • x

      public double x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public double y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component
    • index

      public int index()
      Returns the value of the index record component.
      Returns:
      the value of the index record component
    • model

      public ChartModel model()
      Returns the value of the model record component.
      Returns:
      the value of the model record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component
    • values

      public Map<String,Object> values()
      Returns the value of the values record component.
      Returns:
      the value of the values record component