org.eclipse.birt.report.model.api.util
Class DimensionUtil

java.lang.Object
  extended byorg.eclipse.birt.report.model.api.util.DimensionUtil

public class DimensionUtil
extends java.lang.Object

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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DimensionUtil

public DimensionUtil()
Method Detail

convertTo

public static DimensionValue convertTo(double measure,
                                       java.lang.String fromUnits,
                                       java.lang.String targetUnits)
Convert a measure from one units to another. The conversion is between absolute the units should be one of the absolute units(CM, IN, MM, PT).

Parameters:
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.
Returns:
DimensionValue in the target unit.

convertTo

public 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).

Parameters:
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.
Returns:
DimensionValue in the target unit.

convertTo

public static DimensionValue convertTo(java.lang.String dimension,
                                       java.lang.String appUnit,
                                       java.lang.String targetUnits)
                                throws PropertyValueException
Convert a dimension from one units to another, the dimension like "12pt, 12cm" is composed of two parts: "measure" and "units". The conversion is between absolute the units should be one of the absolute units(CM, IN, MM, PT, PC).

Parameters:
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.
Returns:
DimensionValue in the target unit.
Throws:
PropertyValueException - if the dimension is not valid.

isAbsoluteUnit

public static final boolean isAbsoluteUnit(java.lang.String unit)
Return if the given unit is an absolute unit or not. The following units defined in DesignChoiceConstants are considered as absolute:

Parameters:
unit - a given unit.
Returns:
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. )

isAbsoluteFontSize

public static boolean isAbsoluteFontSize(java.lang.String value)
Returns whether the dimension string value is absolute font size constant. The absolute font size constants are defined in DesignChoiceConstants as followed.

Parameters:
value - dimension string value
Returns:
true if the given value is absolute font size constant.

isRelativeFontSize

public static boolean isRelativeFontSize(java.lang.String value)
Returns whether the dimension string value is relative font size constant. The relative font size constants are defined in DesignChoiceConstants as followed.

Parameters:
value - dimension string value
Returns:
true if the given value is relative font size constant.


Copyright © 2005 Actuate Corp. All rights reserved.