- java.lang.Object
-
- javax.swing.tree.AbstractLayoutCache
-
- 实现的所有接口
-
RowMapper
public abstract class AbstractLayoutCache extends Object implements RowMapper
警告:此类的序列化对象与以后的Swing版本不兼容。 当前的序列化支持适用于运行相同版本Swing的应用程序之间的短期存储或RMI。 从1.4开始,对java.beans软件包中添加了对所有JavaBeansjava.beans长期存储的支持。 请参阅XMLEncoder。
-
-
嵌套类汇总
嵌套类 变量和类型 类 描述 static classAbstractLayoutCache.NodeDimensions由AbstractLayoutCache以确定特定节点的大小和x原点。
-
字段汇总
字段 变量和类型 字段 描述 protected AbstractLayoutCache.NodeDimensionsnodeDimensions负责获取节点大小的对象。protected booleanrootVisible如果显示根节点,则为true;如果其子节点是最高可见节点,则为false。protected introwHeight每行使用的高度。protected TreeModeltreeModel提供信息的模型。protected TreeSelectionModeltreeSelectionModel选择模型。
-
构造方法摘要
构造方法 构造器 描述 AbstractLayoutCache()
-
方法摘要
所有方法 实例方法 抽象方法 具体的方法 变量和类型 方法 描述 abstract RectanglegetBounds(TreePath path, Rectangle placeIn)返回一个矩形,给出绘制路径所需的边界。abstract booleangetExpandedState(TreePath path)如果路径已展开且可见,则返回true。TreeModelgetModel()返回提供数据的TreeModel。AbstractLayoutCache.NodeDimensionsgetNodeDimensions()返回在树中呈现节点的对象,该对象负责计算各个节点的维度。protected RectanglegetNodeDimensions(Object value, int row, int depth, boolean expanded, Rectangle placeIn)通过引用placeIn返回表示value所需的大小。abstract TreePathgetPathClosestTo(int x, int y)返回最接近x,y的节点的路径。abstract TreePathgetPathForRow(int row)返回传入行的路径。intgetPreferredHeight()返回首选高度。intgetPreferredWidth(Rectangle bounds)返回传入区域的首选宽度。abstract intgetRowCount()显示的行数。abstract intgetRowForPath(TreePath path)返回路径中标识的最后一项可见的行。intgetRowHeight()返回每行的高度。int[]getRowsForPaths(TreePath[] paths)返回显示path中的TreePath实例的行。TreeSelectionModelgetSelectionModel()返回用于维护选择的模型。abstract intgetVisibleChildCount(TreePath path)返回行的可见子项数。abstract Enumeration<TreePath>getVisiblePathsFrom(TreePath path)返回一个Enumerator,它在从传入位置开始的可见路径上递增。abstract voidinvalidatePathBounds(TreePath path)指示LayoutCache,对于边界path无效,并且需要进行更新。abstract voidinvalidateSizes()通知TreeState它需要重新计算它引用的所有大小。abstract booleanisExpanded(TreePath path)如果当前展开的行标识的值,则返回true。protected booleanisFixedRowHeight()如果每行的高度是固定大小,则返回true。booleanisRootVisible()如果显示树的根节点,则返回true。abstract voidsetExpandedState(TreePath path, boolean isExpanded)将路径path标记为isExpanded。voidsetModel(TreeModel newModel)设置将提供数据的TreeModel。voidsetNodeDimensions(AbstractLayoutCache.NodeDimensions nd)设置负责绘制树中节点的渲染器,因此负责计算各个节点的尺寸。voidsetRootVisible(boolean rootVisible)确定TreeModel中的TreeModel是否可见。voidsetRowHeight(int rowHeight)设置每个单元格的高度。voidsetSelectionModel(TreeSelectionModel newLSM)设置用于管理新LSM选择的TreeSelectionModel。abstract voidtreeNodesChanged(TreeModelEvent e)在某个节点(或一组兄弟节点)以某种方式更改后调用。abstract voidtreeNodesInserted(TreeModelEvent e)节点插入树后调用。abstract voidtreeNodesRemoved(TreeModelEvent e)从树中删除节点后调用。abstract voidtreeStructureChanged(TreeModelEvent e)在树从给定节点向下彻底更改结构之后调用。
-
-
-
字段详细信息
-
nodeDimensions
protected AbstractLayoutCache.NodeDimensions nodeDimensions
负责获取节点大小的对象。
-
treeModel
protected TreeModel treeModel
提供信息的模型。
-
treeSelectionModel
protected TreeSelectionModel treeSelectionModel
选择模型。
-
rootVisible
protected boolean rootVisible
如果显示根节点,则为true;如果其子节点是最高可见节点,则为false。
-
rowHeight
protected int rowHeight
每行使用的高度。 如果<= 0,则渲染器将用于确定每行的高度。
-
-
方法详细信息
-
setNodeDimensions
public void setNodeDimensions(AbstractLayoutCache.NodeDimensions nd)
设置负责绘制树中节点的渲染器,因此负责计算各个节点的尺寸。- 参数
-
nd- 一个NodeDimensions对象
-
getNodeDimensions
public AbstractLayoutCache.NodeDimensions getNodeDimensions()
返回在树中呈现节点的对象,该对象负责计算各个节点的维度。- 结果
-
NodeDimensions对象
-
setModel
public void setModel(TreeModel newModel)
设置将提供数据的TreeModel。- 参数
-
newModel- 即提供数据的TreeModel
-
getModel
public TreeModel getModel()
返回提供数据的TreeModel。- 结果
-
提供数据的
TreeModel
-
setRootVisible
@BeanProperty(description="Whether or not the root node from the TreeModel is visible.") public void setRootVisible(boolean rootVisible)
确定TreeModel中的TreeModel是否可见。- 参数
-
rootVisible- 如果要显示树的根节点,rootVisibletrue - 另请参见:
-
rootVisible
-
isRootVisible
public boolean isRootVisible()
如果显示树的根节点,则返回true。- 结果
- 如果显示树的根节点,则为true
- 另请参见:
-
rootVisible
-
setRowHeight
@BeanProperty(description="The height of each cell.") public void setRowHeight(int rowHeight)
设置每个单元格的高度。 如果指定的值小于或等于零,则会为每行的高度查询当前单元格渲染器。- 参数
-
rowHeight- 每个单元格的高度(以像素为单位)
-
getRowHeight
public int getRowHeight()
返回每行的高度。 如果返回的值小于或等于0,则每行的高度由渲染器确定。- 结果
- 每行的高度
-
setSelectionModel
public void setSelectionModel(TreeSelectionModel newLSM)
设置用于管理新LSM选择的TreeSelectionModel。- 参数
-
newLSM- 新的TreeSelectionModel
-
getSelectionModel
public TreeSelectionModel getSelectionModel()
返回用于维护选择的模型。- 结果
-
treeSelectionModel
-
getPreferredHeight
public int getPreferredHeight()
返回首选高度。- 结果
- 首选的高度
-
getPreferredWidth
public int getPreferredWidth(Rectangle bounds)
返回传入区域的首选宽度。 该区域由最接近(bounds.x, bounds.y)的路径定义,并在bounds.height + bounds.y处bounds.height + bounds.y。 如果bounds是null,则将返回所有节点的首选宽度(这可能是非常昂贵的计算)。- 参数
-
bounds- 正在查询的区域 - 结果
- 传入区域的首选宽度
-
isExpanded
public abstract boolean isExpanded(TreePath path)
如果当前展开的行标识的值,则返回true。- 参数
-
path- 要检查的TreePath - 结果
- 是否扩展了TreePath
-
getBounds
public abstract Rectangle getBounds(TreePath path, Rectangle placeIn)
返回一个矩形,给出绘制路径所需的边界。- 参数
-
path- 指定节点的TreePath -
placeIn- 提供可用空间的Rectangle对象 - 结果
-
指定要使用的空间的
Rectangle对象
-
getPathForRow
public abstract TreePath getPathForRow(int row)
返回传入行的路径。 如果行不可见,则返回null。- 参数
-
row- 正在查询的行 - 结果
-
给定行的
TreePath
-
getRowForPath
public abstract int getRowForPath(TreePath path)
返回路径中标识的最后一项可见的行。 如果路径中的任何元素当前不可见,则返回-1。- 参数
-
path- 正在查询的TreePath - 结果
- 路径中最后一项可见的行,如果路径中的任何元素当前不可见,则为-1
-
getPathClosestTo
public abstract TreePath getPathClosestTo(int x, int y)
返回最接近x,y的节点的路径。 如果当前没有任何内容可见,则返回null,否则它将始终返回有效路径。 如果你需要测试返回的对象是否正好在x,y,你应该获得返回路径的边界并测试x,y。- 参数
-
x- 所需位置的水平分量 -
y- 所需位置的垂直分量 - 结果
-
最接近指定点的
TreePath
-
getVisiblePathsFrom
public abstract Enumeration<TreePath> getVisiblePathsFrom(TreePath path)
返回一个Enumerator,它在从传入位置开始的可见路径上递增。 枚举的顺序基于路径的显示方式。 返回枚举的第一个元素是path,除非它不可见,在这种情况下将返回null。- 参数
-
path- 枚举的起始位置 - 结果
-
Enumerator从所需位置开始
-
getVisibleChildCount
public abstract int getVisibleChildCount(TreePath path)
返回行的可见子项数。- 参数
-
path- 正在查询的路径 - 结果
- 指定路径的可见子项数
-
setExpandedState
public abstract void setExpandedState(TreePath path, boolean isExpanded)
将路径标记为path展开状态为isExpanded。- 参数
-
path- 正在展开或折叠的路径 -
isExpanded- 如果应扩展路径,isExpandedtrue,否则为false
-
getExpandedState
public abstract boolean getExpandedState(TreePath path)
如果路径已展开且可见,则返回true。- 参数
-
path- 正在查询的路径 - 结果
- 如果路径已展开且可见,则为true,否则为false
-
getRowCount
public abstract int getRowCount()
显示的行数。- 结果
- 显示的行数
-
invalidateSizes
public abstract void invalidateSizes()
通知TreeState它需要重新计算它引用的所有大小。
-
invalidatePathBounds
public abstract void invalidatePathBounds(TreePath path)
指示LayoutCache,对于边界path无效,并且需要进行更新。- 参数
-
path- 正在更新的路径
-
treeNodesChanged
public abstract void treeNodesChanged(TreeModelEvent e)
在某个节点(或一组兄弟节点)以某种方式更改后调用。 节点未更改树中的位置或更改其子阵列,但其他属性已更改并可能影响演示。 示例:文件名已更改,但它位于文件系统中的相同位置。
e.path()返回已更改节点的父节点的路径。
e.childIndices()返回已更改节点的索引。
- 参数
-
e-TreeModelEvent
-
treeNodesInserted
public abstract void treeNodesInserted(TreeModelEvent e)
节点插入树后调用。
e.path()返回新节点的父节点
e.childIndices()以升序返回新节点的索引。
- 参数
-
e-TreeModelEvent
-
treeNodesRemoved
public abstract void treeNodesRemoved(TreeModelEvent e)
从树中删除节点后调用。 请注意,如果从树中删除子树,则此方法可能仅针对已删除子树的根调用一次,而不是针对删除的每个单独兄弟集调用一次。
e.path()返回已删除节点的前父节点。
e.childIndices()返回节点在按升序删除之前的索引。
- 参数
-
e-TreeModelEvent
-
treeStructureChanged
public abstract void treeStructureChanged(TreeModelEvent e)
在树从给定节点向下彻底更改结构之后调用。 如果
e.getPath()返回的路径长度为1且第一个元素未标识当前根节点,则第一个元素应成为树的新根。e.path()保存节点的路径。
e.childIndices()返回null。
- 参数
-
e-TreeModelEvent
-
getRowsForPaths
public int[] getRowsForPaths(TreePath[] paths)
返回显示path中的TreePath实例的行。 此方法应返回与传入的数组长度相同的数组,如果TreePaths中的path之一无效,则其数组中的条目应设置为-1。- Specified by:
-
getRowsForPaths在接口RowMapper - 参数
-
paths- 正在查询的数组TreePath - 结果
-
传入的相同长度的数组,包含每个对应的行,每个行显示每个
TreePath; 如果paths是null,则返回null
-
getNodeDimensions
protected Rectangle getNodeDimensions(Object value, int row, int depth, boolean expanded, Rectangle placeIn)
通过引用在placeIn返回表示value所需的大小。 如果inPlace是null,则应返回新创建的Rectangle,否则该值应放在inPlace并返回。 如果没有渲染器,这将返回null。- 参数
-
value- 要表示的value -
row- 正在查询行 -
depth- 行的深度 -
expanded- 如果展开行,则为true,否则为false -
placeIn- 一个Rectangle其中包含表示value所需的大小 - 结果
-
一个
Rectangle包含节点的尺寸,或null如果节点没有尺寸
-
isFixedRowHeight
protected boolean isFixedRowHeight()
如果每行的高度是固定大小,则返回true。- 结果
- whether the height of each row is a fixed size
-
-