Package chemaxon.struc.graphics
Class MTextDocument.Portion
java.lang.Object
chemaxon.struc.graphics.MTextDocument.Portion
- Enclosing class:
- MTextDocument
Selected text.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
endsWith
(char c) Tests whether this text portion ends with the specified character.final double
getAscent
(Graphics g, FontMetrics fm0) Gets the ascent of this portion.final double
getDescent
(Graphics g, FontMetrics fm0) Gets the descent of this portion.final double
getEndDx()
Gets the x shift at the end.final int
Gets the position of the last character + 1.final String
Gets the selected text as a plain text string.final MTextDocument.Portion
getPortion
(int start, int end) Gets a portion of the text relative to this portion.final int
Gets the position of the first character.final int
length()
Gets the number of characters.final double
portionWidth
(Graphics g, MFont dmfont, FontMetrics fm0) Gets the width of this portion.final double
portionXAdvance
(Graphics g, MFont dmf, FontMetrics fm0) Gets the x coordinate change from the beginning to the end of this portion.final double
portionXAdvance
(Graphics g, MFont dmfont, FontMetrics fm0, boolean lastxadv) Gets the width of this portion.final String
toString()
Gets the string representation of the portion.
-
Method Details
-
getStartPos
public final int getStartPos()Gets the position of the first character.- Returns:
- the start index
-
getEndPos
public final int getEndPos()Gets the position of the last character + 1.- Returns:
- the end index
-
length
public final int length()Gets the number of characters.- Returns:
- the length
-
portionWidth
Gets the width of this portion.- Parameters:
g
- the graphics context or nullfm0
- default font metrics- Returns:
- the width
-
portionXAdvance
Gets the x coordinate change from the beginning to the end of this portion.- Parameters:
g
- the graphics context or nullfm0
- default font metrics- Returns:
- the width
-
portionXAdvance
Gets the width of this portion.- Parameters:
g
- the graphics context or nullfm0
- default font metricslastxadv
- whether to calculate the x advance for the next section beginning at the last character- Returns:
- the width
-
getEndDx
public final double getEndDx()Gets the x shift at the end. It can be nonzero only if a new section starts at the end of this portion. This method should only be called after portionWidth.- Returns:
- the x shift
-
getAscent
Gets the ascent of this portion.- Parameters:
g
- the graphics context or nullfm0
- default font metrics- Returns:
- the ascent
-
getDescent
Gets the descent of this portion.- Parameters:
g
- the graphics context or nullfm0
- default font metrics- Returns:
- the descent
-
getPortion
Gets a portion of the text relative to this portion.- Parameters:
start
- relative start positionend
- relative end position- Returns:
- the portion
-
getPlainText
Gets the selected text as a plain text string.- Returns:
- the text
-
toString
Gets the string representation of the portion. -
endsWith
public boolean endsWith(char c) Tests whether this text portion ends with the specified character.- Parameters:
c
- the character- Returns:
- true if c is the last character, false otherwise
-