@@ -0,0 +1,2502 @@
+package eu.greenlightning.hypercubepdf;%0A%0A/**%0A * Utility class for converting between common units (inches, millimeters) and default user space units.%0A * %3Cp%3E%0A * PDF defines a device-independent coordinate system for each page called user space. Most values used while%0A * creating the PDF are specified in user space coordinates.%0A * %3Cp%3E%0A * Since PDF version 1.6 it is possible to specify the length of the unit of the user space. However, if it is%0A * not specified or the PDF does not support specifying it, the default value of 1 / 72 inch is used.%0A * %3Cp%3E%0A * This class can only deal with values from the default user space. If you change the length of the user%0A * space unit, you need to convert values manually.%0A * %3Cp%3E%0A * PDFBox uses %7B@code float%7Ds to represent user space coordinates and so does Hypercube.%0A *%0A * @author Green Lightning%0A */%0Apublic final class HCPUnits %7B%0A%0A%09private static final float DEFAULT_USER_SPACE_UNITS_PER_INCH = 72;%0A%09private static final float MILLIMETERS_PER_INCH = 25.4f;%0A%0A%09/**%0A%09 * Converts from inches to default user space units.%0A%09 * %0A%09 * @param inches a value in inches%0A%09 * @return the value converted to default user space units%0A%09 * @see HCPUnits Default User Space%0A%09 */%0A%09public static float defaultUserSpaceUnitsFromInches(float inches) %7B%0A%09%09return inches * DEFAULT_USER_SPACE_UNITS_PER_INCH;%0A%09%7D%0A%09%0A%09/**%0A%09 * Converts from default user space units to inches.%0A%09 * %0A%09 * @param units a value in default user space units%0A%09 * @return the value converted to inches%0A%09 * @see HCPUnits Default User Space%0A%09 */%0A%09public static float inchesFromDefaultUserSpaceUnits(float units) %7B%0A%09%09return units / DEFAULT_USER_SPACE_UNITS_PER_INCH;%0A%09%7D%0A%0A%09/**%0A%09 * Converts from millimeters to default user space units.%0A%09 * %0A%09 * @param millimeters a value in millimeters%0A%09 * @return the value converted to default user space units%0A%09 * @see HCPUnits Default User Space%0A%09 */%0A%09public static float defaultUserSpaceUnitsFromMillimeters(float millimeters) %7B%0A%09%09return (millimeters / MILLIMETERS_PER_INCH) * DEFAULT_USER_SPACE_UNITS_PER_INCH;%0A%09%7D%0A%0A%09/**%0A%09 * Converts from default user space units to millimeters.%0A%09 * %0A%09 * @param units a value in default user space units%0A%09 * @return the value converted to millimeters%0A%09 * @see HCPUnits Default User Space%0A%09 */%0A%09public static float millimetersFromDefaultUserSpaceUnits(float units) %7B%0A%09%09return (units / DEFAULT_USER_SPACE_UNITS_PER_INCH) * MILLIMETERS_PER_INCH;%0A%09%7D%0A%0A%09// prevent instantiation%0A%09private HCPUnits() %7B%0A%09%09throw new UnsupportedOperationException();%0A%09%7D%0A%0A%7D%0A

Add HCPUnits.