|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.infinityloop.util.UnitConverter
public class UnitConverter
Unit converter class Converts between several units like cm, mm, twips, pt, inches etc.
Field Summary | |
---|---|
static int |
kUnit_cm
|
static int |
kUnit_Default
|
static int |
kUnit_emu
|
static int |
kUnit_hp
|
static int |
kUnit_in
|
static int |
kUnit_m
|
static int |
kUnit_mm
|
static int |
kUnit_pc
|
static int |
kUnit_pt
|
static int |
kUnit_px
|
static int |
kUnit_tw
|
Constructor Summary | |
---|---|
UnitConverter()
|
Method Summary | |
---|---|
static double |
convert(double src,
int srcUnit,
int destUnit)
Converts a value from one unit to another. |
static double |
convert(java.lang.String srcString,
int destUnit)
Converts a value from one unit to another. |
static java.lang.String |
convertString(double src,
int srcUnit,
int destUnit,
int prec)
Converts a value from one unit to another. |
static double |
getDPI()
Returns the currently set global DPI value used for calculating conversions |
static int |
getUnit(java.lang.String srcString)
Determines which unit a value passed as String is in. |
static int |
getUnitId(java.lang.String u,
int def)
converts an ASCII unit name string to its respective unit id |
static java.lang.String |
precisionString(double d,
int prec)
Convert the passed floating point value to a string representation with the specified number of decimals. |
static void |
setDPI(double dpi)
|
static void |
setPrecision(int decs)
Sets the precision to be used for all following conversions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int kUnit_cm
public static final int kUnit_mm
public static final int kUnit_m
public static final int kUnit_in
public static final int kUnit_tw
public static final int kUnit_pt
public static final int kUnit_pc
public static final int kUnit_px
public static final int kUnit_hp
public static final int kUnit_emu
public static final int kUnit_Default
Constructor Detail |
---|
public UnitConverter()
Method Detail |
---|
public static void setDPI(double dpi)
dpi
- sets the DPI value to use in subsequent calculationspublic static double getDPI()
public static void setPrecision(int decs)
decs
- the number of decimalspublic static double convert(double src, int srcUnit, int destUnit)
src
- source valuesrcUnit
- source unitdestUnit
- destination unit
public static int getUnit(java.lang.String srcString)
srcString
- source value
kUnit_Default
if it could not be determined.public static double convert(java.lang.String srcString, int destUnit)
srcString
- the source value stringdestUnit
- the unit to convert to
public static java.lang.String convertString(double src, int srcUnit, int destUnit, int prec)
src
- the source valuesrcUnit
- the unit the source value is indestUnit
- the unit to convert toprec
- the precision the resulting string should have
public static int getUnitId(java.lang.String u, int def)
public static java.lang.String precisionString(double d, int prec)
d
- the value to convert to a stringprec
- the decimal precision (number of decimals)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |