|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Object | +--javax.swing.plaf.ComponentUI | +--javax.swing.plaf.TextUI | +--javax.swing.plaf.basic.BasicTextUI
テキストコンポーネントの Look & Feel の基礎となるクラスです。このクラスは、JTextComponent の拡張の Look & Feel を作成するときに便利な、エディタのビューおよびコントローラの基本的なサービスを提供します。
多くの場合、状態は関連付けられている JTextComponent にバウンドプロパティとして保持されており、UI では各プロパティの既定値がインストールされます。このデフォルトの動作により、すべてのプロパティに対して値がインストールされますが、通常、Look & Feel の実装ではさらに多くのことが行われます。通常、Look & Feel の実装により、少なくともキーバインディングがインストールされます。
定義する必要がある重要なメソッドは、UIManager から既定値を取り出すために使われるキーの基礎である getPropertyPrefix()
メソッドです。取得した文字列は、名前の特定の Look & Feel 部分 (Metal、Motif など) のない TextUI の型 (TextField、TextArea など) を反映します。
モデルのビューを構築するには、次に示す方法のどれかを使います。
create(javax.swing.text.Element)
メソッドを実装し直します。
#createViewFactory
メソッドを実装し直す必要があります。
警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。今後の Swing リリースでは、長期間の持続性をサポートする予定です。
内部クラスの概要 | |
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 を取得します。 |
protected Rectangle |
getVisibleEditorRect()
エディタの画面上での可視部分を取得します。 |
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 をアンインストールします。 |
int |
viewToModel(JTextComponent tc,
Point pt)
ビューの座標系内の指定された位置をモデル内のもっとも近い位置に変換します。 |
int |
viewToModel(JTextComponent tc,
Point pt,
Position.Bias[] biasReturn)
ビューの座標系内の指定された位置をモデル内のもっとも近い位置に変換します。 |
クラス javax.swing.plaf.ComponentUI から継承したメソッド |
contains,
createUI,
getAccessibleChild,
getAccessibleChildrenCount,
update |
クラス java.lang.Object から継承したメソッド |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
コンストラクタの詳細 |
public BasicTextUI()
メソッドの詳細 |
protected Caret createCaret()
protected Highlighter createHighlighter()
protected String getKeymapName()
protected Keymap createKeymap()
キーマップを作成するために使われるバインディングのセットは、getPropertyPrefix()
メソッドと文字列 .keyBindings
を結合したキーを使って UIManager から取得されます。型は、JTextComponent.KeyBinding[]
であると見なされます。
getKeymapName()
,
JTextComponent
protected void propertyChange(PropertyChangeEvent evt)
evt
- プロパティ変更イベントprotected abstract String getPropertyPrefix()
protected void installDefaults()
uninstallDefaults()
,
installUI(javax.swing.JComponent)
protected void uninstallDefaults()
installDefaults()
,
uninstallUI(javax.swing.JComponent)
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)
c
- エディタコンポーネントComponentUI.installUI(javax.swing.JComponent)
public void uninstallUI(JComponent c)
c
- エディタコンポーネントComponentUI.uninstallUI(javax.swing.JComponent)
public final void paint(Graphics g, JComponent c)
g
- グラフィックスコンテキストc
- エディタコンポーネントpublic Dimension getPreferredSize(JComponent c)
c
- エディタコンポーネントpublic Dimension getMinimumSize(JComponent c)
c
- エディタコンポーネントpublic Dimension getMaximumSize(JComponent c)
c
- エディタコンポーネントprotected Rectangle getVisibleEditorRect()
public Rectangle modelToView(JTextComponent tc, int pos) throws BadLocationException
tc
- この UI がインストールされているテキストコンポーネントpos
- 変換対象のモデル内のローカル位置 >= 0TextUI.modelToView(javax.swing.text.JTextComponent, int)
public Rectangle modelToView(JTextComponent tc, int pos, Position.Bias bias) throws BadLocationException
tc
- この UI がインストールされているテキストコンポーネントpos
- 変換対象のモデル内のローカル位置 >= 0TextUI.modelToView(javax.swing.text.JTextComponent, int)
public int viewToModel(JTextComponent tc, Point pt)
tc
- この UI がインストールされているテキストコンポーネントpt
- 変換対象のビュー内の位置。マウスイベントと同じ座標系でなければならないTextUI.viewToModel(javax.swing.text.JTextComponent, java.awt.Point)
public int viewToModel(JTextComponent tc, Point pt, Position.Bias[] biasReturn)
tc
- この UI がインストールされているテキストコンポーネントpt
- 変換対象のビュー内の位置。マウスイベントと同じ座標系でなければならない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
pos
- 変換される位置 >= 0b
- 描画するために割り当てられた領域direction
- キーボード上の矢印キーと同様の、現在の位置からの方向。SwingConstants.WEST、SwingConstants.EAST、SwingConstants.NORTH、または SwingConstants.SOUTH のどれかpublic void damageRange(JTextComponent tc, int p0, int p1)
tc
- この 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)
p0
- 範囲の始点 >= 0p1
- 範囲の終点 >= p0public EditorKit getEditorKit(JTextComponent tc)
tc
- この UI がインストールされているテキストコンポーネントTextUI.getEditorKit(javax.swing.text.JTextComponent)
public View getRootView(JTextComponent tc)
tc
- この UI がインストールされているテキストコンポーネントTextUI.getRootView(javax.swing.text.JTextComponent)
public View create(Element elem)
elem
- 要素public View create(Element elem, int p0, int p1)
elem
- 要素p0
- 開始オフセット >= 0p1
- 終了オフセット >= p0
|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |