Class CoordinateTransformer

java.lang.Object
com.digitizer.core.CoordinateTransformer

public class CoordinateTransformer extends Object
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

    Constructors
    Constructor
    Description
    Constructs a new CoordinateTransformer with the given calibration state.
  • Method Summary

    Modifier and Type
    Method
    Description
    javafx.geometry.Point2D
    canvasToData(double canvasX, double canvasY)
    Transforms image-pixel coordinates to data coordinates.
    javafx.geometry.Point2D
    canvasToData(double canvasX, double canvasY, boolean useSecondaryY)
    Transforms image-pixel coordinates to data coordinates selecting primary or secondary Y axis.
    javafx.geometry.Point2D
    dataToCanvas(double dataX, double dataY)
    Transforms data coordinates to image-pixel coordinates.
    javafx.geometry.Point2D
    dataToCanvas(double dataX, double dataY, boolean useSecondaryY)
    Transforms data coordinates to image-pixel coordinates selecting primary or secondary Y axis.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CoordinateTransformer

      public CoordinateTransformer(CalibrationState calibration)
      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 space
      dataY - 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 space
      dataY - the y value in data space
      useSecondaryY - 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 space
      canvasY - 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 space
      canvasY - the y value in canvas space
      useSecondaryY - whether to interpret the Y value against the secondary Y axis
      Returns:
      a Point2D in data space, or (0, 0) if not calibrated