chemaxon.struc.graphics
Class MTextDocument.Portion

java.lang.Object
  extended by chemaxon.struc.graphics.MTextDocument.Portion
Enclosing class:
MTextDocument

public class MTextDocument.Portion
extends Object

Selected text.


Method Summary
 boolean endsWith(char c)
          Tests whether this text portion ends with the specified character.
 double getAscent(Graphics g, FontMetrics fm0)
          Gets the ascent of this portion.
 double getDescent(Graphics g, FontMetrics fm0)
          Gets the descent of this portion.
 double getEndDx()
          Gets the x shift at the end.
 int getEndPos()
          Gets the position of the last character + 1.
 String getPlainText()
          Gets the selected text as a plain text string.
 MTextDocument.Portion getPortion(int start, int end)
          Gets a portion of the text relative to this portion.
 int getStartPos()
          Gets the position of the first character.
 int length()
          Gets the number of characters.
 double portionWidth(Graphics g, MFont dmfont, FontMetrics fm0)
          Gets the width of this portion.
 double portionXAdvance(Graphics g, MFont dmf, FontMetrics fm0)
          Gets the x coordinate change from the beginning to the end of this portion.
 double portionXAdvance(Graphics g, MFont dmfont, FontMetrics fm0, boolean lastxadv)
          Gets the width of this portion.
 String toString()
          Gets the string representation of the portion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

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

public final double portionWidth(Graphics g,
                                 MFont dmfont,
                                 FontMetrics fm0)
Gets the width of this portion.

Parameters:
g - the graphics context or null
fm0 - default font metrics
Returns:
the width

portionXAdvance

public final double portionXAdvance(Graphics g,
                                    MFont dmf,
                                    FontMetrics fm0)
Gets the x coordinate change from the beginning to the end of this portion.

Parameters:
g - the graphics context or null
fm0 - default font metrics
Returns:
the width

portionXAdvance

public final double portionXAdvance(Graphics g,
                                    MFont dmfont,
                                    FontMetrics fm0,
                                    boolean lastxadv)
Gets the width of this portion.

Parameters:
g - the graphics context or null
fm0 - default font metrics
lastxadv - 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

public final double getAscent(Graphics g,
                              FontMetrics fm0)
Gets the ascent of this portion.

Parameters:
g - the graphics context or null
fm0 - default font metrics
Returns:
the ascent

getDescent

public final double getDescent(Graphics g,
                               FontMetrics fm0)
Gets the descent of this portion.

Parameters:
g - the graphics context or null
fm0 - default font metrics
Returns:
the descent

getPortion

public final MTextDocument.Portion getPortion(int start,
                                              int end)
Gets a portion of the text relative to this portion.

Parameters:
start - relative start position
end - relative end position
Returns:
the portion

getPlainText

public final String getPlainText()
Gets the selected text as a plain text string.

Returns:
the text

toString

public final String toString()
Gets the string representation of the portion.

Overrides:
toString in class Object
Returns:
the string

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