JavaTM Platform
Standard Ed. 6

javax.swing.plaf.metal
クラス MetalTreeUI

java.lang.Object
  上位を拡張 javax.swing.plaf.ComponentUI
      上位を拡張 javax.swing.plaf.TreeUI
          上位を拡張 javax.swing.plaf.basic.BasicTreeUI
              上位を拡張 javax.swing.plaf.metal.MetalTreeUI

public class MetalTreeUI
extends BasicTreeUI

TreeUI の Metal Look & Feel による実装です。

MetalTreeUI がノード間の間隔と輪郭を可視的に描画する方法を構成できるようにします。次のヒントをサポートします。

斜線

子と親を結ぶ線が描かれる。ルートノードの処理については、JTree.setRootVisible(boolean) および JTree.setShowsRootHandles(boolean) を参照

水平線

ルートノードの子を区分する水平線が描かれる

なし

ノード間に視覚的な指示を与える線を描かない

通常、JTree から TreeUI を取得して MetalTreeUI のインスタンスにキャストするのは実際的な方法ではないので、クライアントプロパティー JTree.lineStyle を使ってこのプロパティーを有効にします。たとえば、Horizontal スタイルに切り替えるには、tree.putClientProperty("JTree.lineStyle", "Horizontal"); を実行します。 

デフォルトは Angled です。


入れ子のクラスの概要
 
クラス javax.swing.plaf.basic.BasicTreeUI から継承された入れ子のクラス/インタフェース
BasicTreeUI.CellEditorHandler, BasicTreeUI.ComponentHandler, BasicTreeUI.FocusHandler, BasicTreeUI.KeyHandler, BasicTreeUI.MouseHandler, BasicTreeUI.MouseInputHandler, BasicTreeUI.NodeDimensionsHandler, BasicTreeUI.PropertyChangeHandler, BasicTreeUI.SelectionModelPropertyChangeHandler, BasicTreeUI.TreeCancelEditingAction, BasicTreeUI.TreeExpansionHandler, BasicTreeUI.TreeHomeAction, BasicTreeUI.TreeIncrementAction, BasicTreeUI.TreeModelHandler, BasicTreeUI.TreePageAction, BasicTreeUI.TreeSelectionHandler, BasicTreeUI.TreeToggleAction, BasicTreeUI.TreeTraverseAction
 
フィールドの概要
 
クラス javax.swing.plaf.basic.BasicTreeUI から継承されたフィールド
cellEditor, collapsedIcon, createdCellEditor, createdRenderer, currentCellRenderer, depthOffset, drawingCache, editingComponent, editingPath, editingRow, editorHasDifferentSize, expandedIcon, largeModel, lastSelectedRow, leftChildIndent, nodeDimensions, preferredMinSize, preferredSize, rendererPane, rightChildIndent, stopEditingInCompleteEditing, totalChildIndent, tree, treeModel, treeSelectionModel, treeState, validCachedPreferredSize
 
コンストラクタの概要
MetalTreeUI()
           
 
メソッドの概要
static ComponentUI createUI(JComponent x)
           
protected  void decodeLineStyle(Object lineStyleFlag)
          クライアントプロパティーに渡された文字列と内部表現 (currently および int) との間の変換を行います。
protected  int getHorizontalLegBuffer()
          ノード間の脚の水平要素は、デフォルトでは子ノードの左側の右で始まります。
 void installUI(JComponent c)
          Look & Feel に適した、指定されたコンポーネントを構成します。
protected  boolean isLocationInExpandControl(int row, int rowLevel, int mouseX, int mouseY)
           
 void paint(Graphics g, JComponent c)
          Look &Feel に適した、指定されたコンポーネントをペイントします。
protected  void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
          脚の水平部分をペイントします。
protected  void paintHorizontalSeparators(Graphics g, JComponent c)
           
protected  void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)
          脚の垂直部分をペイントします。
 void uninstallUI(JComponent c)
          installUI 時に、指定されたコンポーネントで構成された内容を取り消します。
 
クラス javax.swing.plaf.basic.BasicTreeUI から継承されたメソッド
cancelEditing, checkForClickInExpandControl, completeEditing, completeEditing, completeUIInstall, completeUIUninstall, configureLayoutCache, createCellEditorListener, createCellRendererPane, createComponentListener, createDefaultCellEditor, createDefaultCellRenderer, createFocusListener, createKeyListener, createLayoutCache, createMouseListener, createNodeDimensions, createPropertyChangeListener, createSelectionModelPropertyChangeListener, createTreeExpansionListener, createTreeModelListener, createTreeSelectionListener, drawCentered, drawDashedHorizontalLine, drawDashedVerticalLine, ensureRowsAreVisible, getBaseline, getBaselineResizeBehavior, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getEditingPath, getExpandedIcon, getHashColor, getLastChildPath, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathBounds, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getRowX, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installDefaults, installKeyboardActions, installListeners, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isMultiSelectEvent, isRootVisible, isToggleEvent, isToggleSelectionEvent, paintExpandControl, paintHorizontalLine, paintRow, paintVerticalLine, pathWasCollapsed, pathWasExpanded, prepareForUIInstall, prepareForUIUninstall, selectPathForEvent, setCellEditor, setCellRenderer, setCollapsedIcon, setEditable, setExpandedIcon, setHashColor, setLargeModel, setLeftChildIndent, setModel, setPreferredMinSize, setRightChildIndent, setRootVisible, setRowHeight, setSelectionModel, setShowsRootHandles, shouldPaintExpandControl, startEditing, startEditingAtPath, stopEditing, toggleExpandState, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateRenderer, updateSize
 
クラス javax.swing.plaf.ComponentUI から継承されたメソッド
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

MetalTreeUI

public MetalTreeUI()
メソッドの詳細

createUI

public static ComponentUI createUI(JComponent x)

getHorizontalLegBuffer

protected int getHorizontalLegBuffer()
クラス BasicTreeUI の記述:
ノード間の脚の水平要素は、デフォルトでは子ノードの左側の右で始まります。このメソッドは、脚がそれより前で終わるようにします。

オーバーライド:
クラス BasicTreeUI 内の getHorizontalLegBuffer

installUI

public void installUI(JComponent c)
クラス ComponentUI の記述:
Look & Feel に適した、指定されたコンポーネントを構成します。このメソッドは、ComponentUI インスタンスが、指定されたコンポーネントの UI 委譲としてインストールされているときに呼び出されます。このメソッドは、次を含む Look & Feel 用のコンポーネントを完全に構成する必要があります。
  1. カラー、フォント、ボーダー、アイコン、不透明さなどすべてのデフォルトプロパティーの値をコンポーネントにインストールする。可能な場合は、クライアントプログラムによって初期化されたプロパティーの値をオーバーライドしてはならない
  2. 必要に応じて、コンポーネントに LayoutManager をインストールする
  3. 必要なサブコンポーネントを、コンポーネントに作成または追加する
  4. イベントリスナーを、コンポーネントに作成またはインストールする
  5. コンポーネントのプロパティーの変更を適切に検出し、応答するために、PropertyChangeListener をコンポーネントに作成またはインストールする
  6. キーボード UI (ニーモニック、トラバーサルなど) を、コンポーネントにインストールする
  7. 適切なインスタンスのデータを初期化する

オーバーライド:
クラス BasicTreeUI 内の installUI
パラメータ:
c - UI 委譲がインストールされているコンポーネント
関連項目:
ComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

uninstallUI

public void uninstallUI(JComponent c)
クラス ComponentUI の記述:
installUI 時に、指定されたコンポーネントで構成された内容を取り消します。このメソッドは、指定されたコンポーネントの UI 委譲としての UIComponent インスタンスが削除されているときに呼び出されます。このメソッドは、installUI によって実行された構成を元に戻す必要があります。この場合、JComponent インスタンスをクリーンな状態 (余分なリスナーや、Look & Feel 固有のプロパティーオブジェクトが残らないように) にするよう十分注意してください。手順には次のものがあります。
  1. UI として設定されたすべてのボーダーを、コンポーネントから削除する
  2. UI として設定されたすべてのレイアウトマネージャーを、コンポーネントから削除する
  3. UI として追加されたすべてのサブコンポーネントを、コンポーネントから削除する
  4. UI として追加されたすべてのイベント/リスナーを、コンポーネントから削除する
  5. UI としてインストールされたすべてのキーボード UI を、コンポーネントから削除する
  6. GC 用に割り当てられたすべてのインスタンスのデータオブジェクトを無効にする

オーバーライド:
クラス BasicTreeUI 内の uninstallUI
パラメータ:
c - この UI 委譲を削除するコンポーネント。 この引数は通常無視されるが、 UI オブジェクトに状態がなく、複数のコンポーネントに共有されている場合は 使用されることがある
関連項目:
ComponentUI.installUI(javax.swing.JComponent), JComponent.updateUI()

decodeLineStyle

protected void decodeLineStyle(Object lineStyleFlag)
クライアントプロパティーに渡された文字列と内部表現 (currently および int) との間の変換を行います。


isLocationInExpandControl

protected boolean isLocationInExpandControl(int row,
                                            int rowLevel,
                                            int mouseX,
                                            int mouseY)

paint

public void paint(Graphics g,
                  JComponent c)
クラス ComponentUI の記述:
Look &Feel に適した、指定されたコンポーネントをペイントします。このメソッドは ComponentUI.update メソッドから、指定されたコンポーネントがペイントされるときに呼び出されます。サブクラスは、このメソッドをオーバーライドして、指定された Graphics オブジェクトを使ってコンポーネントの内容を描画する必要があります。

オーバーライド:
クラス BasicTreeUI 内の paint
パラメータ:
g - ペイント対象の Graphics コンテキスト
c - ペイントされるコンポーネント。 この引数は通常無視されるが、 UI オブジェクトに状態がなく、複数のコンポーネントに共有されている場合は 使用されることがある
関連項目:
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)

paintHorizontalSeparators

protected void paintHorizontalSeparators(Graphics g,
                                         JComponent c)

paintVerticalPartOfLeg

protected void paintVerticalPartOfLeg(Graphics g,
                                      Rectangle clipBounds,
                                      Insets insets,
                                      TreePath path)
クラス BasicTreeUI の記述:
脚の垂直部分をペイントします。レシーバは、clipBoundsinsets を変更することは許されません。

オーバーライド:
クラス BasicTreeUI 内の paintVerticalPartOfLeg

paintHorizontalPartOfLeg

protected void paintHorizontalPartOfLeg(Graphics g,
                                        Rectangle clipBounds,
                                        Insets insets,
                                        Rectangle bounds,
                                        TreePath path,
                                        int row,
                                        boolean isExpanded,
                                        boolean hasBeenExpanded,
                                        boolean isLeaf)
クラス BasicTreeUI の記述:
脚の水平部分をペイントします。レシーバは、clipBoundsinsets を変更することは許されません。

注:ルートが可視でない場合、parentRow は -1 になることがあります。

オーバーライド:
クラス BasicTreeUI 内の paintHorizontalPartOfLeg

JavaTM Platform
Standard Ed. 6

バグの報告と機能のリクエスト
さらに詳しい API リファレンスおよび開発者ドキュメントについては、Java SE 開発者用ドキュメントを参照してください。開発者向けの詳細な解説、概念の概要、用語の定義、バグの回避策、およびコード実例が含まれています。

Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。