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 TypeMethodDescriptiondefault booleanWhether the X axis is inverted (max-to-min).default booleanWhether the Y axis is inverted (max-to-min).default booleanWhether the Y axis uses a logarithmic scale.voidmapToData(double pixelX, double pixelY, double[] dest) Allocation-free inverse transform: pixel -> data coordinates.voidmapToPixel(double x, double y, double[] out) Transforms data coordinates into pixel coordinates.doublemaxX()Maximum visible X value (data coordinates).doublemaxY()Maximum visible Y value (data coordinates).doubleminX()Minimum visible X value (data coordinates).doubleminY()Minimum visible Y value (data coordinates).The pixel bounds of the plotting area.default doublerangeX()Width of the data range.default doublerangeY()Height of the data range.default ChartRenderHintsRendering hints for the current render pass.default NiceScale.ScaleModeScale mode for X axis (used by helpers such as NiceScale).default NiceScale.ScaleModeScale mode for Y axis (used by helpers such as NiceScale).default ChartThemetheme()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
Scale mode for X axis (used by helpers such as NiceScale). -
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
Rendering hints for the current render pass. -
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().
-