Record Class DefaultPlotContext

java.lang.Object
java.lang.Record
com.arbergashi.charts.api.DefaultPlotContext
All Implemented Interfaces:
PlotContext

public record DefaultPlotContext(Rectangle2D bounds, double minX, double maxX, double minY, double maxY, boolean logarithmicY, boolean invertedX, boolean invertedY, NiceScale.ScaleMode scaleModeX, NiceScale.ScaleMode scaleModeY, ChartTheme theme, ChartRenderHints renderHints) extends Record implements PlotContext
Default PlotContext implementation.

This is a stable, public implementation that applications and renderers can use without depending on com.arbergashi.charts.internal.* types.

Performance: The zero-allocation mapToPixel(double, double, double[]) and mapToData(double, double, double[]) methods are designed for the render hot-path.

Since:
2025-06-01
Version:
1.0.0
Author:
Arber Gashi
  • Constructor Details

    • DefaultPlotContext

      public DefaultPlotContext(Rectangle2D bounds, double minX, double maxX, double minY, double maxY, boolean logarithmicY, boolean invertedX, boolean invertedY, NiceScale.ScaleMode scaleModeX, NiceScale.ScaleMode scaleModeY, ChartTheme theme, ChartRenderHints renderHints)
      Creates an instance of a DefaultPlotContext record class.
      Parameters:
      bounds - the value for the bounds record component
      minX - the value for the minX record component
      maxX - the value for the maxX record component
      minY - the value for the minY record component
      maxY - the value for the maxY record component
      logarithmicY - the value for the logarithmicY record component
      invertedX - the value for the invertedX record component
      invertedY - the value for the invertedY record component
      scaleModeX - the value for the scaleModeX record component
      scaleModeY - the value for the scaleModeY record component
      theme - the value for the theme record component
      renderHints - the value for the renderHints record component
    • DefaultPlotContext

      public DefaultPlotContext(Rectangle2D bounds, double minX, double maxX, double minY, double maxY, boolean logarithmicY, NiceScale.ScaleMode scaleModeX, NiceScale.ScaleMode scaleModeY)
      Backwards-compatible constructor without theme.
    • DefaultPlotContext

      public DefaultPlotContext(Rectangle2D bounds, double minX, double maxX, double minY, double maxY, boolean logarithmicY, boolean invertedX, boolean invertedY, NiceScale.ScaleMode scaleModeX, NiceScale.ScaleMode scaleModeY)
      Constructor that allows axis inversion without a theme or render hints.
    • DefaultPlotContext

      public DefaultPlotContext(Rectangle2D bounds, ChartModel model, double viewMinX, double viewMaxX, double viewMinY, double viewMaxY)
      Constructor that derives scaling from the model with optional view overrides.
    • DefaultPlotContext

      public DefaultPlotContext(Rectangle2D bounds, ChartModel model, double viewMinX, double viewMaxX, double viewMinY, double viewMaxY, ChartTheme theme)
      Theme-aware constructor that derives scaling from the model with optional view overrides.
    • DefaultPlotContext

      public DefaultPlotContext(Rectangle2D bounds, ChartModel model, double viewMinX, double viewMaxX, double viewMinY, double viewMaxY, ChartTheme theme, ChartRenderHints renderHints)
      Theme-aware constructor with render hints.
  • Method Details

    • plotBounds

      public Rectangle2D plotBounds()
      Description copied from interface: PlotContext
      The pixel bounds of the plotting area.
      Specified by:
      plotBounds in interface PlotContext
    • mapToPixel

      public void mapToPixel(double x, double y, double[] out)
      Description copied from interface: PlotContext
      Transforms data coordinates into pixel coordinates.

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

      Specified by:
      mapToPixel in interface PlotContext
      Parameters:
      x - X value (data)
      y - Y value (data)
      out - Array of length at least 2. out[0] = pixelX, out[1] = pixelY.
    • mapToData

      public void mapToData(double pixelX, double pixelY, double[] dest)
      Description copied from interface: PlotContext
      Allocation-free inverse transform: pixel -> data coordinates. Writes the result into dest[0]=dataX, dest[1]=dataY.
      Specified by:
      mapToData in interface PlotContext
    • isLogarithmicY

      public boolean isLogarithmicY()
      Description copied from interface: PlotContext
      Whether the Y axis uses a logarithmic scale.
      Specified by:
      isLogarithmicY in interface PlotContext
    • isInvertedX

      public boolean isInvertedX()
      Description copied from interface: PlotContext
      Whether the X axis is inverted (max-to-min).
      Specified by:
      isInvertedX in interface PlotContext
    • isInvertedY

      public boolean isInvertedY()
      Description copied from interface: PlotContext
      Whether the Y axis is inverted (max-to-min).
      Specified by:
      isInvertedY in interface PlotContext
    • 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.
    • bounds

      public Rectangle2D bounds()
      Returns the value of the bounds record component.
      Returns:
      the value of the bounds record component
    • minX

      public double minX()
      Returns the value of the minX record component.
      Specified by:
      minX in interface PlotContext
      Returns:
      the value of the minX record component
    • maxX

      public double maxX()
      Returns the value of the maxX record component.
      Specified by:
      maxX in interface PlotContext
      Returns:
      the value of the maxX record component
    • minY

      public double minY()
      Returns the value of the minY record component.
      Specified by:
      minY in interface PlotContext
      Returns:
      the value of the minY record component
    • maxY

      public double maxY()
      Returns the value of the maxY record component.
      Specified by:
      maxY in interface PlotContext
      Returns:
      the value of the maxY record component
    • logarithmicY

      public boolean logarithmicY()
      Returns the value of the logarithmicY record component.
      Returns:
      the value of the logarithmicY record component
    • invertedX

      public boolean invertedX()
      Returns the value of the invertedX record component.
      Returns:
      the value of the invertedX record component
    • invertedY

      public boolean invertedY()
      Returns the value of the invertedY record component.
      Returns:
      the value of the invertedY record component
    • scaleModeX

      public NiceScale.ScaleMode scaleModeX()
      Returns the value of the scaleModeX record component.
      Specified by:
      scaleModeX in interface PlotContext
      Returns:
      the value of the scaleModeX record component
    • scaleModeY

      public NiceScale.ScaleMode scaleModeY()
      Returns the value of the scaleModeY record component.
      Specified by:
      scaleModeY in interface PlotContext
      Returns:
      the value of the scaleModeY record component
    • theme

      public ChartTheme theme()
      Returns the value of the theme record component.
      Specified by:
      theme in interface PlotContext
      Returns:
      the value of the theme record component
    • renderHints

      public ChartRenderHints renderHints()
      Returns the value of the renderHints record component.
      Specified by:
      renderHints in interface PlotContext
      Returns:
      the value of the renderHints record component