Package com.digitizer.core
Class CoordinateTransformer
java.lang.Object
com.digitizer.core.CoordinateTransformer
Handles coordinate transformations between data space and canvas (pixel)
space.
The transformer converts between the application's numeric data units and
image pixel positions (the image's natural pixel coordinate system).
Note: the CanvasPanel renders the image into the JavaFX Canvas
at a scaled size and with offsets; therefore the CoordinateTransformer
works in image (natural) pixel coordinates, and callers in the UI layer
should convert between image pixels and canvas coordinates when drawing
or handling mouse events. The transformer respects
CalibrationState (anchor points and log flags)
and provides helper methods used by the CanvasPanel
and AutoTracer.
-
Constructor Summary
ConstructorsConstructorDescriptionCoordinateTransformer(CalibrationState calibration) Constructs a new CoordinateTransformer with the given calibration state. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.geometry.Point2DcanvasToData(double canvasX, double canvasY) Transforms image-pixel coordinates to data coordinates.javafx.geometry.Point2DcanvasToData(double canvasX, double canvasY, boolean useSecondaryY) Transforms image-pixel coordinates to data coordinates selecting primary or secondary Y axis.javafx.geometry.Point2DdataToCanvas(double dataX, double dataY) Transforms data coordinates to image-pixel coordinates.javafx.geometry.Point2DdataToCanvas(double dataX, double dataY, boolean useSecondaryY) Transforms data coordinates to image-pixel coordinates selecting primary or secondary Y axis.
-
Constructor Details
-
CoordinateTransformer
Constructs a new CoordinateTransformer with the given calibration state.- Parameters:
calibration- the calibration state containing anchor points and ranges
-
-
Method Details
-
dataToCanvas
public javafx.geometry.Point2D dataToCanvas(double dataX, double dataY) Transforms data coordinates to image-pixel coordinates.- Parameters:
dataX- the x value in data spacedataY- the y value in data space- Returns:
- a Point2D in canvas space, or (0, 0) if not calibrated
-
dataToCanvas
public javafx.geometry.Point2D dataToCanvas(double dataX, double dataY, boolean useSecondaryY) Transforms data coordinates to image-pixel coordinates selecting primary or secondary Y axis.- Parameters:
dataX- the x value in data spacedataY- the y value in data spaceuseSecondaryY- whether to use the secondary Y axis ranges/log flag- Returns:
- a Point2D in canvas space, or (0, 0) if not calibrated
-
canvasToData
public javafx.geometry.Point2D canvasToData(double canvasX, double canvasY) Transforms image-pixel coordinates to data coordinates.- Parameters:
canvasX- the x value in canvas spacecanvasY- the y value in canvas space- Returns:
- a Point2D in data space, or (0, 0) if not calibrated
-
canvasToData
public javafx.geometry.Point2D canvasToData(double canvasX, double canvasY, boolean useSecondaryY) Transforms image-pixel coordinates to data coordinates selecting primary or secondary Y axis.- Parameters:
canvasX- the x value in canvas spacecanvasY- the y value in canvas spaceuseSecondaryY- whether to interpret the Y value against the secondary Y axis- Returns:
- a Point2D in data space, or (0, 0) if not calibrated
-