Enum Unit

    • Enum Constant Detail

      • Inch

        public static final Unit Inch
      • Point

        public static final Unit Point
      • Feet

        public static final Unit Feet
      • Yard

        public static final Unit Yard
      • Millimeter

        public static final Unit Millimeter
      • Centimeter

        public static final Unit Centimeter
      • Meter

        public static final Unit Meter
      • Pica

        public static final Unit Pica
      • TypographicalPoint

        public static final Unit TypographicalPoint
      • JadiceDocumentUnit

        public static final Unit JadiceDocumentUnit
      • Pixel

        @Deprecated
        public static final Unit Pixel
        Deprecated.
        Pixels depend on the screen resolution. Use Point for further implementations.
    • Method Detail

      • values

        public static Unit[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Unit c : Unit.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Unit valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • convertTo

        public float convertTo​(Unit dstUnit,
                               float value)
        Convert the given value in this unit to the given destination unit.
        Parameters:
        dstUnit - the destination (desired) unit
        value - the value
        Returns:
        the value in destination units
        Throws:
        NullPointerException - if dstUnit is null
      • convertTo

        public double convertTo​(Unit dstUnit,
                                double value)
        Convert the given value in this unit to the given destination unit.
        Parameters:
        dstUnit - the destination (desired) unit
        value - the value
        Returns:
        the value in destination units
        Throws:
        NullPointerException - if dstUnit is null
      • convertFrom

        public float convertFrom​(Unit srcUnit,
                                 float value)
        Convert the given value in the given destination unit to this unit.
        Parameters:
        srcUnit - the source (current) unit
        value - the value
        Returns:
        the value in this units
        Throws:
        NullPointerException - if srcUnit is null
      • convertFrom

        public double convertFrom​(Unit srcUnit,
                                  double value)
        Convert the given value in the given destination unit to this unit.
        Parameters:
        srcUnit - the source (current) unit
        value - the value
        Returns:
        the value in this units
        Throws:
        NullPointerException - if srcUnit is null