|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Number com.cc.framework.ui.html.LengthUnit
This class encapsulates HTML length units
Field Summary | |
private static double[] |
CONVERSION
The following table holds the conversion factors from 1 inch to the corresponding unit The order is: CM; MM; IN; PT; PC; PX; EM; EX |
private static long |
serialVersionUID
Serial Version UID |
private int |
type
Size type |
static int |
TYPE_LENGTH
Type discriminator: Length |
static int |
TYPE_PERCENTAGE
Type discriminator: Percentage |
private int |
unit
unit designator |
private static java.lang.String[] |
UNIT
Unit Strings |
static int |
UNIT_CM
Centimeters |
static int |
UNIT_EM
The height of the element's font |
static int |
UNIT_EX
The height of the letter "x" |
static int |
UNIT_IN
Inches (1 inch = 2.54 centimeters) |
static int |
UNIT_MM
Millimeters |
static int |
UNIT_PC
Picas (1 pica = 12 points) |
static int |
UNIT_PT
Points (1 point = 1/72 inches) |
static int |
UNIT_PX
Pixels |
private double |
value
Floating-point number for the length or a percentage of the parent object's unit |
Constructor Summary | |
|
LengthUnit(double value)
Constructs a length in pixels |
|
LengthUnit(double value,
int unit)
Constructor |
private |
LengthUnit(int type,
double value,
int unit)
Constructor |
private |
LengthUnit(LengthUnit other)
Copy Constructor |
Method Summary | |
LengthUnit |
convert(int targetUnit)
Converts the length to the given unit. |
private boolean |
convertable(int unit)
|
double |
doubleValue()
|
float |
floatValue()
|
int |
getType()
|
int |
getUnit()
|
int |
intValue()
|
boolean |
isAbsoluteValue()
|
private static boolean |
isDigit(char ch)
Check if the given character is a digit or a dot |
boolean |
isRelativeValue()
|
long |
longValue()
|
LengthUnit |
minus(double summand)
adds a literal to the current length |
LengthUnit |
minus(LengthUnit summand)
adds a literal to the current length |
static LengthUnit |
parse(java.lang.String str)
Parses a String and creates a LengthUnit object |
LengthUnit |
plus(double summand)
adds a literal to the current length |
LengthUnit |
plus(LengthUnit summand)
adds a literal to the current length |
java.lang.String |
toString()
|
java.lang.String |
toString(int decimals)
|
private java.lang.String |
valueStr(int decimals)
Format the given double value with the given number of fraction digits |
Methods inherited from class java.lang.Number |
byteValue, shortValue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final long serialVersionUID
public static final int TYPE_LENGTH
public static final int TYPE_PERCENTAGE
public static final int UNIT_CM
public static final int UNIT_MM
public static final int UNIT_IN
public static final int UNIT_PT
public static final int UNIT_PC
public static final int UNIT_PX
public static final int UNIT_EM
public static final int UNIT_EX
private static final java.lang.String[] UNIT
private static final double[] CONVERSION
private int type
private double value
private int unit
Constructor Detail |
public LengthUnit(double value)
value
- length in pixelspublic LengthUnit(double value, int unit)
value
- lengthunit
- unit (UNIT_xx constant)private LengthUnit(int type, double value, int unit)
type
- type discriminator (TYPE_xxxx constant)value
- length or percentageunit
- the unit in witch the length is given (UNIT_xx constant)private LengthUnit(LengthUnit other)
other
- the object to copy fromMethod Detail |
public static LengthUnit parse(java.lang.String str) throws java.lang.IllegalArgumentException
str
- String to parse
java.lang.IllegalArgumentException
- When the string is no valid length stringprivate static boolean isDigit(char ch)
ch
- character to check
private java.lang.String valueStr(int decimals)
decimals
- number of fraction digits
private boolean convertable(int unit)
public LengthUnit convert(int targetUnit)
targetUnit
- the unit to convert to
public double doubleValue()
Number.doubleValue()
public float floatValue()
Number.floatValue()
public int intValue()
Number.intValue()
public long longValue()
Number.longValue()
public LengthUnit plus(double summand)
summand
- the value to add
public LengthUnit plus(LengthUnit summand)
summand
- the value to add. The value will be converted to the matching unit
public LengthUnit minus(double summand)
summand
- the value to add
public LengthUnit minus(LengthUnit summand)
summand
- the value to add. The value will be converted to the matching unit
public int getType()
public int getUnit()
public boolean isAbsoluteValue()
true
when this is an absolute valuepublic boolean isRelativeValue()
true
when this is a relative valuepublic java.lang.String toString(int decimals)
decimals
- internal decimal places
public java.lang.String toString()
Object.toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |