Class HitTestUtils

java.lang.Object
com.arbergashi.charts.internal.HitTestUtils

public final class HitTestUtils extends Object
Internal utility for fast, allocation-free hit-testing.
Since:
2025-06-01
Version:
1.0.0
Author:
Arber Gashi
  • Method Details

    • nearestPointIndex

      public static Optional<Integer> nearestPointIndex(Point2D pixel, ChartModel model, PlotContext context)
      Finds the index of the nearest data point to a given pixel location. This method is zero-allocation and works directly on the model's primitive data.
      Parameters:
      pixel - The pixel coordinate to test against.
      model - The data model.
      context - The plot context for coordinate transformation.
      Returns:
      An Optional containing the index of the nearest point, or empty if not found.