Package org.tinfour.utils.rendering
Class RenderingTransformAid
- java.lang.Object
-
- org.tinfour.utils.rendering.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 Summary
Constructors Constructor Description 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AffineTransformgetCartesianToPixelTransform()Gets the affine transform for mapping Cartesian coordinates to pixel coordinates.Rectangle2DgetDomainRectangle()Gets the rectangle for the drawing area corresponding to the coordinate domain that was specified for the constructor.doublegetPixelsPerUnit()Gets the distance in pixels across one unit of distance in the Cartesian coordinate system.AffineTransformgetPixelToCartesianTransform()Gets the affine transform for mapping pixel coordinates to Cartesian coordinates.doublegetUnitsPerPixel()Gets the distance across a pixel in the corresponding Cartesian coordinate system.
-
-
-
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 pixelsheight- the height of the drawing surface, in pixelspad- an arbitrary padding to be added to each side of the rectangle, in pixelsx0- Cartesian x coordinate for the lower-left corner of the domainy0- Cartesian y coordinate for the lower-left corner of the domainx1- Cartesian x coordinate for the upper-right corner of the domainy1- 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
-
-