public class TextMeasurement extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PRECISION |
static int |
TYPE_EM
Proportional to the font em width (normally the font height).
|
static int |
TYPE_LENGTH
An absolute measurement on the document.
|
static int |
TYPE_PERCENT
Proportional to the width of the space character, but expressed as a
percentage in markup.
|
static TextMeasurement |
ZERO |
| Constructor and Description |
|---|
TextMeasurement()
Default constructor.
|
TextMeasurement(int eType,
double dScale)
Create a relative measurement.
|
TextMeasurement(UnitSpan oLength)
Create a length type measurement, given a length value.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object object)
Equality comparison.
|
UnitSpan |
flatten(FontInstance oFontInstance)
Determine the absolute value of this measurement.
|
UnitSpan |
flatten(UnitSpan oBaseValue)
Determine the absolute value of this measurement in the absence of
font information.
|
static TextMeasurement |
fromString(String sValue) |
static TextMeasurement |
fromString(String sValue,
int eDefaultUnits) |
static TextMeasurement |
fromString(String sValue,
int eDefaultUnits,
boolean bValuePerUnit)
Populate this measurement from the content of a given string.
|
UnitSpan |
getLength()
Return the length value for this measurement object.
|
int |
getLengthValue()
Return the integer value of the length.
|
double |
getScale()
Get the scale value for relative measurements.
|
int |
getType()
Return the type of this measurement object.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isZero()
Determine whether this measurement represents a zero value.
|
static boolean |
match(TextMeasurement m1,
TextMeasurement m2) |
String |
toString() |
String |
toString(int nPrecision)
Generate a string from the current value of this measurement object.
|
static TextMeasurement |
zero() |
public static final int TYPE_LENGTH
public static final int TYPE_EM
public static final int TYPE_PERCENT
public static final int DEFAULT_PRECISION
public static final TextMeasurement ZERO
public TextMeasurement()
public TextMeasurement(UnitSpan oLength)
oLength - - Initial length value to be stored in this
measurement.public TextMeasurement(int eType,
double dScale)
eType - - Type of the measurement. Must be either TYPE_EM or
TYPE_PERCENT.dScale - - Scale factor for the measurement. Note that for
percentage measurement the given value is not scaled by 100 (e.g,
pass 1.0 to get 100%).public UnitSpan flatten(FontInstance oFontInstance)
Used at run-time, this method returns an absolute length corresponding to the measurement, irrespective of the measurement type. If the measurement is of type length, it already represents an absolute amount. Otherwise, the given font is used to scale the relative value appropriately.
oFontInstance - - Font instance to use to scale relative
amounts. If this is a null reference, zero is returned. If the
measurement type is percent and the font has no space character, the
measurement is treated as being of type em.public UnitSpan flatten(UnitSpan oBaseValue)
This is a sort of poor person's Flatten() method. If the font information is not available, one call call this overload, typically with the font height. If the measurement type is relative, it applies the scale to the given unit span. Otherwise it simply returns the (absolute) length.
oBaseValue - - Base unit span to apply relative scales to.public int getType()
public UnitSpan getLength()
public int getLengthValue()
public double getScale()
public boolean isZero()
public static TextMeasurement fromString(String sValue, int eDefaultUnits, boolean bValuePerUnit)
sValue - - String value to use. This is essentially an
extension of the allowable syntax for creating unit spans.public static TextMeasurement fromString(String sValue, int eDefaultUnits)
public static TextMeasurement fromString(String sValue)
public String toString(int nPrecision)
nPrecision - - (optional) Maximum number of decimal places in
the result. Default is six.public static boolean match(TextMeasurement m1, TextMeasurement m2)
public boolean equals(Object object)
Two measurements are considered equal if they have the same type and the appropriate values match (length for length types, scale for relative types).
public int hashCode()
public static TextMeasurement zero()
Copyright © 2010 - 2020 Adobe. All Rights Reserved