public abstract class BasicTextUI extends TextUI implements ViewFactory
テキストコンポーネントの Look & Feel の基礎です。このクラスは、JTextComponent の拡張のための Look & Feel を作成するときに便利な、エディタビューおよびコントローラの基本的なサービスを提供します。
ほとんどの状態は関連付けられた JTextComponent にバウンドプロパティーとして保持されており、UI はさまざまなプロパティーのデフォルト値をインストールします。このデフォルトは、すべてのプロパティーのために何かをインストールします。ただし通常は、Look & Feel 実装が追加の作業を行います。少なくとも、Look & Feel は一般的にキーバインディングをインストールします。
また、JTextComponent に関連付けられた Document が AbstractDocument のサブクラスである場合、このクラスはいくつかの並行サポートも提供します。View または View 階層へのアクセスは、モデルを変更するスレッドと Swing イベントスレッド (レンダリング、モデルとビュー座標変換などを行う) との間で直列化されます。ルートビューにアクセスするときは、最初に AbstractDocument で読み取りロックを獲得して、そのロックを finally ブロックで解放するようにしてください。
定義する必要がある重要なメソッドは、UIManager からデフォルトを取り出すために使用されるキーの基礎として使用される、getPropertyPrefix() メソッドです。これらの文字列は、名前の特定の Look & Feel 部分 (Metal、Motif など) のない TextUI の型 (TextField、TextArea など) を反映しているはずです。
モデルのビューを構築するには、次に示す方法のいずれかを使います。
create(javax.swing.text.Element) メソッドを実装し直します。
警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースとの互換性がなくなる予定です。現在の直列化のサポートは、短期間の格納や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。1.4 以降、すべての JavaBeansTM 用の長期間の格納サポートが java.beans パッケージに追加されています。XMLEncoder を参照してください。
| 修飾子と型 | クラスと説明 |
|---|---|
static class |
BasicTextUI.BasicCaret |
static class |
BasicTextUI.BasicHighlighter |
| コンストラクタと説明 |
|---|
BasicTextUI()
新しい UI を作成します。
|
| 修飾子と型 | メソッドと説明 |
|---|---|
View |
create(Element elem)
要素のビューを作成します。
|
View |
create(Element elem, int p0, int p1)
要素のビューを作成します。
|
protected Caret |
createCaret()
キャレットに使用するオブジェクトを作成します。
|
protected Highlighter |
createHighlighter()
ハイライトを追加するために使用するオブジェクトを作成します。
|
protected Keymap |
createKeymap()
テキストコンポーネントに使用するキーマップを作成し、それに必要なバインディングをインストールします。
|
void |
damageRange(JTextComponent tc, int p0, int p1)
モデル内の指定された一部分に対応するビューの部分が描画し直されるようにします。
|
void |
damageRange(JTextComponent t, int p0, int p1, Position.Bias p0Bias, Position.Bias p1Bias)
モデル内の指定された一部分に対応するビューの部分が描画し直されるようにします。
|
protected JTextComponent |
getComponent()
この UI 実装に関連付けられたテキストコンポーネントを取得します。
|
EditorKit |
getEditorKit(JTextComponent tc)
UI の EditorKit を取得します。
|
protected String |
getKeymapName()
この UI にデフォルトでインストールまたは使用されるキーマップの名前を取得します。
|
Dimension |
getMaximumSize(JComponent c)
エディタコンポーネントの最大サイズを取得します。
|
Dimension |
getMinimumSize(JComponent c)
エディタコンポーネントの最小サイズを取得します。
|
int |
getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet)
キャレットが配置される可能性のある、視覚的に表された次のモデル位置を決定する手段を提供します。
|
Dimension |
getPreferredSize(JComponent c)
エディタコンポーネントの推奨サイズを取得します。
|
protected abstract String |
getPropertyPrefix()
UIManager を介してプロパティーを参照するためのキーとして使用される名前を取得します。
|
View |
getRootView(JTextComponent tc)
関連したテキストコンポーネントの割り当てを持つ View を取得します。
|
String |
getToolTipText(JTextComponent t, Point pt)
渡された位置でツールチップとして使用される文字列を返します。
|
protected Rectangle |
getVisibleEditorRect()
ルート View を渡す割り当てを取得します。
|
protected void |
installDefaults()
フォント、フォアグラウンド、バックグラウンド、キャレットの色、選択の色、選択されたテキストの色、無効になったテキストの色、ボーダーの色などのコンポーネントプロパティーを初期化します。
|
protected void |
installKeyboardActions() |
protected void |
installListeners()
UI のリスナーをインストールします。
|
void |
installUI(JComponent c)
コンポーネントの UI をインストールします。
|
protected void |
modelChanged()
モデルの変更にフラグを立てます。
|
Rectangle |
modelToView(JTextComponent tc, int pos)
モデル内の指定された位置を、ビュー座標体系内の場所に変換します。
|
Rectangle |
modelToView(JTextComponent tc, int pos, Position.Bias bias)
モデル内の指定された位置を、ビュー座標体系内の場所に変換します。
|
void |
paint(Graphics g, JComponent c)
インタフェースをペイントします。
|
protected void |
paintBackground(Graphics g)
ビューのバックグラウンドをペイントします。
|
protected void |
paintSafely(Graphics g)
このスレッドのビューからモデルが変更されないという保証付きで、安全にインタフェースをペイントします。
|
protected void |
propertyChange(PropertyChangeEvent evt)
このメソッドは、関連付けられた JTextComponent でバウンドプロパティーが変更されたときに呼び出されます。
|
protected void |
setView(View v)
ビュー階層の現在のルートを設定し、invalidate() を呼び出します。
|
protected void |
uninstallDefaults()
null に明示的にオーバーライドされていないコンポーネントプロパティーを設定します。 |
protected void |
uninstallKeyboardActions() |
protected void |
uninstallListeners()
UI のリスナーをアンインストールします。
|
void |
uninstallUI(JComponent c)
コンポーネントの UI をアンインストールします。
|
void |
update(Graphics g, JComponent c)
スーパークラスが、制御不可能な方法でバックグラウンドをペイントします。
|
int |
viewToModel(JTextComponent tc, Point pt)
ビュー座標体系内の指定された場所を、モデル内のもっとも近い代表的な位置に変換します。
|
int |
viewToModel(JTextComponent tc, Point pt, Position.Bias[] biasReturn)
ビュー座標体系内の指定された場所を、モデル内のもっとも近い代表的な位置に変換します。
|
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehaviorprotected Caret createCaret()
protected Highlighter createHighlighter()
protected String getKeymapName()
protected Keymap createKeymap()
キーマップを作成するために使用されるバインディングのセットは、getPropertyPrefix() メソッドと文字列 .keyBindings を結合することでフォーマットされるキーを使用して UIManager から取得されます。型は、JTextComponent.KeyBinding[] になります。
getKeymapName(), JTextComponentprotected void propertyChange(PropertyChangeEvent evt)
evt - プロパティー変更イベントprotected abstract String getPropertyPrefix()
protected void installDefaults()
protected void uninstallDefaults()
null に明示的にオーバーライドされていないコンポーネントプロパティーを設定します。現在の値が UIResource でなければ、プロパティーはオーバーライドされたと判断されます。protected void installListeners()
protected void uninstallListeners()
protected void installKeyboardActions()
protected void uninstallKeyboardActions()
protected void paintBackground(Graphics g)
g - グラフィックスコンテキストprotected final JTextComponent getComponent()
protected void modelChanged()
protected final void setView(View v)
v - ルートビューprotected void paintSafely(Graphics g)
g - グラフィックスコンテキストpublic void installUI(JComponent c)
null または UIResource のインスタンスである場合にのみ設定されます。
installUI、クラス: ComponentUIc - エディタコンポーネントComponentUI.installUI(javax.swing.JComponent)public void uninstallUI(JComponent c)
uninstallUI、クラス: ComponentUIc - エディタコンポーネントComponentUI.uninstallUI(javax.swing.JComponent)public void update(Graphics g, JComponent c)
注:注:また、スーパークラスはバックグラウンドのレンダリングでスレッドセーフではありません。ただし、このことはデフォルトレンダリングでは問題になりません。
update、クラス: ComponentUIg - ペイント対象の Graphics コンテキストc - ペイントされるコンポーネント。この引数は通常無視されるが、UI オブジェクトがステートレスで、複数のコンポーネントで共有されている場合は使用されることがあるComponentUI.paint(java.awt.Graphics, javax.swing.JComponent), JComponent.paintComponent(java.awt.Graphics)public final void paint(Graphics g, JComponent c)
paint、クラス: ComponentUIg - グラフィックスコンテキストc - エディタコンポーネントComponentUI.update(java.awt.Graphics, javax.swing.JComponent)public Dimension getPreferredSize(JComponent c)
getPreferredSize、クラス: ComponentUIc - エディタコンポーネントJComponent.getPreferredSize(), LayoutManager.preferredLayoutSize(java.awt.Container)public Dimension getMinimumSize(JComponent c)
getMinimumSize、クラス: ComponentUIc - エディタコンポーネントJComponent.getMinimumSize(), LayoutManager.minimumLayoutSize(java.awt.Container), ComponentUI.getPreferredSize(javax.swing.JComponent)public Dimension getMaximumSize(JComponent c)
getMaximumSize、クラス: ComponentUIc - エディタコンポーネントJComponent.getMaximumSize(), LayoutManager2.maximumLayoutSize(java.awt.Container)protected Rectangle getVisibleEditorRect()
public Rectangle modelToView(JTextComponent tc, int pos) throws BadLocationException
modelToView、クラス: TextUItc - この UI がインストールされているテキストコンポーネントpos - 変換対象のモデル内でのローカル位置 >= 0BadLocationException - 指定された位置が、関連付けられたドキュメント内の有効な位置を表していない場合TextUI.modelToView(javax.swing.text.JTextComponent, int)public Rectangle modelToView(JTextComponent tc, int pos, Position.Bias bias) throws BadLocationException
modelToView、クラス: TextUItc - この UI がインストールされているテキストコンポーネントpos - 変換対象のモデル内でのローカル位置 >= 0BadLocationException - 指定された位置が、関連付けられたドキュメント内の有効な位置を表していない場合TextUI.modelToView(javax.swing.text.JTextComponent, int)public int viewToModel(JTextComponent tc, Point pt)
viewToModel、クラス: TextUItc - この UI がインストールされているテキストコンポーネントpt - 変換対象のビューの座標系での位置。この場合の座標系は、マウスイベントと同じ座標系であるべきである。TextUI.viewToModel(javax.swing.text.JTextComponent, java.awt.Point)public int viewToModel(JTextComponent tc, Point pt, Position.Bias[] biasReturn)
viewToModel、クラス: TextUItc - この UI がインストールされているテキストコンポーネントpt - 変換対象のビューの座標系での位置。この場合の座標系は、マウスイベントと同じ座標系であるべきである。biasReturn - 指定された点がモデル内の前の文字と次の文字のどちらに近いのかを示すため、このメソッドによって書き込まれるTextUI.viewToModel(javax.swing.text.JTextComponent, java.awt.Point)public int getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet) throws BadLocationException
getNextVisualPositionFrom、クラス: TextUIt - この UI がインストールされているテキストコンポーネントpos - 変換対象の位置 >= 0b - 位置のバイアスdirection - 現在位置からの方向。キーボードに通常見られる矢印キーと見なすことができる。SwingConstants.WEST、SwingConstants.EAST、SwingConstants.NORTH、または SwingConstants.SOUTH の場合があるbiasRet - 返される位置のバイアスを含む配列BadLocationExceptionpublic void damageRange(JTextComponent tc, int p0, int p1)
damageRange、クラス: TextUItc - この UI がインストールされているテキストコンポーネントp0 - 範囲の始点 >= 0p1 - 範囲の終点 >= p0TextUI.damageRange(javax.swing.text.JTextComponent, int, int)public void damageRange(JTextComponent t, int p0, int p1, Position.Bias p0Bias, Position.Bias p1Bias)
damageRange、クラス: TextUIp0 - 範囲の始点 >= 0p1 - 範囲の終点 >= p0public EditorKit getEditorKit(JTextComponent tc)
getEditorKit、クラス: TextUItc - この UI がインストールされているテキストコンポーネントTextUI.getEditorKit(javax.swing.text.JTextComponent)public View getRootView(JTextComponent tc)
注: View 階層はルートビューからトラバースすることができ、ほかのことも同様にできます。このように行われたことは、TextUI を通じた単純なメソッド呼び出しのように保護することができません。したがって、並行処理が存在する場合には、このメソッドを呼び出すロジックによって、適切な処理を準備する必要があります。
getRootView、クラス: TextUItc - この UI がインストールされているテキストコンポーネントTextUI.getRootView(javax.swing.text.JTextComponent)public String getToolTipText(JTextComponent t, Point pt)
getToolTipText、クラス: TextUIJTextComponent.getToolTipText(java.awt.event.MouseEvent), View.getToolTipText(float, float, java.awt.Shape)public View create(Element elem)
create、インタフェース: ViewFactoryelem - 要素View バグまたは機能を送信
詳細な API リファレンスおよび開発者ドキュメントについては、Java SE のドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2013, Oracle and/or its affiliates. All rights reserved.