Enum Class DistanceUnit

java.lang.Object
java.lang.Enum<DistanceUnit>
org.mapfish.print.map.DistanceUnit
All Implemented Interfaces:
Serializable, Comparable<DistanceUnit>, Constable

public enum DistanceUnit extends Enum<DistanceUnit>
An enum for expressing distance units. Contains everything needed for conversions and others.
  • Enum Constant Details

    • M

      public static final DistanceUnit M
      Represents the meter unit.
    • MM

      public static final DistanceUnit MM
      Represents the millimeter unit.
    • CM

      public static final DistanceUnit CM
      Represents the centimeter unit.
    • KM

      public static final DistanceUnit KM
      Represents the kilometer unit.
    • FT

      public static final DistanceUnit FT
      Represents the american foot unit.
    • IN

      public static final DistanceUnit IN
      Represents the american inch unit.
    • YD

      public static final DistanceUnit YD
      Represents the american yard unit.
    • MI

      public static final DistanceUnit MI
      Represents the american mile unit.
    • DEGREES

      public static final DistanceUnit DEGREES
      Represents the lat long degree unit.
    • MINUTE

      public static final DistanceUnit MINUTE
      Represents the lat long minute unit.
    • SECOND

      public static final DistanceUnit SECOND
      Represents the lat long second unit.
    • PX

      public static final DistanceUnit PX
      Represents the pixel unit. The conversion factor is the one used by JasperReports (1 inch = 72 pixel).
    • PT

      public static final DistanceUnit PT
      Represents the point unit.
    • PC

      public static final DistanceUnit PC
      Represents the pica unit.
  • Method Details

    • values

      public static DistanceUnit[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DistanceUnit valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null
    • fromString

      public static DistanceUnit fromString(String val)
      Parse the value and return the identified unit object.
      Parameters:
      val - the string to parse.
      Returns:
      null if this unit is unknown
    • getBestUnit

      public static DistanceUnit getBestUnit(double value, DistanceUnit unit)
      Return the first unit that would give a value >=1.
      Parameters:
      value - the value
      unit - the unit of the value
    • fromProjection

      public static DistanceUnit fromProjection(org.geotools.api.referencing.crs.CoordinateReferenceSystem projection)
      Determine the unit of the given projection.
      Parameters:
      projection - the projection to determine
    • isBase

      public boolean isBase()
    • convertTo

      public double convertTo(double value, DistanceUnit targetUnit)
      Convert values in this unit to the equivalent value in another unit.
       DistanceUnit.M.convertTo(1.0, DistanceUnit.MM)==1000.0
       
      Parameters:
      value - a value in the same unit as this DistanceUnit
      targetUnit - the unit to convert value to (from this unit)
    • isSameBaseUnit

      public boolean isSameBaseUnit(DistanceUnit target)
      Check if this unit and the target unit have the same "base" unit IE inches and feet have same base unit.
      Parameters:
      target - the unit to compare to this unit.
    • toString

      public final String toString()
      Overrides:
      toString in class Enum<DistanceUnit>
    • getAllUnits

      public final DistanceUnit[] getAllUnits()
      Return the sorted list (from smallest to biggest) of units sharing the same base unit.
      Returns:
      the sorted list (from smallest to biggest) of units sharing the same base unit.