Package org.apache.fop.fo.properties
Class FixedLength
- java.lang.Object
-
- org.apache.fop.fo.properties.Property
-
- org.apache.fop.fo.properties.LengthProperty
-
- org.apache.fop.fo.properties.FixedLength
-
public final class FixedLength extends LengthProperty
An absolute length quantity in XSL
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.fop.fo.properties.LengthProperty
LengthProperty.Maker
-
-
Field Summary
Fields Modifier and Type Field Description private static PropertyCache<FixedLength>
CACHE
cache holding all canonical FixedLength instancesstatic java.lang.String
CM
Describes the unit centimeter.static java.lang.String
INCH
Describes the unit inch.private int
millipoints
static java.lang.String
MM
Describes the unit millimeter.static java.lang.String
MPT
Describes the unit millipoint.static java.lang.String
PICA
Describes the unit pica.static java.lang.String
POINT
Describes the unit point.static FixedLength
ZERO_FIXED_LENGTH
canonical zero-length instance
-
Constructor Summary
Constructors Modifier Constructor Description private
FixedLength(double numUnits, java.lang.String units, float res)
Set the length given a number of units, a unit name and an assumed resolution (used in case the units are pixels)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static int
convert(double dvalue, java.lang.String unit, float res)
Convert the given length to a dimensionless integer representing a whole number of base units (milli-points).boolean
equals(java.lang.Object obj)
static FixedLength
getInstance(double numUnits)
Return the cachedFixedLength
instance corresponding to the computed value.static FixedLength
getInstance(double numUnits, java.lang.String units)
Return the cachedFixedLength
instance corresponding to the computed value This method assumes a source-resolution of 1 (1px = 1pt)static FixedLength
getInstance(double numUnits, java.lang.String units, float sourceResolution)
Return the cachedFixedLength
instance corresponding to the computed value in base-units (millipoints).double
getNumericValue()
Return the value of this Numericdouble
getNumericValue(PercentBaseContext context)
Return the value of this Numericint
getValue()
Returns the length in 1/1000ths of a point (millipoints)int
getValue(PercentBaseContext context)
Returns the length in 1/1000ths of a point (millipoints)int
hashCode()
boolean
isAbsolute()
Return true since a FixedLength is always absolute.java.lang.String
toString()
-
Methods inherited from class org.apache.fop.fo.properties.LengthProperty
getDimension, getLength, getNumeric, getObject
-
Methods inherited from class org.apache.fop.fo.properties.Property
getCharacter, getColor, getCondLength, getEnum, getKeep, getLengthPair, getLengthRange, getList, getNCname, getNumber, getSpace, getSpecifiedValue, getString, isAuto, setSpecifiedValue
-
-
-
-
Field Detail
-
PICA
public static final java.lang.String PICA
Describes the unit pica.- See Also:
- Constant Field Values
-
POINT
public static final java.lang.String POINT
Describes the unit point.- See Also:
- Constant Field Values
-
MM
public static final java.lang.String MM
Describes the unit millimeter.- See Also:
- Constant Field Values
-
CM
public static final java.lang.String CM
Describes the unit centimeter.- See Also:
- Constant Field Values
-
INCH
public static final java.lang.String INCH
Describes the unit inch.- See Also:
- Constant Field Values
-
MPT
public static final java.lang.String MPT
Describes the unit millipoint.- See Also:
- Constant Field Values
-
CACHE
private static final PropertyCache<FixedLength> CACHE
cache holding all canonical FixedLength instances
-
ZERO_FIXED_LENGTH
public static final FixedLength ZERO_FIXED_LENGTH
canonical zero-length instance
-
millipoints
private int millipoints
-
-
Constructor Detail
-
FixedLength
private FixedLength(double numUnits, java.lang.String units, float res)
Set the length given a number of units, a unit name and an assumed resolution (used in case the units are pixels)- Parameters:
numUnits
- quantity of input unitsunits
- input unit specifierres
- input/source resolution
-
-
Method Detail
-
getInstance
public static FixedLength getInstance(double numUnits, java.lang.String units, float sourceResolution)
Return the cachedFixedLength
instance corresponding to the computed value in base-units (millipoints).- Parameters:
numUnits
- quantity of input unitsunits
- input unit specifiersourceResolution
- input/source resolution (= ratio of pixels per pt)- Returns:
- the canonical FixedLength instance corresponding to the given number of units and unit specifier in the given resolution
-
getInstance
public static FixedLength getInstance(double numUnits, java.lang.String units)
Return the cachedFixedLength
instance corresponding to the computed value This method assumes a source-resolution of 1 (1px = 1pt)- Parameters:
numUnits
- input unitsunits
- unit specifier- Returns:
- the canonical FixedLength instance corresponding to the given number of units and unit specifier
-
getInstance
public static FixedLength getInstance(double numUnits)
Return the cachedFixedLength
instance corresponding to the computed value. This method assumes 'millipoints' (non-standard) as units, and an implied source-resolution of 1 (1px = 1pt).- Parameters:
numUnits
- input units- Returns:
- the canonical FixedLength instance corresponding to the given number of units and unit specifier
-
convert
private static int convert(double dvalue, java.lang.String unit, float res)
Convert the given length to a dimensionless integer representing a whole number of base units (milli-points).- Parameters:
dvalue
- quantity of input unitsunit
- input unit specifier (in, cm, etc.)res
- the input/source resolution (in case the unit spec is "px")
-
getValue
public int getValue()
Returns the length in 1/1000ths of a point (millipoints)- Returns:
- the length in millipoints
-
getValue
public int getValue(PercentBaseContext context)
Returns the length in 1/1000ths of a point (millipoints)- Parameters:
context
- The context for the length calculation (for percentage based lengths)- Returns:
- the length in millipoints
-
getNumericValue
public double getNumericValue()
Return the value of this Numeric- Returns:
- the computed value.
-
getNumericValue
public double getNumericValue(PercentBaseContext context)
Return the value of this Numeric- Parameters:
context
- The context for the length calculation (for percentage based lengths)- Returns:
- the computed value.
-
isAbsolute
public boolean isAbsolute()
Return true since a FixedLength is always absolute. Return true if the numeric is an absolute value. Relative values are percentages and table-column-units. All other numerics are absolute.- Returns:
- true when the numeric is absolute.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-