lsm tree java_BasicTreeUI

方法详细信息

createUI public static ComponentUI createUI​(JComponent x)

构造一个

BasicTreeUI的新实例。

参数

x - 一个组件

结果

BasicTreeUI的新实例

getHashColor protected Color getHashColor()

返回散列颜色。

结果

哈希颜色

setHashColor protected void setHashColor​(Color color)

设置哈希颜色。

参数

color - 哈希颜色

setLeftChildIndent public void setLeftChildIndent​(int newAmount)

设置左子缩进。

参数

newAmount - 左侧儿童缩进

getLeftChildIndent public int getLeftChildIndent()

返回左子缩进。

结果

左边的孩子缩进

setRightChildIndent public void setRightChildIndent​(int newAmount)

设置正确的子缩进。

参数

newAmount - 正确的儿童缩进

getRightChildIndent public int getRightChildIndent()

返回正确的子缩进。

结果

合适的孩子缩进

setExpandedIcon public void setExpandedIcon​(Icon newG)

设置展开的图标。

参数

newG - 展开的图标

getExpandedIcon public Icon getExpandedIcon()

返回展开的图标。

结果

展开的图标

setCollapsedIcon public void setCollapsedIcon​(Icon newG)

设置折叠图标。

参数

newG - 折叠图标

getCollapsedIcon public Icon getCollapsedIcon()

返回折叠的图标。

结果

折叠的图标

setLargeModel protected void setLargeModel​(boolean largeModel)

如有必要,更新componentListener。

参数

largeModel - 新值

isLargeModel protected boolean isLargeModel()

如果设置了大型模型,则返回

true 。

结果

true如果设置了大型模型

setRowHeight protected void setRowHeight​(int rowHeight)

设置行高,将其转发到treeState。

参数

rowHeight - 行高

getRowHeight protected int getRowHeight()

返回行高。

结果

行高

setCellRenderer protected void setCellRenderer​(TreeCellRenderer tcr)

将TreeCellRenderer设置为tcr 。

这会调用updateRenderer 。

参数

tcr - 新值

getCellRenderer protected TreeCellRenderer getCellRenderer()

返回

currentCellRenderer ,它将是树渲染器,或

defaultCellRenderer ,它们不是null。

结果

TreeCellRenderer一个实例

setModel protected void setModel​(TreeModel model)

设置

TreeModel 。

参数

model - 新值

getModel protected TreeModel getModel()

返回树模型。

结果

树模型

setRootVisible protected void setRootVisible​(boolean newValue)

将根设置为可见。

参数

newValue - 新值

isRootVisible protected boolean isRootVisible()

如果树根可见,则返回

true 。

结果

true如果树根可见

setShowsRootHandles protected void setShowsRootHandles​(boolean newValue)

确定是否显示节点句柄。

参数

newValue - 新值

getShowsRootHandles protected boolean getShowsRootHandles()

如果要显示根句柄,则返回

true 。

结果

true如果要显示根句柄

setCellEditor protected void setCellEditor​(TreeCellEditor editor)

设置单元格编辑器。

参数

editor - 新的单元格编辑器

getCellEditor protected TreeCellEditor getCellEditor()

返回

TreeCellEditor的实例。

结果

TreeCellEditor一个实例

setEditable protected void setEditable​(boolean newValue)

配置接收器允许或不允许编辑。

参数

newValue - 新值

isEditable protected boolean isEditable()

如果树可编辑,则返回

true 。

结果

true树是否可编辑

setSelectionModel protected void setSelectionModel​(TreeSelectionModel newLSM)

重置选择模型。

适当的侦听器安装在模型上。

参数

newLSM - 新的选择模型

getSelectionModel protected TreeSelectionModel getSelectionModel()

返回树选择模型。

结果

树选择模型

getPathBounds public Rectangle getPathBounds​(JTree tree,

TreePath path)

返回包含将绘制路径中最后一项的标签部分的Rectangle。

如果路径中的任何组件当前有效,则返回null。

Specified by:

参数

tree -

JTree的

path

path - 标识节点的

TreePath

结果

Rectangle包含将绘制路径中最后一项的标签部分,如果路径中的任何组件当前有效,

null 。

getPathForRow public TreePath getPathForRow​(JTree tree,

int row)

返回传入行的路径。

如果row不可见,则返回null。

Specified by:

参数

tree -

JTree对象

row - 指定行的整数

结果

path为

row或

null如果

row不可见

getRowForPath public int getRowForPath​(JTree tree,

TreePath path)

返回路径中标识的最后一项可见的行。

如果路径中的任何元素当前不可见,则返回-1。

Specified by:

参数

tree -

JTree for

path

path - 要查看的

TreePath对象

结果

指定标识最后一项的行的整数,如果

path中的任何元素当前不可见,则返回-1

getRowCount public int getRowCount​(JTree tree)

返回正在显示的行数。

Specified by:

参数

tree - 要为其计数行的

JTree

结果

一个整数,指定要显示的行数

getClosestPathForLocation public TreePath getClosestPathForLocation​(JTree tree,

int x,

int y)

返回最接近x,y的节点的路径。

如果当前没有任何内容可见,则返回null,否则它将始终返回有效路径。

如果你需要测试返回的对象是否正好在x,y,你应该获得返回路径的边界并测试x,y。

Specified by:

参数

tree -

JTree对象

x - 一个整数,给出显示区域左边缘水平的像素数

y - 一个整数,给出显示区域顶部垂直的像素数,减去任何上边距

结果

TreePath节点最接近

x,y或

null如果当前没有任何可见

isEditing public boolean isEditing​(JTree tree)

如果正在编辑树,则返回true。

getEditingPath()可以返回正在编辑的项目。

Specified by:

参数

tree -

JTree对象

结果

如果正在编辑

tree则为true

stopEditing public boolean stopEditing​(JTree tree)

停止当前的编辑会话。

如果未编辑树,则无效。

如果编辑器允许编辑会话停止,则返回true。

Specified by:

参数

tree -

JTree对象

结果

如果编辑器允许编辑会话停止,则为true

cancelEditing public void cancelEditing​(JTree tree)

取消当前编辑会话。

Specified by:

参数

tree -

JTree对象

startEditingAtPath public void startEditingAtPath​(JTree tree,

TreePath path)

选择路径中的最后一项并尝试编辑它。

如果CellEditor不允许编辑所选项目,编辑将失败。

Specified by:

参数

tree - 正在编辑的

JTree

path - 要编辑的

TreePath

getEditingPath public TreePath getEditingPath​(JTree tree)

返回正在编辑的元素的路径。

Specified by:

参数

tree - 要返回路径的

JTree

结果

一个

TreePath包含路径

tree

prepareForUIInstall protected void prepareForUIInstall()

在设置

tree实例变量之后但在安装任何默认值/侦听器之前调用。

completeUIInstall protected void completeUIInstall()

安装完所有默认值/侦听器后从installUI调用。

installDefaults protected void installDefaults()

安装默认属性。

installListeners protected void installListeners()

注册听众。

installKeyboardActions protected void installKeyboardActions()

注册键盘操作。

installComponents protected void installComponents()

Intall树的子组件,即渲染器窗格。

createNodeDimensions

创建

NodeDimensions的实例,该实例能够确定树中给定节点的大小。

结果

NodeDimensions一个实例

createPropertyChangeListener protected PropertyChangeListener createPropertyChangeListener()

创建一个负责的监听器,根据树的更改方式更新UI。

结果

PropertyChangeListener一个实例

createMouseListener protected MouseListener createMouseListener()

创建负责根据鼠标事件更新选择的侦听器。

结果

MouseListener一个实例

createFocusListener protected FocusListener createFocusListener()

创建一个监听器,负责在丢失/获得焦点时更新显示。

结果

FocusListener一个实例

createKeyListener protected KeyListener createKeyListener()

创建负责从树中获取关键事件的侦听器。

结果

KeyListener一个实例

createSelectionModelPropertyChangeListener protected PropertyChangeListener createSelectionModelPropertyChangeListener()

创建负责从选择模型获取属性更改事件的侦听器。

结果

PropertyChangeListener一个实例

createTreeSelectionListener protected TreeSelectionListener createTreeSelectionListener()

创建基于选择更改方法更新显示的侦听器。

结果

TreeSelectionListener一个实例

createCellEditorListener protected CellEditorListener createCellEditorListener()

创建一个侦听器来处理当前编辑器中的事件。

结果

CellEditorListener一个实例

createComponentListener protected ComponentListener createComponentListener()

创建并返回一个新的ComponentHandler。

这用于大型模型,以在组件移动时将validCachedPreferredSize标记为无效。

结果

ComponentListener一个实例

createTreeExpansionListener protected TreeExpansionListener createTreeExpansionListener()

当节点扩展状态更改时,创建并返回负责更新treestate的对象。

结果

TreeExpansionListener一个实例

createLayoutCache protected AbstractLayoutCache createLayoutCache()

创建负责管理扩展内容的对象以及节点的大小。

结果

负责管理扩展内容的对象

createCellRendererPane protected CellRendererPane createCellRendererPane()

返回放置渲染器组件的渲染器窗格。

结果

CellRendererPane一个实例

createDefaultCellEditor protected TreeCellEditor createDefaultCellEditor()

创建默认单元格编辑器。

结果

默认的单元格编辑器

createDefaultCellRenderer protected TreeCellRenderer createDefaultCellRenderer()

返回用于对每个节点进行标记的默认单元格渲染器。

结果

TreeCellRenderer一个实例

createTreeModelListener protected TreeModelListener createTreeModelListener()

返回一个侦听器,可以在模型更改时更新树。

结果

TreeModelListener一个实例。

prepareForUIUninstall protected void prepareForUIUninstall()

在安装UI之前调用。

completeUIUninstall protected void completeUIUninstall()

卸载UI。

uninstallDefaults protected void uninstallDefaults()

卸载默认属性。

uninstallListeners protected void uninstallListeners()

取消注册听众。

uninstallKeyboardActions protected void uninstallKeyboardActions()

取消注册键盘操作。

uninstallComponents protected void uninstallComponents()

卸载渲染器窗格。

getBaseline public int getBaseline​(JComponent c,

int width,

int height)

返回基线。

重写:

参数

c -

JComponent正在申请基线

width - 获取基线的宽度

height - 获取基线的高度

结果

基线或值<0表示没有合理的基线

异常

从以下版本开始:

1.6

另请参见:

getBaselineResizeBehavior

返回一个枚举,指示组件的基线如何随大小的变化而变化。

isDropLine protected boolean isDropLine​(JTree.DropLocation loc)

告知DropLocation是否应由节点之间的线指示。

这适用于javax.swing.DropMode.INSERT和javax.swing.DropMode.ON_OR_INSERT丢弃模式。

参数

loc - a

DropLocation

结果

true如果放置位置应显示为一条线

从以下版本开始:

1.7

paintDropLine protected void paintDropLine​(Graphics g)

画下线。

参数

g -

Graphics要绘制的对象

从以下版本开始:

1.7

getDropLineRect protected Rectangle getDropLineRect​(JTree.DropLocation loc)

返回下拉线的无限制框。

参数

loc - a

DropLocation

结果

下拉线的边界框

从以下版本开始:

1.7

paintHorizontalPartOfLeg protected void paintHorizontalPartOfLeg​(Graphics g,

Rectangle clipBounds,

Insets insets,

Rectangle bounds,

TreePath path,

int row,

boolean isExpanded,

boolean hasBeenExpanded,

boolean isLeaf)

涂抹腿部的水平部分。

接收方不应修改clipBounds或insets 。

注意:如果根不可见,则parentRow可以为-1。

参数

g - 图形上下文

clipBounds - 剪裁的矩形

insets - 内

insets

bounds - 一个边界矩形

path - 树路径

row - 一排

isExpanded -

true如果路径已展开

hasBeenExpanded -

true如果路径已展开

isLeaf -

true如果路径是叶子

paintVerticalPartOfLeg protected void paintVerticalPartOfLeg​(Graphics g,

Rectangle clipBounds,

Insets insets,

TreePath path)

涂抹腿部的垂直部分。

该接收器不应修改clipBounds , insets 。

参数

g - 图形上下文

clipBounds - 剪裁的矩形

insets - insets

path - 树路径

paintExpandControl protected void paintExpandControl​(Graphics g,

Rectangle clipBounds,

Insets insets,

Rectangle bounds,

TreePath path,

int row,

boolean isExpanded,

boolean hasBeenExpanded,

boolean isLeaf)

绘制一行的展开(切换)部分。

接收方不应修改clipBounds或insets 。

参数

g - 图形上下文

clipBounds - 剪裁的矩形

insets - 内

insets

bounds - 一个边界矩形

path - 树路径

row - 一排

isExpanded -

true如果路径已展开

hasBeenExpanded -

true如果路径已展开

isLeaf -

true如果行是叶子

paintRow protected void paintRow​(Graphics g,

Rectangle clipBounds,

Insets insets,

Rectangle bounds,

TreePath path,

int row,

boolean isExpanded,

boolean hasBeenExpanded,

boolean isLeaf)

绘制一行的渲染器部分。

接收方不应修改clipBounds或insets 。

参数

g - 图形上下文

clipBounds - 剪裁的矩形

insets - 内

insets

bounds - 一个边界矩形

path - 树路径

row - 一排

isExpanded -

true如果路径已展开

hasBeenExpanded -

true如果路径已展开

isLeaf -

true如果路径是叶子

shouldPaintExpandControl protected boolean shouldPaintExpandControl​(TreePath path,

int row,

boolean isExpanded,

boolean hasBeenExpanded,

boolean isLeaf)

如果应为指定行绘制展开(切换)控件,则返回

true 。

参数

path - 树路径

row - 一排

isExpanded -

true如果路径已展开

hasBeenExpanded -

true如果路径已展开

isLeaf -

true如果行是叶子

结果

true是否应为指定行绘制展开(切换)控件

paintVerticalLine protected void paintVerticalLine​(Graphics g,

JComponent c,

int x,

int top,

int bottom)

画一条垂直线。

参数

g - 图形上下文

c - 组件

x - X坐标

top - Y1坐标

bottom - Y2坐标

paintHorizontalLine protected void paintHorizontalLine​(Graphics g,

JComponent c,

int y,

int left,

int right)

画一条水平线。

参数

g - 图形上下文

c - 一个组件

y - Y坐标

left - X1坐标

right - X2坐标

getVerticalLegBuffer protected int getVerticalLegBuffer()

节点之间的腿的垂直元素默认从父节点的底部开始。

这种方法使腿部开始低于此值。

结果

垂直腿缓冲

getHorizontalLegBuffer protected int getHorizontalLegBuffer()

默认情况下,节点之间的支路的水平元素从子节点的左侧开始。

这种方法在此之前使腿部结束。

结果

水平腿缓冲

drawCentered protected void drawCentered​(Component c,

Graphics graphics,

Icon icon,

int x,

int y)

绘制以(x,y)为中心的

icon 。

参数

c - 组件

graphics - 图形上下文

icon - 一个图标

x - X坐标

y - Y坐标

drawDashedHorizontalLine protected void drawDashedHorizontalLine​(Graphics g,

int y,

int x1,

int x2)

画一条水平虚线。

假设x1 <= x2 。

如果x1大于x2 ,则该方法不提取任何内容。

参数

g -实例

Graphics

y - Y坐标

x1 - X1坐标

x2 - X2坐标

drawDashedVerticalLine protected void drawDashedVerticalLine​(Graphics g,

int x,

int y1,

int y2)

画一条垂直虚线。

假定为y1 <= y2 。

如果y1大于y2 ,则该方法不提取任何内容。

参数

g -实例

Graphics

x - X坐标

y1 - Y1坐标

y2 - Y2坐标

getRowX protected int getRowX​(int row,

int depth)

返回沿x轴的位置,以呈现特定的行。

返回值不包括JTree上指定的任何Insets。

这不会检查行或深度的有效性,假设它是正确的,并且如果行或深度与树的行或深度不匹配,则不会抛出异常。

参数

row - 要返回x位置的行

depth - 行的深度

结果

相当于缩进给定行的数量。

从以下版本开始:

1.5

updateLayoutCacheExpandedNodes protected void updateLayoutCacheExpandedNodes()

使所有在JTree中扩展的节点在LayoutCache中扩展。

这将使用根路径调用updateExpandedDescendants。

updateExpandedDescendants protected void updateExpandedDescendants​(TreePath path)

通过从树中获取展开的后代并转发到树状态来更新

path的所有后代的展开状态。

参数

path - 树路径

getLastChildPath protected TreePath getLastChildPath​(TreePath parent)

返回最后一个子项

parent的路径。

参数

parent - 树路径

结果

最后一个孩子的路径

parent

updateDepthOffset protected void updateDepthOffset()

更新每个深度应该偏移的程度。

updateCellEditor protected void updateCellEditor()

根据我们所包含的JTree的可编辑性更新cellEditor。如果树是可编辑的但没有cellEditor,则将使用基本树。

updateRenderer protected void updateRenderer()

当渲染器发生变化时,我们从树中传来消息。

configureLayoutCache protected void configureLayoutCache()

根据我们提供外观的树重置TreeState实例。

updateSize protected void updateSize()

将缓存的大小标记为无效,并使用

treeDidChange向树发送消息。

updateCachedPreferredSize protected void updateCachedPreferredSize()

更新preferredSize实例变量,该变量从getPreferredSize()返回。

对于从左到右的方向,大小由当前的AbstractLayoutCache确定。 对于RTL方向,首选大小变为宽度减去最小x位置。

pathWasExpanded protected void pathWasExpanded​(TreePath path)

VisibleTreeNode后从

VisibleTreeNode消息。

参数

path - 树路径

pathWasCollapsed protected void pathWasCollapsed​(TreePath path)

它崩溃后从

VisibleTreeNode消息。

参数

path - 树路径

ensureRowsAreVisible protected void ensureRowsAreVisible​(int beginRow,

int endRow)

确保

beginRow至

endRow标识的行可见。

参数

beginRow - 开始行

endRow - 结束行

setPreferredMinSize public void setPreferredMinSize​(Dimension newSize)

设置首选最小大小。

参数

newSize - 新的首选大小

getPreferredMinSize public Dimension getPreferredMinSize()

返回最小首选大小。

结果

最小首选尺寸

getPreferredSize public Dimension getPreferredSize​(JComponent c,

boolean checkConsistency)

返回表示c中树的首选大小。

如果checkConsistency为true则首先true checkConsistency消息。

参数

c - 一个组件

checkConsistency - 如果检查

true一致性

结果

表示组件中树的首选大小

getMaximumSize public Dimension getMaximumSize​(JComponent c)

返回此组件的最大大小,如果实例当前位于JTree中,则该大小将是首选大小,或0,0。

completeEditing protected void completeEditing()

用于停止编辑会话的消息。

如果接收器提供的外观和感觉从getInvokesStopCellEditing返回true,则将在当前编辑器上调用stopCellEditing。

然后,completeEditing将显示false,true,false消息,以取消任何延迟编辑。

completeEditing protected void completeEditing​(boolean messageStop,

boolean messageCancel,

boolean messageTree)

停止编辑会话。

如果messageStop为true编辑器中传递消息与stopEditing ,如果messageCancel为true编辑器中传递消息与cancelEditing 。

如果messageTree是true向treeModel消息valueForPathChanged 。

参数

messageStop - 要停止编辑的消息

messageCancel - 取消编辑的消息

messageTree - 树的消息

startEditing protected boolean startEditing​(TreePath path,

MouseEvent event)

如果有cellEditor和shouldSelectCell返回true将开始编辑节点。

这假定路径有效且可见。

参数

path - 树路径

event - 鼠标事件

结果

true如果编辑成功

checkForClickInExpandControl protected void checkForClickInExpandControl​(TreePath path,

int mouseX,

int mouseY)

如果

mouseX和

mouseY都在的展开/折叠区域

row ,这将切换行。

参数

path - 树路径

mouseX - X坐标

mouseY - Y坐标

isLocationInExpandControl protected boolean isLocationInExpandControl​(TreePath path,

int mouseX,

int mouseY)

返回

true如果

mouseX和

mouseY下降,用于展开/折叠节点和节点的行的区域

row不代表叶子。

参数

path - 树路径

mouseX - X坐标

mouseY - Y坐标

结果

true如果鼠标光标落在用于展开/折叠节点且该节点不是叶子的行区域中。

handleExpandControlClick protected void handleExpandControlClick​(TreePath path,

int mouseX,

int mouseY)

当用户单击特定行时发送消息,这将调用

toggleExpandState 。

参数

path - 树路径

mouseX - X坐标

mouseY - Y坐标

toggleExpandState protected void toggleExpandState​(TreePath path)

如果未展开,则展开路径;如果展开,则展开行。

如果扩张的路径和JTree上扩大卷轴, ensureRowsAreVisible被调用,以尽可能多的孩子滚动到尽可能可见(试图滚动到路径的最后一个可见的后代)。

参数

path - 树路径

isToggleSelectionEvent protected boolean isToggleSelectionEvent​(MouseEvent event)

返回

true表示节点上的鼠标事件应该仅切换鼠标

true的选择。

参数

event - 鼠标事件

结果

true如果节点上的鼠标事件应切换选择

isMultiSelectEvent protected boolean isMultiSelectEvent​(MouseEvent event)

返回

true表示节点上的鼠标事件应从锚点中选择。

参数

event - 鼠标事件

结果

true如果节点上的鼠标事件应从锚点中选择

isToggleEvent protected boolean isToggleEvent​(MouseEvent event)

返回true表示应根据事件切换鼠标下的行。

这是在checkForClickInExpandControl之后调用的,这意味着该位置不在扩展(切换)控件中。

参数

event - 鼠标事件

结果

true如果应该切换鼠标下的行

selectPathForEvent protected void selectPathForEvent​(TreePath path,

MouseEvent event)

消息传递基于特定行的MouseEvent更新选择。

如果事件是切换选择事件,则选择或取消选择该行。

如果事件标识多选事件,则从锚点更新选择。

否则,将选择该行,如果事件指定了切换事件,则行将展开/折叠。

参数

path - 所选路径

event - 鼠标事件

isLeaf protected boolean isLeaf​(int row)

返回

true如果在节点

row是叶。

参数

row - 一排

结果

true如果在节点

row是叶

updateLeadSelectionRow protected void updateLeadSelectionRow()

更新选择的前导行。

从以下版本开始:

1.7

getLeadSelectionRow protected int getLeadSelectionRow()

返回选择的前导行。

结果

选择引导行

从以下版本开始:

1.7

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值