Package com.adobe.xfa.text
Class TextBaselineShift
java.lang.Object
com.adobe.xfa.text.TextBaselineShift
This class defines a text baseline shift attribute.
It's loosely modelled after the proposed XSL baseline shift attribute
See baseline-shift
The differences in implementation from the XSL variation include:
1. We support only baseline, <percentage> and <length> values
2. The adjusted baseline will be calculated relative to the preceding text, rather than the parent.
3. There is no accompanying "shift-direction" attribute, so negative percentages and lengths will shift up, and positive values will shift down.
1. We support only baseline, <percentage> and <length> values
2. The adjusted baseline will be calculated relative to the preceding text, rather than the parent.
3. There is no accompanying "shift-direction" attribute, so negative percentages and lengths will shift up, and positive values will shift down.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final TextBaselineShiftstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.TextBaselineShift(double dPercentage) Create a baseline shift with a percentage offsetTextBaselineShift(int eType, int nLevel) Create a baseline shift by type, with optional level.TextBaselineShift(TextBaselineShift oSource) Copy constructorTextBaselineShift(UnitSpan oLength) Create a baseline shift with a fixed offsetTextBaselineShift(String sString, boolean bSuppressInversion) Create a baseline shift from a string -
Method Summary
Modifier and TypeMethodDescriptionapplyShift(UnitSpan oStartingBaseline, UnitSpan oLineHeight) Apply this baseline shift to a baseline valuecopyFrom(TextBaselineShift oSource) Assignment operatorbooleanEquality operatorUnitSpan[]Apply this baseline shift to a baseline value and return font sizeReturn the absolute shift.intgetLevel()Return the subscript or superscript level.doubleReturn the percentage shift.getString(boolean bSuppressInversion) Represent the value of this shift as a stringintgetType()Return the type of shift.inthashCode()booleanFind out whether this shift adjusts in the positive (down/subscript) direction or not.booleanFind out whether this shift has no effect.booleannotEqual(TextBaselineShift oCompare) Inequality operator
-
Field Details
-
BASELINE
public static final int BASELINE- See Also:
-
PERCENTAGE
public static final int PERCENTAGE- See Also:
-
LENGTH
public static final int LENGTH- See Also:
-
SUBSCRIPT
public static final int SUBSCRIPT- See Also:
-
SUPERSCRIPT
public static final int SUPERSCRIPT- See Also:
-
DEFAULT_SHIFT
-
-
Constructor Details
-
TextBaselineShift
public TextBaselineShift()Default constructor. Creates a baseline shift with a value "baseline" - No baseline shift. -
TextBaselineShift
Copy constructor- Parameters:
oSource- the TextBaselineShift object to copy
-
TextBaselineShift
public TextBaselineShift(double dPercentage) Create a baseline shift with a percentage offset- Parameters:
dPercentage- the amount to shift by. Negative percentages shift up, positive values shift down. The percentage is relative to the current line height.
-
TextBaselineShift
Create a baseline shift with a fixed offset- Parameters:
oLength- the absolute value to shift by. Negative values shift up, positive values shift down.
-
TextBaselineShift
public TextBaselineShift(int eType, int nLevel) Create a baseline shift by type, with optional level.This constructor is intended primarily to create subscript and superscript baseline shifts. It can take any type code, but if that code is not for a subscript or superscript, the shift is effectively neutral.
- Parameters:
eType- - Type code for the new shift object.nLevel- - Subscript or superscript level. Ignored if the type code is for something other than subscript or superscript. Defaults to one.
-
TextBaselineShift
Create a baseline shift from a string- Parameters:
sString- a textual representation of the baseline value. Should be something like "baseline" or "15%" or "2pt".
-
-
Method Details
-
flatten
Apply this baseline shift to a baseline value and return font size- Parameters:
oStartingBaseline- the current baseline positionoLineHeight- The height of the current line- Returns:
- A two UnitSpan array with the adjusted baseline value and the new font size.
-
applyShift
Apply this baseline shift to a baseline value- Parameters:
oStartingBaseline- the current baseline positionoLineHeight- The height of the current line- Returns:
- the adjusted baseline value.
-
getString
Represent the value of this shift as a string- Returns:
- a string that represents this shift. A value such as: "baseline" or "25%" or "0.15in"
-
getType
public int getType()Return the type of shift.- Returns:
- A value from the TypeCode enumeration to indicate whether this is an absolute, percentage or neutral shift.
-
getLength
Return the absolute shift.- Returns:
- absolute shift amount. Value is meaningful only if this is an absolute (length) type shift.
-
getPercentage
public double getPercentage()Return the percentage shift.- Returns:
- Percentage shift amount. Value is meaningful only if this is a percentage type shift.
-
getLevel
public int getLevel()Return the subscript or superscript level.- Returns:
- Subscript or superscript level. Value is meaningful only if this is a subscript or superscript type shift.
-
isNeutral
public boolean isNeutral()Find out whether this shift has no effect.- Returns:
- Boolean indicating TRUE if the shift is neutral.
-
isDownShift
public boolean isDownShift()Find out whether this shift adjusts in the positive (down/subscript) direction or not.- Returns:
- Boolean indicating TRUE if the shift is downward.
-
copyFrom
Assignment operator- Parameters:
oSource- the object to copy- Returns:
- this object
-
equals
Equality operator -
hashCode
public int hashCode() -
notEqual
Inequality operator- Parameters:
oCompare- the object to compare- Returns:
- one if not equal
-