|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchemaxon.struc.graphics.MTextDocument
public class MTextDocument
Text document consisting of sections with different attributes.
Nested Class Summary | |
---|---|
class |
MTextDocument.Portion
Selected text. |
static class |
MTextDocument.Section
Plain text section with uniform attributes. |
Constructor Summary | |
---|---|
MTextDocument()
Constructs an empty document. |
|
MTextDocument(MTextDocument d)
Copy constructor. |
|
MTextDocument(java.lang.String s)
Constructs a document from the specified string. |
Method Summary | |
---|---|
void |
append(java.lang.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 k,
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. |
java.lang.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,
java.lang.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(java.io.ObjectInput in)
Restores the document. |
void |
readFromString(java.lang.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,
java.lang.String s)
Replaces a substring in the document. |
MFont |
reuseFont(java.lang.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(java.lang.String s)
Sets the document as plain text. |
java.lang.String |
substring(int start)
Gets a substring of the document. |
java.lang.String |
substring(int start,
int end)
Gets a substring of the document. |
java.lang.String |
toString()
Gets the string representation of the document. |
void |
updateSubLevel(double[] sublevX,
double x,
int k)
|
void |
writeExternal(java.io.ObjectOutput out)
Saves the document. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MTextDocument()
public MTextDocument(java.lang.String s)
s
- the stringpublic MTextDocument(MTextDocument d)
d
- the document to copyMethod Detail |
---|
public final java.lang.String getPlainText()
public void setPlainText(java.lang.String s)
s
- the textpublic final int length()
public final char charAt(int i)
public boolean endsWith(char c)
c
- the character
public final java.lang.String substring(int start)
start
- index of first character
public final java.lang.String substring(int start, int end)
start
- index of first characterend
- index of last character + 1
public final void remove(int start, int len)
start
- index of first character to deletelen
- number of characters to deletepublic final void append(java.lang.String s, MTextAttributes attr)
s
- text to addattr
- section attributes or nullpublic final void insert(int i, java.lang.String s, MTextAttributes attr)
i
- character indexs
- string to insertattr
- text attributes or nullpublic final void replace(int start, int len, java.lang.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 + 1
public MFont getDefaultFont()
public void setDefaultFont(MFont f)
f
- the fontpublic final int getSectionCount()
public final int getSectionIndexOfCharAt(int i)
i
- character position
public final MTextDocument.Section getSection(int k)
k
- section number
public final double getSectionShiftY(int k)
k
- the section number
public final int findScriptLastSectionIndex(int k, int subl)
k
- 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 java.lang.String toString()
toString
in class java.lang.Object
public void readFromString(java.lang.String str) throws java.lang.IllegalArgumentException
str
- the string
java.lang.IllegalArgumentException
public MFont reuseFont(java.lang.String name, int style, double size)
public void updateSubLevel(double[] sublevX, double x, int k)
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- the stream to read data from in order to restore the object
java.io.IOException
- if I/O errors occur
java.lang.ClassNotFoundException
- If the class for an object being
restored cannot be found.public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- the stream to write the object to
java.io.IOException
- Includes any I/O exceptions that may occur
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |