Interface PlotContext

All Known Implementing Classes:
CartesianPlotContext, DefaultPlotContext, DefaultPlotContext

public interface PlotContext
Context for drawing a plot. Defines the visible data range and screen boundaries. Used for coordinate transformations between data and pixel space.

Framework note: A ChartTheme may be provided by the chart panel. Code should prefer theme() over any global/static theme access.

Since:
2025-06-15
Version:
1.0.0
Author:
Arber Gashi
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Whether the X axis is inverted (max-to-min).
    default boolean
    Whether the Y axis is inverted (max-to-min).
    default boolean
    Whether the Y axis uses a logarithmic scale.
    void
    mapToData(double pixelX, double pixelY, double[] dest)
    Allocation-free inverse transform: pixel -> data coordinates.
    void
    mapToPixel(double x, double y, double[] out)
    Transforms data coordinates into pixel coordinates.
    double
    Maximum visible X value (data coordinates).
    double
    Maximum visible Y value (data coordinates).
    double
    Minimum visible X value (data coordinates).
    double
    Minimum visible Y value (data coordinates).
    The pixel bounds of the plotting area.
    default double
    Width of the data range.
    default double
    Height of the data range.
    Rendering hints for the current render pass.
    Scale mode for X axis (used by helpers such as NiceScale).
    Scale mode for Y axis (used by helpers such as NiceScale).
    default ChartTheme
    Theme associated with the current rendering context.
  • Method Details

    • minX

      double minX()
      Minimum visible X value (data coordinates).
    • maxX

      double maxX()
      Maximum visible X value (data coordinates).
    • minY

      double minY()
      Minimum visible Y value (data coordinates).
    • maxY

      double maxY()
      Maximum visible Y value (data coordinates).
    • plotBounds

      Rectangle2D plotBounds()
      The pixel bounds of the plotting area.
    • mapToPixel

      void mapToPixel(double x, double y, double[] out)
      Transforms data coordinates into pixel coordinates.

      Zero-Allocation: The result is written into the provided array.

      Parameters:
      x - X value (data)
      y - Y value (data)
      out - Array of length at least 2. out[0] = pixelX, out[1] = pixelY.
    • rangeX

      default double rangeX()
      Width of the data range.
    • rangeY

      default double rangeY()
      Height of the data range.
    • mapToData

      void mapToData(double pixelX, double pixelY, double[] dest)
      Allocation-free inverse transform: pixel -> data coordinates. Writes the result into dest[0]=dataX, dest[1]=dataY.
    • scaleModeX

      default NiceScale.ScaleMode scaleModeX()
      Scale mode for X axis (used by helpers such as NiceScale).
    • scaleModeY

      default NiceScale.ScaleMode scaleModeY()
      Scale mode for Y axis (used by helpers such as NiceScale).
    • isLogarithmicY

      default boolean isLogarithmicY()
      Whether the Y axis uses a logarithmic scale.
    • isInvertedX

      default boolean isInvertedX()
      Whether the X axis is inverted (max-to-min).
    • isInvertedY

      default boolean isInvertedY()
      Whether the Y axis is inverted (max-to-min).
    • renderHints

      default ChartRenderHints renderHints()
      Rendering hints for the current render pass.
    • theme

      default ChartTheme theme()
      Theme associated with the current rendering context.

      Framework contract: This must be non-null during rendering. Implementations that do not manage per-panel themes should return a stable default such as ChartThemes.defaultDark().