| java.lang.Object com.ibm.richtext.styledtext.MStyleBuffer com.ibm.richtext.styledtext.StyleBuffer
StyleBuffer | final class StyleBuffer extends MStyleBuffer implements Externalizable(Code) | | StyleBuffer implements MStyleBuffer. It maintains
AttributeMap objects to apply to the text in an MText object,
and the
intervals on which those styles apply.
StyleBuffer stores the intervals on which styles apply in a RunArray
object (see RunArray for more information). The styles are stored in
an array of AttributeMap objects.
RunArray maintains an array of integers which represent offsets into text.
The array has a "positive" region in which offsets are given as positive distances
from the start of the text, and a "negative" region in which offsets are given as
negative distances from the end of the text. Between the positive and negative regions
is a gap, into which new offsets may be inserted. This storage scheme allows for
efficient response to a series of editing operations which occur in the same area of the
text.
StyleBuffer uses the offsets in RunArray as the boundaries of style runs.
A style run begins at each offset in RunArray, and each style run continues to
the next offset. The style array is kept in sync with the array of offsets in RunArray;
that is, the style which begins at RunArray[i] is stored in StyleArray[i].
The first entry in the RunArray is always 0.
author: John Raley See Also: AttributeMap See Also: MText See Also: RunArray |
Method Summary | |
void | compress() Minimize the amount of storage used by this object. | public void | deleteText(int start, int limit) Respond to a deletion in the text. | public void | insertText(int start, int limit) Respond to an insertion in the text. | public boolean | modifyStyles(int start, int limit, StyleModifier modifier, int[] damagedRange) | public void | readExternal(ObjectInput in) | public void | replace(int start, int limit, MConstText srcText, int srcStart, int srcLimit) | void | setIterator(int pos, StyleRunIterator iter) | public AttributeMap | styleAt(int pos) Return style at location pos. | public int | styleLimit(int pos) | public int | styleStart(int pos) | public void | writeExternal(ObjectOutput out) |
StyleBuffer | StyleBuffer(int initialLength, AttributeMap initialStyle)(Code) | | Creates a new style buffer with length initialLength and with a
single run of defaultStyle.
|
StyleBuffer | public StyleBuffer()(Code) | | Note: this constructor is ONLY for use by the Serialization
mechanism. It does not leave this object in a valid state!
|
compress | void compress()(Code) | | Minimize the amount of storage used by this object.
|
deleteText | public void deleteText(int start, int limit)(Code) | | Respond to a deletion in the text. The last style run before
start is truncated to end at start. The
style run containing (start+length) is set to begin
at (start+length). Runs in between are deleted.
If the deletion occurs entirely within one style run, the length of the style
run is reduced by length.
This implementation assumes that all styles propogate.
This method shifts the run table such that the run in which the delete began
is the last positive run. Other methods depend on this "side effect".
Parameters: start - the offset where the deletion began Parameters: length - the offset where the deletion stopped |
insertText | public void insertText(int start, int limit)(Code) | | Respond to an insertion in the text. The length of the last style run which
begins before start is increased by length. The run table
is shifted such that the run into which text was inserted is the last positive run.
This implementation assumes that all styles propogate.
Parameters: start - the offset where the insertion began Parameters: length - the number of characters inserted |
modifyStyles | public boolean modifyStyles(int start, int limit, StyleModifier modifier, int[] damagedRange)(Code) | | |
replace | public void replace(int start, int limit, MConstText srcText, int srcStart, int srcLimit)(Code) | | |
setIterator | void setIterator(int pos, StyleRunIterator iter)(Code) | | |
styleAt | public AttributeMap styleAt(int pos)(Code) | | Return style at location pos.
Parameters: pos - an offset into the text |
styleLimit | public int styleLimit(int pos)(Code) | | |
styleStart | public int styleStart(int pos)(Code) | | |
|
|