Class RenderingTransformAid


  • public class RenderingTransformAid
    extends Object
    Provides an aid for establishing a Cartesian coordinate system for rendering 2D drawings as well as utilities for initializing a graphics surface.
    • Constructor Detail

      • RenderingTransformAid

        public RenderingTransformAid​(int width,
                                     int height,
                                     int pad,
                                     double x0,
                                     double y0,
                                     double x1,
                                     double y1)
        Constructs resources for a coordinate system appropriate for the presentation of a rectangular region defined by the specified coordinates. The transforms created by this class will be appropriate for drawing graphs within the coordinate domain as large as possible within the bounds of the specified size of the graphics surface based on width, height, and padding allowance.
        Parameters:
        width - the width of the drawing surface, in pixels
        height - the height of the drawing surface, in pixels
        pad - an arbitrary padding to be added to each side of the rectangle, in pixels
        x0 - Cartesian x coordinate for the lower-left corner of the domain
        y0 - Cartesian y coordinate for the lower-left corner of the domain
        x1 - Cartesian x coordinate for the upper-right corner of the domain
        y1 - Cartesian y coordinate for the upper-right corner of the domain
    • Method Detail

      • getCartesianToPixelTransform

        public AffineTransform getCartesianToPixelTransform()
        Gets the affine transform for mapping Cartesian coordinates to pixel coordinates. The transform was established by the constructor for this class.
        Returns:
        a valid instance of an affine transform
      • getPixelToCartesianTransform

        public AffineTransform getPixelToCartesianTransform()
        Gets the affine transform for mapping pixel coordinates to Cartesian coordinates. The transform was established by the constructor for this class.
        Returns:
        a valid instance of an affine transform
      • getDomainRectangle

        public Rectangle2D getDomainRectangle()
        Gets the rectangle for the drawing area corresponding to the coordinate domain that was specified for the constructor. This rectangle is suitable for use as a clipping rectangle when creating images.
        Returns:
        a valid instance of a rectangle, in pixel coordinates.
      • getUnitsPerPixel

        public double getUnitsPerPixel()
        Gets the distance across a pixel in the corresponding Cartesian coordinate system.
        Returns:
        a non-zero floating point value
      • getPixelsPerUnit

        public double getPixelsPerUnit()
        Gets the distance in pixels across one unit of distance in the Cartesian coordinate system.
        Returns:
        a non-zero floating point value