public class MTextDocument extends Object implements Externalizable
Modifier and Type | Class and Description |
---|---|
class |
MTextDocument.Portion
Selected text.
|
static class |
MTextDocument.Section
Plain text section with uniform attributes.
|
Constructor and Description |
---|
MTextDocument()
Constructs an empty document.
|
MTextDocument(MTextDocument d)
Copy constructor.
|
MTextDocument(String s)
Constructs a document from the specified string.
|
Modifier and Type | Method and Description |
---|---|
void |
append(String s,
MTextAttributes attr)
Append text to end of document.
|
char |
charAt(int i)
Gets a character of the document.
|
boolean |
endsWith(char c)
Tests whether the document ends with the specified character.
|
int |
findScriptLastSectionIndex(int from,
int subl)
Finds the end of a subscript or superscript.
|
MFont |
getAttrFont(MTextAttributes attr)
Gets the font for the specified attribute object.
|
MTextAttributes |
getAttributes(int start,
int len,
int set0)
Gets the common attributes of the selected text.
|
MFont |
getDefaultFont()
Gets the default font.
|
String |
getPlainText()
Gets the document as plain text.
|
MTextDocument.Portion |
getPortion(int start,
int end)
Gets a portion of the document.
|
int |
getScriptCount(int i1,
int subl)
Gets the number of subscripts or superscripts on the last normal
character.
|
MTextDocument.Section |
getSection(int k)
Gets a section of the document.
|
int |
getSectionCount()
Gets the number of sections in the document.
|
int |
getSectionIndexOfCharAt(int i)
Gets the section index of a character.
|
double |
getSectionShiftY(int k)
Gets the y shift of a section.
|
void |
insert(int i,
String s,
MTextAttributes attr)
Inserts a string.
|
boolean |
isFontDefaultInRange(int start,
int len)
Tests whether the default font is used in the specified range.
|
boolean |
isFontRegularInRange(int start,
int len)
Tests whether the default font is used in the specified range.
|
int |
length()
Gets the length of the document.
|
void |
readExternal(ObjectInput in)
Restores the document.
|
void |
readFromString(String str)
Reads the document from a string.
|
void |
remove(int start,
int len)
Deletes a substring in the document.
|
void |
replace(int start,
int len,
String s)
Replaces a substring in the document.
|
MFont |
reuseFont(String name,
int style,
double size) |
void |
setAttributes(int start,
int len,
MTextAttributes attr)
Sets attributes of selected text.
|
void |
setDefaultFont(MFont f)
Sets the default font.
|
void |
setPlainText(String s)
Sets the document as plain text.
|
String |
substring(int start)
Gets a substring of the document.
|
String |
substring(int start,
int end)
Gets a substring of the document.
|
String |
toString()
Gets the string representation of the document.
|
void |
updateSubLevel(double[] sublevX,
double x,
int k) |
void |
writeExternal(ObjectOutput out)
Saves the document.
|
public MTextDocument()
public MTextDocument(String s)
s
- the stringpublic MTextDocument(MTextDocument d)
d
- the document to copypublic final String getPlainText()
public void setPlainText(String s)
s
- the textpublic final int length()
public final char charAt(int i)
public boolean endsWith(char c)
c
- the characterpublic final String substring(int start)
start
- index of first characterpublic final String substring(int start, int end)
start
- index of first characterend
- index of last character + 1public final void remove(int start, int len)
start
- index of first character to deletelen
- number of characters to deletepublic final void append(String s, MTextAttributes attr)
s
- text to addattr
- section attributes or nullpublic final void insert(int i, String s, MTextAttributes attr)
i
- character indexs
- string to insertattr
- text attributes or nullpublic final void replace(int start, int len, String s)
start
- index of first character to deletelen
- number of characters to replaces
- substitutionpublic final MTextAttributes getAttributes(int start, int len, int set0)
start
- position of first characterlen
- number of charactersset0
- the set of attributes that are supposed to be set
even if their values are "default"public final boolean isFontDefaultInRange(int start, int len)
public final boolean isFontRegularInRange(int start, int len)
public final void setAttributes(int start, int len, MTextAttributes attr)
start
- position of first characterlen
- number of charactersattr
- the attributesMTextAttributes.A_SUBLEVEL
,
MTextAttributes.A_FOREGROUND
,
MTextAttributes.A_FONT
,
MTextAttributes.A_FONTFAMILY
,
MTextAttributes.A_FONTSIZE
,
MTextAttributes.A_BOLD
,
MTextAttributes.A_ITALIC
,
MTextAttributes.A_SCALE
,
MTextAttributes.A_DX
,
MTextAttributes.A_DY
public final MTextDocument.Portion getPortion(int start, int end)
start
- position of first characterend
- position of last character + 1public MFont getDefaultFont()
public void setDefaultFont(MFont f)
f
- the fontpublic final int getSectionCount()
public final int getSectionIndexOfCharAt(int i)
i
- character positionpublic final MTextDocument.Section getSection(int k)
k
- section numberpublic final double getSectionShiftY(int k)
k
- the section numberpublic final int findScriptLastSectionIndex(int from, int subl)
from
- the first section indexsubl
- the script level to query,
+1 (superscript) or -1 (subscript)public final int getScriptCount(int i1, int subl)
i1
- the positionsubl
- the script level to query,
+1 (superscript) or -1 (subscript)public MFont getAttrFont(MTextAttributes attr)
public String toString()
public void readFromString(String str) throws IllegalArgumentException
str
- the stringIllegalArgumentException
public void updateSubLevel(double[] sublevX, double x, int k)
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
in
- the stream to read data from in order to restore the objectIOException
- if I/O errors occurClassNotFoundException
- If the class for an object being
restored cannot be found.public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
out
- the stream to write the object toIOException
- Includes any I/O exceptions that may occur