|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectjavax.swing.plaf.ComponentUI
javax.swing.plaf.TextUI
javax.swing.plaf.basic.BasicTextUI
public abstract class BasicTextUI
テキストコンポーネントの Look & Feel の基礎となるクラスです。このクラスは、JTextComponent の拡張のための Look & Feel を作成するときに便利な、エディタのビューおよびコントローラの基本的なサービスを提供します。
多くの場合、状態は関連する JTextComponent にバウンドプロパティーとして保持されており、UI では各プロパティーのデフォルト値がインストールされます。このデフォルトの動作により、すべてのプロパティーに対して値がインストールされますが、通常、Look & Feel の実装ではさらに多くのことが行われます。Look & Feel の実装により、少なくともキーバインディングがインストールされるのが普通です。
また、JTextComponent に関連した Document が AbstractDocument のサブクラスである場合、このクラスは並行サポートも提供します。View または View 階層へのアクセスは、モデルを変更するスレッドと、描画したいモデルとビュー間の座標変換を行なったりするための Swing イベントスレッドとの間で直列化されます。ルートビューにアクセスするには、最初に AbstractDocument の読み取りロックを取得して、そのロックを最終ブロックで解放する必要があります。
定義する必要がある重要なメソッドは、UIManager からデフォルトの値を取り出すために使用されるキーの基礎である getPropertyPrefix() メソッドです。取得した文字列は、名前の特定の Look & Feel 部分 (Metal、Motif など) のない TextUI の型 (TextField、TextArea など) を反映します。
モデルのビューを構築するには、次に示す方法のいずれかを使います。
create(javax.swing.text.Element) メソッドを実装し直します。
警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。JDK Version 1.4 以降、すべての JavaBeans™ の長期間の運用サポートは、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)
ビュー座標体系内の指定された場所を、モデル内のもっとも近い位置に変換します。 |
| クラス javax.swing.plaf.ComponentUI から継承されたメソッド |
|---|
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior |
| クラス 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(),
JTextComponentprotected 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)
ComponentUI 内の installUIc - エディタコンポーネントComponentUI.installUI(javax.swing.JComponent)public void uninstallUI(JComponent c)
ComponentUI 内の uninstallUIc - エディタコンポーネントComponentUI.uninstallUI(javax.swing.JComponent)
public void update(Graphics g,
JComponent c)
注: また、デフォルトの描画の場合は問題ありませんが、スーパークラスの場合はバックグラウンド描画時にスレッドセーフではありません。
ComponentUI 内の updateg - ペイント対象の Graphics コンテキストc - ペイントされるコンポーネント。 この引数は通常無視されるが、 UI オブジェクトに状態がなく、複数のコンポーネントに共有されている場合は 使用されることがあるComponentUI.paint(java.awt.Graphics, javax.swing.JComponent),
JComponent.paintComponent(java.awt.Graphics)
public final void paint(Graphics g,
JComponent c)
ComponentUI 内の paintg - グラフィックスコンテキストc - エディタコンポーネントComponentUI.update(java.awt.Graphics, javax.swing.JComponent)public Dimension getPreferredSize(JComponent c)
ComponentUI 内の getPreferredSizec - エディタコンポーネント
JComponent.getPreferredSize(),
LayoutManager.preferredLayoutSize(java.awt.Container)public Dimension getMinimumSize(JComponent c)
ComponentUI 内の getMinimumSizec - エディタコンポーネント
JComponent.getMinimumSize(),
LayoutManager.minimumLayoutSize(java.awt.Container),
ComponentUI.getPreferredSize(javax.swing.JComponent)public Dimension getMaximumSize(JComponent c)
ComponentUI 内の getMaximumSizec - エディタコンポーネント
JComponent.getMaximumSize(),
LayoutManager2.maximumLayoutSize(java.awt.Container)protected Rectangle getVisibleEditorRect()
public Rectangle modelToView(JTextComponent tc,
int pos)
throws BadLocationException
TextUI 内の modelToViewtc - この UI がインストールされているテキストコンポーネントpos - 変換対象のモデル内でのローカル位置 >= 0
BadLocationException - 指定された位置が、関連するドキュメント内の 有効な位置を示さない場合TextUI.modelToView(javax.swing.text.JTextComponent, int)
public Rectangle modelToView(JTextComponent tc,
int pos,
Position.Bias bias)
throws BadLocationException
TextUI 内の modelToViewtc - この UI がインストールされているテキストコンポーネントpos - 変換対象のモデル内でのローカル位置 >= 0
BadLocationException - 指定された位置が、関連するドキュメント内の 有効な位置を示さない場合TextUI.modelToView(javax.swing.text.JTextComponent, int)
public int viewToModel(JTextComponent tc,
Point pt)
TextUI 内の viewToModeltc - この UI がインストールされているテキストコンポーネントpt - 変換対象のビューの座標系での位置。この場合の座標系は、マウスイベントと同じ座標系でなければならない
TextUI.viewToModel(javax.swing.text.JTextComponent, java.awt.Point)
public int viewToModel(JTextComponent tc,
Point pt,
Position.Bias[] biasReturn)
TextUI 内の viewToModeltc - この 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
TextUI 内の getNextVisualPositionFromt - この UI がインストールされているテキストコンポーネントpos - 変換対象の位置 >= 0b - 位置のバイアスdirection - 現在位置からの方向。これは、キーボードに通常存在する矢印キーと見なすことができ、 SwingConstants.WEST、SwingConstants.EAST、 SwingConstants.NORTH、または SwingConstants.SOUTH になるbiasRet - 返される位置のバイアスを含む配列
BadLocationException
public void damageRange(JTextComponent tc,
int p0,
int p1)
TextUI 内の damageRangetc - この 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)
TextUI 内の damageRangep0 - 範囲の始点 >= 0p1 - 範囲の終点 >= p0public EditorKit getEditorKit(JTextComponent tc)
TextUI 内の getEditorKittc - この UI がインストールされているテキストコンポーネント
TextUI.getEditorKit(javax.swing.text.JTextComponent)public View getRootView(JTextComponent tc)
注: View 階層はルートビューからトラバースすることができ、ほかのことも同様にできます。このように行われたことは、TextUI を通じた単純なメソッド呼び出しのように保護することができません。したがって、並行性の考えられる適切な操作は、このメソッドを呼び出す論理で処理が行われるようにする必要があります。
TextUI 内の getRootViewtc - この UI がインストールされているテキストコンポーネント
TextUI.getRootView(javax.swing.text.JTextComponent)
public String getToolTipText(JTextComponent t,
Point pt)
TextUI 内の getToolTipTextJTextComponent.getToolTipText(java.awt.event.MouseEvent),
View.getToolTipText(float, float, java.awt.Shape)public View create(Element elem)
ViewFactory 内の createelem - 要素
View
public View create(Element elem,
int p0,
int p1)
elem - 要素p0 - 開始オフセット <= 0p1 - 終了オフセット >= p0
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。