|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Object | +--javax.swing.text.GapVector | +--javax.swing.text.GapContent
emacs が使うものと類似したギャップ付きバッファを使って実装された AbstractDocument.Content インタフェースの実装です。記憶される内容は、どこかにギャップを持つ Unicode 文字列の配列です。ギャップは変更の位置に移動されるので、ほとんどの変更が同じ位置にある場所で、共通の動作を利用できるようになります。ギャップ境界で生じる変更は一般的に簡単なものなので、配列の内容を直接移動して変更を適用するよりもギャップを移動するほうが手間がかかりません。
また、変更を追跡する位置を管理するのも一般的に簡単です。位置の実装 (マーク) は配列インデックスを格納し、現在のギャップ位置から逐次位置を簡単に計算できます。変更ではギャップの移動時に新旧ギャップ境界間のマークに対する更新を必要とするだけなので、マークの更新は一般に非常に手軽です。マークはソートされた状態で格納されるので、2 等分探索ですばやく見つけられます。これはマークを追加する手間を増大させる一方で、マークの更新を維持する手間を減らします。
コンストラクタの概要 | |
GapContent()
新しい GapContent オブジェクトを作成します。 |
|
GapContent(int initialLength)
新しい GapContent オブジェクトを、指定された初期サイズで作成します。 |
メソッドの概要 | |
protected Object |
allocateArray(int len)
項目を格納するための適切な型の配列を割り当てます。 |
Position |
createPosition(int offset)
コンテンツの変更に対応してその変更を追跡する位置をコンテンツ内に作成します。 |
protected int |
getArrayLength()
割り当てられた配列の長さを取得します。 |
void |
getChars(int where,
int len,
Segment chars)
コンテンツの一部を取得します。 |
protected Vector |
getPositionsInRange(Vector v,
int offset,
int length)
offset 〜 offset + length の範囲の Position に対応する、UndoPosRef のインスタンスが格納されている Vector を返します。 |
String |
getString(int where,
int len)
コンテンツの一部を取得します。 |
UndoableEdit |
insertString(int where,
String str)
文字列をコンテンツに挿入します。 |
int |
length()
コンテンツの長さを返します。 |
UndoableEdit |
remove(int where,
int nitems)
コンテンツの一部を削除します。 |
protected void |
resetMarksAtZero()
オフセットが 0 のマークをすべてリセットして、インデックスも 0 になるようにします。 |
protected void |
shiftEnd(int newSize)
ギャップを拡大し、これにより、必要なデータを移動して適切なマークを更新します。 |
protected void |
shiftGap(int newGapStart)
ギャップの開始位置を新しい位置に移動します。 |
protected void |
shiftGapEndUp(int newGapEnd)
ギャップの終端を上方に調節します。 |
protected void |
shiftGapStartDown(int newGapStart)
ギャップの終端を下方に調節します。 |
protected void |
updateUndoPositions(Vector positions,
int offset,
int length)
positions 内にあるすべての UndoPosRef のインスタンスに対して、位置をリセットします。 |
クラス javax.swing.text.GapVector から継承したメソッド |
getArray,
getGapEnd,
getGapStart,
replace |
クラス java.lang.Object から継承したメソッド |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
コンストラクタの詳細 |
public GapContent()
public GapContent(int initialLength)
initialLength
- 初期サイズメソッドの詳細 |
protected Object allocateArray(int len)
protected int getArrayLength()
public int length()
AbstractDocument.Content.length()
public UndoableEdit insertString(int where, String str) throws BadLocationException
where
- 開始位置 >= 0、< length()str
- 挿入対象の、null 以外の文字列AbstractDocument.Content.insertString(int, java.lang.String)
public UndoableEdit remove(int where, int nitems) throws BadLocationException
where
- 開始位置 >= 0、where + nitems < length()nitems
- 削除対象の文字数 >= 0AbstractDocument.Content.remove(int, int)
public String getString(int where, int len) throws BadLocationException
where
- 開始位置 >= 0len
- 取得する長さ >= 0AbstractDocument.Content.getString(int, int)
public void getChars(int where, int len, Segment chars) throws BadLocationException
where
- 開始位置 >= 0、where + len <= length()len
- 取得する文字数 >= 0chars
- 文字列の返し先の Segment オブジェクトAbstractDocument.Content.getChars(int, int, javax.swing.text.Segment)
public Position createPosition(int offset) throws BadLocationException
offset
- 追跡対象のオフセット >= 0protected void shiftEnd(int newSize)
protected void shiftGap(int newGapStart)
protected void resetMarksAtZero()
protected void shiftGapStartDown(int newGapStart)
protected void shiftGapEndUp(int newGapEnd)
protected Vector getPositionsInRange(Vector v, int offset, int length)
offset
〜 offset
+ length
の範囲の Position に対応する、UndoPosRef のインスタンスが格納されている Vector を返します。v
が null ではない場合は、適合した Position がその中に置かれます。適合した Position が格納されている Vector が返されます。v
- 使用する Vector。null の場合は、新しく作成されるoffset
- 開始位置のオフセット >= 0length
- 範囲の長さ >= 0protected void updateUndoPositions(Vector positions, int offset, int length)
positions
内にあるすべての UndoPosRef のインスタンスに対して、位置をリセットします。positions
- リセット対象の UndoPosRef のインスタンス
|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |