Package org.mapfish.print.map
Enum Class DistanceUnit
- All Implemented Interfaces:
Serializable
,Comparable<DistanceUnit>
,Constable
An enum for expressing distance units. Contains everything needed for conversions and others.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionRepresents the centimeter unit.Represents the lat long degree unit.Represents the american foot unit.Represents the american inch unit.Represents the kilometer unit.Represents the meter unit.Represents the american mile unit.Represents the lat long minute unit.Represents the millimeter unit.Represents the pica unit.Represents the point unit.Represents the pixel unit.Represents the lat long second unit.Represents the american yard unit. -
Method Summary
Modifier and TypeMethodDescriptiondouble
convertTo
(double value, DistanceUnit targetUnit) Convert values in this unit to the equivalent value in another unit.static DistanceUnit
fromProjection
(org.geotools.api.referencing.crs.CoordinateReferenceSystem projection) Determine the unit of the given projection.static DistanceUnit
fromString
(String val) Parse the value and return the identified unit object.final DistanceUnit[]
Return the sorted list (from smallest to biggest) of units sharing the same base unit.static DistanceUnit
getBestUnit
(double value, DistanceUnit unit) Return the first unit that would give a value >=1.boolean
isBase()
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.final String
toString()
static DistanceUnit
Returns the enum constant of this class with the specified name.static DistanceUnit[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
M
Represents the meter unit. -
MM
Represents the millimeter unit. -
CM
Represents the centimeter unit. -
KM
Represents the kilometer unit. -
FT
Represents the american foot unit. -
IN
Represents the american inch unit. -
YD
Represents the american yard unit. -
MI
Represents the american mile unit. -
DEGREES
Represents the lat long degree unit. -
MINUTE
Represents the lat long minute unit. -
SECOND
Represents the lat long second unit. -
PX
Represents the pixel unit. The conversion factor is the one used by JasperReports (1 inch = 72 pixel). -
PT
Represents the point unit. -
PC
Represents the pica unit.
-
-
Method Details
-
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
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 nameNullPointerException
- if the argument is null
-
fromString
Parse the value and return the identified unit object.- Parameters:
val
- the string to parse.- Returns:
- null if this unit is unknown
-
getBestUnit
Return the first unit that would give a value >=1.- Parameters:
value
- the valueunit
- 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
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 thisDistanceUnit
targetUnit
- the unit to convert value to (from this unit)
-
isSameBaseUnit
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
- Overrides:
toString
in classEnum<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.
-