- java.lang.Object
-
- javax.swing.tree.AbstractLayoutCache
-
- javax.swing.tree.FixedHeightLayoutCache
-
- All Implemented Interfaces:
-
RowMapper
public class FixedHeightLayoutCache extends AbstractLayoutCache
注意:在将来的版本中这将变得更加开放。警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,支持所有JavaBeans的长期存储已被添加到
java.beans包中。 请参阅XMLEncoder。
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.tree.AbstractLayoutCache
AbstractLayoutCache.NodeDimensions
-
-
Field Summary
-
Fields inherited from class javax.swing.tree.AbstractLayoutCache
nodeDimensions, rootVisible, rowHeight, treeModel, treeSelectionModel
-
-
构造方法摘要
构造方法 Constructor 描述 FixedHeightLayoutCache()构造一个FixedHeightLayoutCache。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 RectanglegetBounds(TreePath path, Rectangle placeIn)返回一个给出绘制路径所需边界的矩形。booleangetExpandedState(TreePath path)如果路径被展开且可见,则返回true。TreePathgetPathClosestTo(int x, int y)返回最接近x,y的节点的路径。TreePathgetPathForRow(int row)返回在行中传递的路径。intgetRowCount()返回可见行数。intgetRowForPath(TreePath path)返回在路径中识别的最后一个项目可见的行。intgetVisibleChildCount(TreePath path)返回行的可见子项数。Enumeration<TreePath>getVisiblePathsFrom(TreePath path)返回一个枚举器,它从传入的位置开始,以可见路径递增。voidinvalidatePathBounds(TreePath path)没有什么,FixedHeightLayoutCache不缓存宽度,这是可以改变的。voidinvalidateSizes()通知TreeState需要重新计算它所引用的所有大小。booleanisExpanded(TreePath path)如果当前标识的值目前已被扩展,则返回true。voidsetExpandedState(TreePath path, boolean isExpanded)标记路径path展开状态为isExpanded。voidsetModel(TreeModel newModel)设置将提供数据的TreeModel。voidsetRootVisible(boolean rootVisible)确定TreeModel中的根节点是否可见。voidsetRowHeight(int rowHeight)设置每个单元格的高度。voidtreeNodesChanged(TreeModelEvent e)节点(或一组兄弟节点)以某种方式更改后调用。voidtreeNodesInserted(TreeModelEvent e)在节点插入到树中之后调用。voidtreeNodesRemoved(TreeModelEvent e)从树中删除节点后调用。voidtreeStructureChanged(TreeModelEvent e)在树已经从给定节点大幅度改变结构之后调用。-
Methods inherited from class javax.swing.tree.AbstractLayoutCache
getModel, getNodeDimensions, getNodeDimensions, getPreferredHeight, getPreferredWidth, getRowHeight, getRowsForPaths, getSelectionModel, isFixedRowHeight, isRootVisible, setNodeDimensions, setSelectionModel
-
-
-
-
方法详细信息
-
setModel
public void setModel(TreeModel newModel)
设置将提供数据的TreeModel。- 重写:
-
setModel在AbstractLayoutCache - 参数
-
newModel- 提供数据的TreeModel
-
setRootVisible
public void setRootVisible(boolean rootVisible)
确定TreeModel中的根节点是否可见。- 重写:
-
setRootVisible在AbstractLayoutCache - 参数
-
rootVisible- 如果要显示树的根节点,rootVisibletrue - 另请参见:
-
AbstractLayoutCache.rootVisible
-
setRowHeight
public void setRowHeight(int rowHeight)
设置每个单元格的高度。 如果rowHeight小于或等于0,则会抛出IllegalArgumentException异常。- 重写:
-
setRowHeight在AbstractLayoutCache - 参数
-
rowHeight- 每个单元格的高度,以像素为单位
-
getRowCount
public int getRowCount()
返回可见行数。- Specified by:
-
getRowCount在AbstractLayoutCache - 结果
- 正在显示的行数
-
invalidatePathBounds
public void invalidatePathBounds(TreePath path)
没有什么,FixedHeightLayoutCache不缓存宽度,这是可以改变的。- Specified by:
-
invalidatePathBounds在AbstractLayoutCache - 参数
-
path- 正在更新的路径
-
invalidateSizes
public void invalidateSizes()
通知TreeState需要重新计算它所引用的所有大小。- Specified by:
-
invalidateSizes在AbstractLayoutCache
-
isExpanded
public boolean isExpanded(TreePath path)
如果当前标识的值目前已被扩展,则返回true。- Specified by:
-
isExpanded类AbstractLayoutCache - 参数
-
path- TreePath检查 - 结果
- TreePath是否扩展
-
getBounds
public Rectangle getBounds(TreePath path, Rectangle placeIn)
返回一个给出绘制路径所需边界的矩形。- Specified by:
-
getBounds在AbstractLayoutCache - 参数
-
path- 指定节点的TreePath -
placeIn- 给出可用空间的Rectangle对象 - 结果
- 一个指定要使用的空间的Rectangle对象
-
getPathForRow
public TreePath getPathForRow(int row)
返回在行中传递的路径。 如果行不可见返回null。- Specified by:
-
getPathForRow在AbstractLayoutCache - 参数
-
row- 正在查询的行 - 结果
-
该给定行的
TreePath
-
getRowForPath
public int getRowForPath(TreePath path)
返回在路径中识别的最后一个项目可见的行。 如果路径中的任何元素当前不可见,则返回-1。- Specified by:
-
getRowForPath在AbstractLayoutCache - 参数
-
path- 被查询的TreePath - 结果
- 路径中最后一个项目可见的行或-1当路径中的任何元素当前不可见时
-
getPathClosestTo
public TreePath getPathClosestTo(int x, int y)
返回最接近x,y的节点的路径。 如果当前没有任何可见的内容,则返回null,否则返回一个有效的路径。 如果您需要测试返回的对象是否完全在x处,那么您应该获得返回路径的边界,并对其进行测试x,y。- Specified by:
-
getPathClosestTo在AbstractLayoutCache - 参数
-
x- 所需位置的水平分量 -
y- 所需位置的垂直分量 - 结果
-
最接近指定点的
TreePath
-
getVisibleChildCount
public int getVisibleChildCount(TreePath path)
返回行的可见子项数。- Specified by:
-
getVisibleChildCount在AbstractLayoutCache - 参数
-
path- 被查询的路径 - 结果
- 指定路径的可见子项数
-
getVisiblePathsFrom
public Enumeration<TreePath> getVisiblePathsFrom(TreePath path)
返回一个枚举器,它从传入的位置开始,以可见路径递增。 枚举的顺序是基于路径的显示方式。- Specified by:
-
getVisiblePathsFrom在AbstractLayoutCache - 参数
-
path- 枚举的起始位置 - 结果
-
Enumerator从所需位置开始
-
setExpandedState
public void setExpandedState(TreePath path, boolean isExpanded)
标记路径path扩展状态为isExpanded。- Specified by:
-
setExpandedState在AbstractLayoutCache - 参数
-
path- 正在扩展或折叠的路径 -
isExpanded- 如果路径应该扩展,isExpandedtrue,否则为false
-
getExpandedState
public boolean getExpandedState(TreePath path)
如果路径被展开且可见,则返回true。- Specified by:
-
getExpandedState中的AbstractLayoutCache - 参数
-
path- 被查询的路径 - 结果
- 如果路径被扩展和可见,则为true,否则为false
-
treeNodesChanged
public void treeNodesChanged(TreeModelEvent e)
节点(或一组兄弟节点)以某种方式更改后调用。 节点没有更改树中的位置或更改其子数组,但其他属性已更改,并可能影响演示。 示例:文件的名称已更改,但它位于文件系统中的相同位置。
e.path()返回已更改节点的父节点的路径。
e.childIndices()返回已更改节点的索引(es)。
- Specified by:
-
treeNodesChanged类AbstractLayoutCache - 参数
-
e-TreeModelEvent
-
treeNodesInserted
public void treeNodesInserted(TreeModelEvent e)
在节点插入到树中之后调用。
e.path()返回新节点的父节点
e.childIndices()按升序返回新节点的索引。
- Specified by:
-
treeNodesInsertedAbstractLayoutCache - 参数
-
e-TreeModelEvent
-
treeNodesRemoved
public void treeNodesRemoved(TreeModelEvent e)
从树中删除节点后调用。 请注意,如果从树中删除子树,则此方法只能针对已删除的子树的根调用一次,而对于删除的每个单独的一组兄弟,则不能一次。
e.path()返回已删除节点的前一个父节点。
e.childIndices()返回节点在按升序删除之前的索引。
- Specified by:
-
treeNodesRemoved在AbstractLayoutCache - 参数
-
e-TreeModelEvent
-
treeStructureChanged
public void treeStructureChanged(TreeModelEvent e)
在树已经从给定节点大幅度改变结构之后调用。 如果e.getPath()返回的路径长度为1,而第一个元素不标识当前根节点,则第一个元素应该成为树的新根。
e.path()保存节点的路径。
e.childIndices()返回null。
- Specified by:
-
treeStructureChanged中的AbstractLayoutCache - 参数
-
e- theTreeModelEvent
-
-