|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.birt.report.model.api.util.DimensionUtil
public class DimensionUtil
Utility class to do conversions between units.
Constructor Summary | |
---|---|
DimensionUtil()
|
Method Summary | |
---|---|
static DimensionValue |
convertTo(DimensionValue dimension,
java.lang.String appUnit,
java.lang.String targetUnits)
Convert a DimensionValue from one units to another, The
conversion is between absolute the units should be one of the absolute
units(CM, IN, MM, PT, PC). |
static DimensionValue |
convertTo(double measure,
java.lang.String fromUnits,
java.lang.String targetUnits)
Convert a measure from one units to another. |
static double |
convertTo(java.lang.Object value,
java.lang.String appUnits,
java.lang.String targetUnits,
double baseSize,
int dpi)
Convert a measure from one units to another. |
static double |
convertTo(java.lang.Object value,
java.lang.String appUnits,
java.lang.String targetUnits,
double baseSize,
java.lang.String baseSizeUnits,
int dpi)
Convert a measure from one units to another. |
static DimensionValue |
convertTo(java.lang.String dimension,
java.lang.String appUnit,
java.lang.String targetUnits)
Convert a dimension from one units to another, the dimension like "12pt, 12cm" is composed of two parts: "measure" and "units". |
static boolean |
isAbsoluteFontSize(java.lang.String value)
Returns whether the dimension string value is absolute font size constant. |
static boolean |
isAbsoluteUnit(java.lang.String unit)
Return if the given unit is an absolute unit or not. |
static boolean |
isRelativeFontSize(java.lang.String value)
Returns whether the dimension string value is relative font size constant. |
static boolean |
isRelativeUnit(java.lang.String unit)
Return if the given unit is a relative unit or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DimensionUtil()
Method Detail |
---|
public static DimensionValue convertTo(double measure, java.lang.String fromUnits, java.lang.String targetUnits)
measure
- the numeric measure of the dimension.fromUnits
- unit of the measure, it must be one of the absolute unit.targetUnits
- the desired units, it must be one of the absolute unit.
DimensionValue
in the target unit.public static DimensionValue convertTo(DimensionValue dimension, java.lang.String appUnit, java.lang.String targetUnits)
DimensionValue
from one units to another, The
conversion is between absolute the units should be one of the absolute
units(CM, IN, MM, PT, PC).
dimension
- the numeric measure of the dimension.appUnit
- the application unit of the dimension, if the dimension has
not specified a unit, the the application unit will be applied
to it. It must be one of the absolute unit.targetUnits
- the desired unit.
DimensionValue
in the target unit.public static DimensionValue convertTo(java.lang.String dimension, java.lang.String appUnit, java.lang.String targetUnits) throws PropertyValueException
dimension
- a string representing a absolute dimension value like "12pt,
12pc...".appUnit
- the application unit of the dimension, if the dimension has
not specified a unit, the the application unit will be applied
to it. It must be one of the absolute unit.targetUnits
- the desired unit.
DimensionValue
in the target unit.
PropertyValueException
- if the dimension is not valid.public static final boolean isAbsoluteUnit(java.lang.String unit)
DesignChoiceConstants
are considered as
absolute:
unit
- a given unit.
true
if the unit is an absolute unit like cm, in,
mm, pt and pc. Return false
if the unit is not an
absolute unit.( it can be an relative unit like "%", or even an
unrecognized unit. )public static final boolean isRelativeUnit(java.lang.String unit)
DesignChoiceConstants
are considered as
relative:
unit
- a given unit.
true
if the unit is a relative unit like em, ex, %
and px. Return false
if the unit is not a relative
unit.( it can be an absolute relative unit like "mm", or even an
unrecognized unit. )public static boolean isAbsoluteFontSize(java.lang.String value)
DesignChoiceConstants
as followed.
FONT_SIZE_XX_SMALL
FONT_SIZE_X_SMALL
FONT_SIZE_SMALL
FONT_SIZE_MEDIUM
FONT_SIZE_LARGE
FONT_SIZE_X_LARGE
FONT_SIZE_XX_LARGE
value
- dimension string value
public static boolean isRelativeFontSize(java.lang.String value)
DesignChoiceConstants
as followed.
FONT_SIZE_SMALLER
FONT_SIZE_LARGER
value
- dimension string value
public static double convertTo(java.lang.Object value, java.lang.String appUnits, java.lang.String targetUnits, double baseSize, int dpi)
String
. It must be a legal dimension value, such as
'10 em', '+3.5pt', '10%'.
DimensionValue
DimensionHandle
value
- the input dimension value to be convertedappUnits
- the application units, used as default to convert from when
units part of the input value is empty or nulltargetUnits
- the desired units, it must be one of the absolute unit.baseSize
- the base size to convert value with relative units, such as
em, ex and %, this value must be computed in units of
DesignChoiceConstants.UNITS_PT
.dpi
- int value that represents the pixel per inch
public static double convertTo(java.lang.Object value, java.lang.String appUnits, java.lang.String targetUnits, double baseSize, java.lang.String baseSizeUnits, int dpi)
String
. It must be a legal dimension value, measure
part and units part such as '10 em', '+3.5pt', '10%' or only measure
part, such as 10.12, 45, +4.
DimensionValue
DimensionHandle
value
- the input dimension value to be convertedappUnits
- the application units, used as the original units to convert
from when units part of the input value is empty or null.It
must be one of the absolute unit(CM, IN, MM, PT, PC).targetUnits
- the desired units, it must be one of the absolute unit(CM, IN,
MM, PT, PC).baseSize
- the base size to convert value with relative units, such as
em, ex and %baseSizeUnits
- the units for the base size. It must be one of the absolute
units(CM, IN, MM, PT, PC). By default it is
DesignChoiceConstants.UNITS_PT
dpi
- int value that represents the pixel per inch
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |