public abstract class CompositeView extends View
CompositeView は、1 つ以上の子ビューを管理する abstract クラスの View の実装です。CompositeView は、比較的少数の子ビューを管理することを想定しています。CompositeView は、BoxView など、子の View を含む、View の実装の開始ポイントとして使用されます。子の View のコレクションを管理するサブクラスでは、replace(int, int, javax.swing.text.View[]) メソッドが使用されます。DocumentListener 通知中に View が replace を呼び出すので、通常 replace を直接呼び出す必要はありません。
CompositeView は、子の View にレイアウトポリシーを強制しませんが、これから含むことになる子の View の挿入は許可します。インセットは、setInsets(short, short, short, short) または setParagraphInsets(javax.swing.text.AttributeSet) によって設定できます。
View の抽象メソッドに加え、CompositeView のサブクラスもオーバーライドする必要があります。
isBefore(int, int, java.awt.Rectangle) - 指定された View の位置が、CompositeView の視覚空間の前にあるかどうかを調べる。
isAfter(int, int, java.awt.Rectangle) - 指定された View の位置が、CompositeView の視覚空間の後ろにあるかどうかを調べる。
getViewAtPoint(int, int, java.awt.Rectangle) - 指定された視覚位置のビューを返す。
childAllocation(int, java.awt.Rectangle) - 特定の子 View の境界を返す。
CompositeView の Inset により境界をオフセットしたあとで、getChildAllocation は childAllocation を呼び出す。 BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXISBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST| コンストラクタと説明 |
|---|
CompositeView(Element elem)
指定された要素の
CompositeView を構築します。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected abstract void |
childAllocation(int index, Rectangle a)
指定された子への割り当てを返します。
|
protected boolean |
flipEastAndWestAtEnds(int position, Position.Bias bias)
次のビューをどの方向に配置するかを決定します。
|
protected short |
getBottomInset()
下のインセットを取得します。
|
Shape |
getChildAllocation(int index, Shape a)
指定された、レンダリングする子ビューへの割り当てを取得します。
|
protected Rectangle |
getInsideAllocation(Shape a)
ビューに指定された不変の割り当てを、内部割り当てを表す可変割り当てに変換します。
|
protected short |
getLeftInset()
左のインセットを取得します。
|
protected int |
getNextEastWestVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet)
カーソルを置くことのできる、次の視覚的な位置を返します。方向は右 (east) または左 (west) になります。
|
protected int |
getNextNorthSouthVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet)
カーソルを置くことのできる、次の視覚的な位置を返します。方向は上 (north) または下 (south) になります。
|
int |
getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet)
キャレットが配置される可能性のある、視覚的に表された次のモデル位置を決定する手段を提供します。
|
protected short |
getRightInset()
右のインセットを取得します。
|
protected short |
getTopInset()
上のインセットを取得します。
|
View |
getView(int n)
コンテナ内の n 番目のビューを返します。
|
protected abstract View |
getViewAtPoint(int x, int y, Rectangle alloc)
指定された座標の子ビューを取得します。
|
protected View |
getViewAtPosition(int pos, Rectangle a)
モデル内で指定された位置を表す子ビューを取得します。
|
int |
getViewCount()
このビューの子ビューの数を返します。
|
int |
getViewIndex(int pos, Position.Bias b)
モデル内の指定された位置を表す子ビューのインデックスを返します。
|
protected int |
getViewIndexAtPosition(int pos)
モデル内の指定された位置を表す子ビューのインデックスを取得します。
|
protected abstract boolean |
isAfter(int x, int y, Rectangle alloc)
ある点が、矩形範囲の後ろにあるかどうかを判定します。
|
protected abstract boolean |
isBefore(int x, int y, Rectangle alloc)
ある点が、矩形範囲の前にあるかどうかを判定します。
|
protected void |
loadChildren(ViewFactory f)
ビューを初期化するためにすべての子をロードします。
|
Shape |
modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
ドキュメントモデルの座標空間からビューの座標空間へのマッピングを提供します。
|
Shape |
modelToView(int pos, Shape a, Position.Bias b)
ドキュメントモデルの座標空間からビューの座標空間へのマッピングを提供します。
|
void |
replace(int offset, int length, View[] views)
子ビューを置換します。
|
protected void |
setInsets(short top, short left, short bottom, short right)
ビューのインセットを設定します。
|
protected void |
setParagraphInsets(AttributeSet attr)
指定された属性から選ばれた段落属性から、インセットを設定します。
|
void |
setParent(View parent)
ビューの親を設定します。
|
int |
viewToModel(float x, float y, Shape a, Position.Bias[] bias)
ビューの座標空間からモデルの論理座標空間へのマッピングを提供します。
|
append, breakView, changedUpdate, createFragment, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getParent, getPreferredSpan, getResizeWeight, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, paint, preferenceChanged, remove, removeAll, removeUpdate, setSize, updateChildren, updateLayout, viewToModelpublic CompositeView(Element elem)
CompositeView を構築します。elem - このビューが扱う要素protected void loadChildren(ViewFactory f)
setParent(javax.swing.text.View) メソッドによって呼び出されます。サブクラスは、このメソッドを再実装して別の方法で子ビューを初期化できます。デフォルトの実装は、子要素ごとに子ビューを作成します。f - ビューファクトリsetParent(javax.swing.text.View)public void setParent(View parent)
loadChildren メソッドの呼び出しとともにスーパークラスの動作を提供するために実装し直されます。子をコンストラクタの中にロードしないようにしてください。これは、親を設定する動作が原因となって、たとえば収容側 Container を取得するために、子が階層をさかのぼって検索しようとするからです。このビューが子を持つ場合、ビューはビュー階層内のある位置から別の位置へ移動しているので、loadChildren メソッドは呼び出されません。public int getViewCount()
getViewCount、クラス: ViewgetView(int)public View getView(int n)
public void replace(int offset,
int length,
View[] views)
null に設定された親を持ち、削除されるビューの内部参照をしているので、ガベージとして回収できます。public Shape getChildAllocation(int index, Shape a)
getChildAllocation、クラス: Viewindex - 子のインデックス。0 以上で getViewCount() より小さい値a - このビューに対する割り当てpublic Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
modelToView、クラス: Viewpos - 変換対象の位置 >= 0a - 描画するために割り当てられた領域b - Position.Bias.Forward または Position.Bias.Backward のバイアス値BadLocationException - 指定された位置が、関連するドキュメント内の有効な位置を示さない場合View.modelToView(int, java.awt.Shape, javax.swing.text.Position.Bias)public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a) throws BadLocationException
modelToView、クラス: Viewp0 - 変換対象の位置 >= 0b0 - 位置が 2 つのビューの境界である場合に、p0 によって表される直前の文字または次の文字へのバイアス。Position.Bias.Forward または Position.Bias.Backwardp1 - 変換対象の位置 >= 0b1 - 位置が 2 つのビューの境界である場合に、p1 によって表される直前の文字または次の文字へのバイアスa - 描画するために割り当てられた領域BadLocationException - 指定された位置が、関連するドキュメント内の有効な位置を示さない場合IllegalArgumentException - bias 引数が無効な場合View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])public int viewToModel(float x,
float y,
Shape a,
Position.Bias[] bias)
viewToModel、クラス: Viewx - 変換するビュー位置の x 座標 >= 0y - 変換するビュー位置の y 座標 >= 0a - 描画するために割り当てられた領域bias - Position.Bias.Forward または Position.Bias.BackwardView.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])public int getNextVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
getNextNorthSouthVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[]) および getNextEastWestVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[]) の簡易メソッドです。getNextVisualPositionFrom、クラス: Viewpos - 変換対象の位置 >= 0b - Position.Bias.Forward または Position.Bias.Backward のバイアス値a - 描画するために割り当てられた領域direction - 現在位置からの方向。これは、キーボードに通常存在する矢印キーと見なすことができ、次のいずれかになる。
SwingConstants.WEST
SwingConstants.EAST
SwingConstants.NORTH
SwingConstants.SOUTH
biasRet - チェックされたバイアスを含む配列BadLocationExceptionIllegalArgumentException - direction が無効である場合public int getViewIndex(int pos,
Position.Bias b)
getViewIndexByPosition メソッドを呼び出すためにこのメソッドを実装しています。getViewIndex、クラス: Viewpos - 位置 >= 0protected abstract boolean isBefore(int x,
int y,
Rectangle alloc)
x - X 座標 >= 0y - Y 座標 >= 0alloc - 矩形protected abstract boolean isAfter(int x,
int y,
Rectangle alloc)
x - X 座標 >= 0y - Y 座標 >= 0alloc - 矩形protected abstract View getViewAtPoint(int x, int y, Rectangle alloc)
x - X 座標 >= 0y - Y 座標 >= 0alloc - 入口での親の割り当て。出口で子の割り当てに変更protected abstract void childAllocation(int index,
Rectangle a)
index - 子のインデックス。0 以上で getViewCount() より小さい値a - 入り口でのボックスの内部への割り当て。および、出口でのインデックス位置の子ビューの割り当て。protected View getViewAtPosition(int pos, Rectangle a)
pos - 位置 >= 0a - 入り口でのボックスの内部への割り当て。および、出口での位置を含むビューの割り当てnullprotected int getViewIndexAtPosition(int pos)
pos - 位置 >= 0protected Rectangle getInsideAllocation(Shape a)
childAllocation メソッドに送られます。a - ビューに指定された割り当てnull の場合、戻り値は nullprotected void setParagraphInsets(AttributeSet attr)
attr - 属性protected void setInsets(short top,
short left,
short bottom,
short right)
top - 上のインセット >= 0left - 左のインセット >= 0bottom - 下のインセット >= 0right - 右のインセット >= 0protected short getLeftInset()
protected short getRightInset()
protected short getTopInset()
protected short getBottomInset()
protected int getNextNorthSouthVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
pos - 変換対象の位置 >= 0b - Position.Bias.Forward または Position.Bias.Backward のバイアス値a - 描画するために割り当てられた領域direction - 現在位置からの方向。これは、キーボードに通常存在する矢印キーと見なすことができ、次のいずれかになる。
SwingConstants.NORTH
SwingConstants.SOUTH
biasRet - チェックされたバイアスを含む配列BadLocationExceptionIllegalArgumentException - direction が無効である場合getNextVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[])protected int getNextEastWestVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
pos - 変換対象の位置 >= 0b - Position.Bias.Forward または Position.Bias.Backward のバイアス値a - 描画するために割り当てられた領域direction - 現在位置からの方向。これは、キーボードに通常存在する矢印キーと見なすことができ、次のいずれかになる。
SwingConstants.WEST
SwingConstants.EAST
biasRet - チェックされたバイアスを含む配列BadLocationExceptionIllegalArgumentException - direction が無効である場合getNextVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[])protected boolean flipEastAndWestAtEnds(int position,
Position.Bias bias)
View が考慮されます。通常は、EAST への View がインデックス n + 1、WEST への View がインデックス n -1 となるように、View は左から右へレイアウトされます。双方向テキストなど一部の場合では、EAST への View をインデックス n + 1 ではなくインデックス n -1 に、または WEST への View をインデックス n - 1 ではなくインデックス n + 1 にすることもできます。この場合、このメソッドは true を返し、View が降順にレイアウトされていることを示します。
ここでは無条件に false が返されます。View を降順に配置する可能性がある場合、サブクラスはこのメソッドをオーバーライドします。
position - モデルへの位置bias - Position.Bias.Forward または Position.Bias.Backward バグまたは機能を送信
詳細な API リファレンスおよび開発者ドキュメントについては、Java SE のドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2013, Oracle and/or its affiliates. All rights reserved.