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_AXIS
BOTTOM, 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, viewToModel
public 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
、クラスView
getView(int)
public View getView(int n)
public void replace(int offset, int length, View[] views)
null
に設定され、ガベージ・コレクションが行えるようにそれらのビューへの内部参照が削除されます。 public Shape getChildAllocation(int index, Shape a)
getChildAllocation
、クラスView
index
- 子のインデックス。0以上でgetViewCount()より小さい値a
- このビューに対する割当てpublic Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
modelToView
、クラスView
pos
- 変換対象の位置>= 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
、クラスView
p0
- 変換対象の位置>= 0b0
- 位置が2つのビューの境界である場合に、p0によって表される直前の文字または次の文字へのバイアス。Position.Bias.Forward
またはPosition.Bias.Backward
p1
- 変換対象の位置>= 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
、クラスView
x
- 変換するビュー位置のx座標>= 0y
- 変換するビュー位置のy座標>= 0a
- 描画するために割り当てられた領域bias
- Position.Bias.Forward
またはPosition.Bias.Backward
View.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[])
の簡易メソッドです。 このメソッドを使用すると、0以上の範囲内で変換する位置を指定できます。 値が-1の場合は、位置が自動的に計算されます。 値が-1よりも小さい場合は、BadLocationException
がスローされます。 getNextVisualPositionFrom
、クラスView
pos
- 変換対象の位置b
- Position.Bias.Forward
またはPosition.Bias.Backward
のバイアス値a
- 描画するために割り当てられた領域direction
- 現在位置からの方向。これは、キーボードに通常存在する矢印キーと見なすことができ、次のいずれかになる。
SwingConstants.WEST
SwingConstants.EAST
SwingConstants.NORTH
SwingConstants.SOUTH
biasRet
- チェックされたバイアスを含む配列BadLocationException
- 指定された位置がドキュメント内の有効な位置でない場合IllegalArgumentException
- direction
が無効である場合public int getViewIndex(int pos, Position.Bias b)
getViewIndexByPosition
メソッドを呼び出すためにこのメソッドを実装しています。 getViewIndex
、クラスView
pos
- 位置>= 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
- 入口でのボックスの内部への割当て。および、出口での位置を含むビューの割当てnull
protected int getViewIndexAtPosition(int pos)
pos
- 位置>= 0protected Rectangle getInsideAllocation(Shape a)
childAllocation
メソッドに送られます。 a
- ビューに指定された割当てnull
の場合、戻り値はnull
protected 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
- チェックされたバイアスを含む配列BadLocationException
IllegalArgumentException
- 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
- チェックされたバイアスを含む配列BadLocationException
IllegalArgumentException
- 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, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。