Class UnitTranslator

java.lang.Object
toxi.math.conversion.UnitTranslator

public class UnitTranslator extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Number of millimeters per inch
    static final double
    Number of points per inch
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    millisToPixels(double mm, int dpi)
    Converts millimeters into pixels.
    static double
    millisToPoints(double mm)
    Converts millimeters into PostScript points.
    static double
    pixelsToInch(int pix, int dpi)
    Converts pixels into inches.
    static double
    pixelsToMillis(int pix, int dpi)
    Converts pixels into millimeters.
    static double
    pixelsToPoints(int pix, int dpi)
    Converts pixels into points.
    static double
    pointsToMillis(double pt)
    Converts points into millimeters.
    static int
    pointsToPixels(double pt, int dpi)
    Converts points into pixels.
    static double
    squareInchToMillis(double area)
    Converts an area measure in square inch to square millimeters.
    static double
    squarePointsToInch(double area)
    Converts an area measure in points to square inch.
    static double
    squarePointsToMillis(double area)
    Converts an area measure in points to square millimeters.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • INCH_MM

      public static final double INCH_MM
      Number of millimeters per inch
      See Also:
    • POINT_POSTSCRIPT

      public static final double POINT_POSTSCRIPT
      Number of points per inch
      See Also:
  • Constructor Details

    • UnitTranslator

      public UnitTranslator()
  • Method Details

    • millisToPixels

      public static int millisToPixels(double mm, int dpi)
      Converts millimeters into pixels.
      Parameters:
      mm - millimeters
      dpi - DPI resolution
      Returns:
      number of pixels
    • millisToPoints

      public static double millisToPoints(double mm)
      Converts millimeters into PostScript points.
      Parameters:
      mm - millimeters
      Returns:
      number of points
    • pixelsToInch

      public static double pixelsToInch(int pix, int dpi)
      Converts pixels into inches.
      Parameters:
      pix - pixels
      dpi - DPI resolution to use
      Returns:
      number of inches
    • pixelsToMillis

      public static double pixelsToMillis(int pix, int dpi)
      Converts pixels into millimeters.
      Parameters:
      pix - pixels
      dpi - DPI resolution
      Returns:
      number of millimeters
    • pixelsToPoints

      public static double pixelsToPoints(int pix, int dpi)
      Converts pixels into points.
      Parameters:
      pix - pixels
      dpi - DPI resolution
      Returns:
      number of points
    • pointsToMillis

      public static double pointsToMillis(double pt)
      Converts points into millimeters.
      Parameters:
      pt -
      Returns:
      number of millimeters
    • pointsToPixels

      public static int pointsToPixels(double pt, int dpi)
      Converts points into pixels.
      Parameters:
      pt - points
      dpi - DPI resolution
      Returns:
      number of pixels
    • squareInchToMillis

      public static double squareInchToMillis(double area)
      Converts an area measure in square inch to square millimeters.
      Parameters:
      area -
      Returns:
      square mm
    • squarePointsToInch

      public static double squarePointsToInch(double area)
      Converts an area measure in points to square inch.
      Parameters:
      area -
      Returns:
      square inch
    • squarePointsToMillis

      public static double squarePointsToMillis(double area)
      Converts an area measure in points to square millimeters.
      Parameters:
      area -
      Returns:
      square mm