Package com.adobe.xfa.text
Class TextBaselineShift
- java.lang.Object
-
- com.adobe.xfa.text.TextBaselineShift
-
public class TextBaselineShift extends java.lang.Object
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.
-
-
Field Summary
Fields Modifier and Type Field Description static int
BASELINE
static TextBaselineShift
DEFAULT_SHIFT
static int
LENGTH
static int
PERCENTAGE
static int
SUBSCRIPT
static int
SUPERSCRIPT
-
Constructor Summary
Constructors Constructor Description TextBaselineShift()
Default 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(java.lang.String sString, boolean bSuppressInversion)
Create a baseline shift from a string
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UnitSpan
applyShift(UnitSpan oStartingBaseline, UnitSpan oLineHeight)
Apply this baseline shift to a baseline valueTextBaselineShift
copyFrom(TextBaselineShift oSource)
Assignment operatorboolean
equals(java.lang.Object object)
Equality operatorUnitSpan[]
flatten(UnitSpan oStartingBaseline, UnitSpan oLineHeight, UnitSpan poFontSize)
Apply this baseline shift to a baseline value and return font sizeUnitSpan
getLength()
Return the absolute shift.int
getLevel()
Return the subscript or superscript level.double
getPercentage()
Return the percentage shift.java.lang.String
getString(boolean bSuppressInversion)
Represent the value of this shift as a stringint
getType()
Return the type of shift.int
hashCode()
boolean
isDownShift()
Find out whether this shift adjusts in the positive (down/subscript) direction or not.boolean
isNeutral()
Find out whether this shift has no effect.boolean
notEqual(TextBaselineShift oCompare)
Inequality operator
-
-
-
Field Detail
-
BASELINE
public static final int BASELINE
- See Also:
- Constant Field Values
-
PERCENTAGE
public static final int PERCENTAGE
- See Also:
- Constant Field Values
-
LENGTH
public static final int LENGTH
- See Also:
- Constant Field Values
-
SUBSCRIPT
public static final int SUBSCRIPT
- See Also:
- Constant Field Values
-
SUPERSCRIPT
public static final int SUPERSCRIPT
- See Also:
- Constant Field Values
-
DEFAULT_SHIFT
public static final TextBaselineShift DEFAULT_SHIFT
-
-
Constructor Detail
-
TextBaselineShift
public TextBaselineShift()
Default constructor. Creates a baseline shift with a value "baseline" - No baseline shift.
-
TextBaselineShift
public TextBaselineShift(TextBaselineShift oSource)
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
public TextBaselineShift(UnitSpan oLength)
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
public TextBaselineShift(java.lang.String sString, boolean bSuppressInversion)
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 Detail
-
flatten
public UnitSpan[] flatten(UnitSpan oStartingBaseline, UnitSpan oLineHeight, UnitSpan poFontSize)
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
public UnitSpan applyShift(UnitSpan oStartingBaseline, UnitSpan oLineHeight)
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
public java.lang.String getString(boolean bSuppressInversion)
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
public UnitSpan 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
public TextBaselineShift copyFrom(TextBaselineShift oSource)
Assignment operator- Parameters:
oSource
- the object to copy- Returns:
- this object
-
equals
public boolean equals(java.lang.Object object)
Equality operator- Overrides:
equals
in classjava.lang.Object
- Parameters:
object
- the object to compare- Returns:
- one if equal
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
notEqual
public boolean notEqual(TextBaselineShift oCompare)
Inequality operator- Parameters:
oCompare
- the object to compare- Returns:
- one if not equal
-
-