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 Summary
ConstructorsConstructorDescriptionDefaultPlotContext(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(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 aDefaultPlotContextrecord class.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(Rectangle2D bounds, ChartModel model, double viewMinX, double viewMaxX, double viewMinY, double viewMaxY) Constructor that derives scaling from the model with optional view overrides.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(Rectangle2D bounds, ChartModel model, double viewMinX, double viewMaxX, double viewMinY, double viewMaxY, ChartTheme theme, ChartRenderHints renderHints) Theme-aware constructor with render hints. -
Method Summary
Modifier and TypeMethodDescriptionbounds()Returns the value of theboundsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturns the value of theinvertedXrecord component.booleanReturns the value of theinvertedYrecord component.booleanWhether the X axis is inverted (max-to-min).booleanWhether the Y axis is inverted (max-to-min).booleanWhether the Y axis uses a logarithmic scale.booleanReturns the value of thelogarithmicYrecord component.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()Returns the value of themaxXrecord component.doublemaxY()Returns the value of themaxYrecord component.doubleminX()Returns the value of theminXrecord component.doubleminY()Returns the value of theminYrecord component.The pixel bounds of the plotting area.Returns the value of therenderHintsrecord component.Returns the value of thescaleModeXrecord component.Returns the value of thescaleModeYrecord component.theme()Returns the value of thethemerecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from interface PlotContext
rangeX, rangeY
-
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 aDefaultPlotContextrecord class.- Parameters:
bounds- the value for theboundsrecord componentminX- the value for theminXrecord componentmaxX- the value for themaxXrecord componentminY- the value for theminYrecord componentmaxY- the value for themaxYrecord componentlogarithmicY- the value for thelogarithmicYrecord componentinvertedX- the value for theinvertedXrecord componentinvertedY- the value for theinvertedYrecord componentscaleModeX- the value for thescaleModeXrecord componentscaleModeY- the value for thescaleModeYrecord componenttheme- the value for thethemerecord componentrenderHints- the value for therenderHintsrecord 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
Description copied from interface:PlotContextThe pixel bounds of the plotting area.- Specified by:
plotBoundsin interfacePlotContext
-
mapToPixel
public void mapToPixel(double x, double y, double[] out) Description copied from interface:PlotContextTransforms data coordinates into pixel coordinates.Zero-Allocation: The result is written into the provided array.
- Specified by:
mapToPixelin interfacePlotContext- 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:PlotContextAllocation-free inverse transform: pixel -> data coordinates. Writes the result into dest[0]=dataX, dest[1]=dataY.- Specified by:
mapToDatain interfacePlotContext
-
isLogarithmicY
public boolean isLogarithmicY()Description copied from interface:PlotContextWhether the Y axis uses a logarithmic scale.- Specified by:
isLogarithmicYin interfacePlotContext
-
isInvertedX
public boolean isInvertedX()Description copied from interface:PlotContextWhether the X axis is inverted (max-to-min).- Specified by:
isInvertedXin interfacePlotContext
-
isInvertedY
public boolean isInvertedY()Description copied from interface:PlotContextWhether the Y axis is inverted (max-to-min).- Specified by:
isInvertedYin interfacePlotContext
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
bounds
Returns the value of theboundsrecord component.- Returns:
- the value of the
boundsrecord component
-
minX
public double minX()Returns the value of theminXrecord component.- Specified by:
minXin interfacePlotContext- Returns:
- the value of the
minXrecord component
-
maxX
public double maxX()Returns the value of themaxXrecord component.- Specified by:
maxXin interfacePlotContext- Returns:
- the value of the
maxXrecord component
-
minY
public double minY()Returns the value of theminYrecord component.- Specified by:
minYin interfacePlotContext- Returns:
- the value of the
minYrecord component
-
maxY
public double maxY()Returns the value of themaxYrecord component.- Specified by:
maxYin interfacePlotContext- Returns:
- the value of the
maxYrecord component
-
logarithmicY
public boolean logarithmicY()Returns the value of thelogarithmicYrecord component.- Returns:
- the value of the
logarithmicYrecord component
-
invertedX
public boolean invertedX()Returns the value of theinvertedXrecord component.- Returns:
- the value of the
invertedXrecord component
-
invertedY
public boolean invertedY()Returns the value of theinvertedYrecord component.- Returns:
- the value of the
invertedYrecord component
-
scaleModeX
Returns the value of thescaleModeXrecord component.- Specified by:
scaleModeXin interfacePlotContext- Returns:
- the value of the
scaleModeXrecord component
-
scaleModeY
Returns the value of thescaleModeYrecord component.- Specified by:
scaleModeYin interfacePlotContext- Returns:
- the value of the
scaleModeYrecord component
-
theme
Returns the value of thethemerecord component.- Specified by:
themein interfacePlotContext- Returns:
- the value of the
themerecord component
-
renderHints
Returns the value of therenderHintsrecord component.- Specified by:
renderHintsin interfacePlotContext- Returns:
- the value of the
renderHintsrecord component
-