- java.lang.Object
-
- javax.swing.tree.AbstractLayoutCache
-
- All Implemented Interfaces:
-
RowMapper
public abstract class AbstractLayoutCache extends Object implements RowMapper
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,支持所有JavaBeans的长期存储已被添加到java.beans包中。 请参阅XMLEncoder。
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 描述 static classAbstractLayoutCache.NodeDimensions由AbstractLayoutCache用于确定特定节点的大小和x原点。
-
Field Summary
Fields Modifier and Type Field 描述 protected AbstractLayoutCache.NodeDimensionsnodeDimensions负责获取节点大小的对象。protected booleanrootVisible如果显示根节点,则为真,如果子节点是最高可见节点,则为false。protected introwHeight每行要使用的高度。protected TreeModeltreeModel模型提供信息。protected TreeSelectionModeltreeSelectionModel选择模式。
-
构造方法摘要
构造方法 Constructor 描述 AbstractLayoutCache()
-
方法摘要
所有方法 接口方法 抽象方法 具体的方法 Modifier and Type 方法 描述 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)将用于管理选择的TreeSelectionModel设置为新的LSM。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
如果显示根节点,则为真,如果子节点是最高可见节点,则为false。
-
rowHeight
protected int rowHeight
每行要使用的高度。 如果这是<= 0,则渲染器将用于确定每行的高度。
-
-
方法详细信息
-
setNodeDimensions
public void setNodeDimensions(AbstractLayoutCache.NodeDimensions nd)
设置负责绘制树中节点的渲染器,因此负责计算各个节点的维度。- 参数
-
nd- aNodeDimensions对象
-
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是否可见。- 参数
-
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)
将用于管理选择的TreeSelectionModel设置为新的LSM。- 参数
-
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为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,则会返回null,否则将始终返回有效的路径。 如果您需要测试返回的对象是否完全在x处,那么您应该获得返回路径的边界,并对其进行测试x,y。- 参数
-
x- 所需位置的水平分量 -
y- 所需位置的垂直分量 - 结果
-
最接近指定点的
TreePath
-
getVisiblePathsFrom
public abstract Enumeration<TreePath> getVisiblePathsFrom(TreePath path)
返回一个Enumerator,从传入的位置开始可见的路径递增。 枚举的顺序是基于路径的显示方式。 返回枚举的第一个元素将是路径,除非它不可见,在这种情况下将返回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()返回已更改节点的索引(es)。
- 参数
-
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中的一个TreePaths中的path不正确,则其数组中的条目应设置为-1。- Specified by:
-
getRowsForPaths在接口RowMapper - 参数
-
paths-阵列TreePathS是查询 - 结果
-
传入相同长度的数组,其中包含显示每个
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- 如果行被展开,expandedtrue,否则为false -
placeIn- aRectangle包含所需的大小代表value - 结果
-
一个
Rectangle包含节点的尺寸,或null如果节点没有尺寸
-
isFixedRowHeight
protected boolean isFixedRowHeight()
如果每行的高度是固定大小,则返回true。- 结果
- whether the height of each row is a fixed size
-
-