Class CartesianPlotContext
java.lang.Object
com.arbergashi.charts.api.CartesianPlotContext
- All Implemented Interfaces:
PlotContext
Standard
PlotContext implementation for Cartesian coordinate systems.
This context is optimized for rendering performance. It precomputes linear scaling factors
so mapToPixel(double, double, double[]) and mapToData(double, double, double[])
run in constant time with no intermediate allocations.
- Since:
- 2025-06-01
- Version:
- 1.0.0
- Author:
- Arber Gashi
-
Constructor Summary
ConstructorsConstructorDescriptionCartesianPlotContext(Rectangle2D bounds, double minX, double maxX, double minY, double maxY) Creates a new context for the given data range and plot bounds. -
Method Summary
Modifier and TypeMethodDescriptionvoidmapToData(double pixelX, double pixelY, double[] dest) Maps pixel coordinates to data coordinates.voidmapToPixel(double dataX, double dataY, double[] dest) Maps data coordinates to 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).Returns the plot bounds in pixel coordinates.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PlotContext
isInvertedX, isInvertedY, isLogarithmicY, rangeX, rangeY, renderHints, scaleModeX, scaleModeY, theme
-
Constructor Details
-
CartesianPlotContext
Creates a new context for the given data range and plot bounds.- Parameters:
bounds- the plot area in pixel coordinatesminX- minimum visible X value (data coordinates)maxX- maximum visible X value (data coordinates)minY- minimum visible Y value (data coordinates)maxY- maximum visible Y value (data coordinates)- Throws:
IllegalArgumentException- ifminX >= maxXorminY >= maxY
-
-
Method Details
-
mapToPixel
public void mapToPixel(double dataX, double dataY, double[] dest) Maps data coordinates to pixel coordinates.Allocation-free: writes the result to
destwhere dest[0] is X and dest[1] is Y.- Specified by:
mapToPixelin interfacePlotContext- Parameters:
dataX- X in data coordinatesdataY- Y in data coordinatesdest- output array of length at least 2
-
mapToData
public void mapToData(double pixelX, double pixelY, double[] dest) Maps pixel coordinates to data coordinates.Allocation-free: writes the result to
destwhere dest[0] is X and dest[1] is Y.- Specified by:
mapToDatain interfacePlotContext- Parameters:
pixelX- X in pixel coordinatespixelY- Y in pixel coordinatesdest- output array of length at least 2
-
plotBounds
Returns the plot bounds in pixel coordinates.- Specified by:
plotBoundsin interfacePlotContext
-
minX
public double minX()Description copied from interface:PlotContextMinimum visible X value (data coordinates).- Specified by:
minXin interfacePlotContext- Returns:
- minimum visible X value (data coordinates)
-
maxX
public double maxX()Description copied from interface:PlotContextMaximum visible X value (data coordinates).- Specified by:
maxXin interfacePlotContext- Returns:
- maximum visible X value (data coordinates)
-
minY
public double minY()Description copied from interface:PlotContextMinimum visible Y value (data coordinates).- Specified by:
minYin interfacePlotContext- Returns:
- minimum visible Y value (data coordinates)
-
maxY
public double maxY()Description copied from interface:PlotContextMaximum visible Y value (data coordinates).- Specified by:
maxYin interfacePlotContext- Returns:
- maximum visible Y value (data coordinates)
-