- java.lang.Object
-
- javax.swing.tree.AbstractLayoutCache
-
- javax.swing.tree.VariableHeightLayoutCache
-
- All Implemented Interfaces:
-
RowMapper
public class VariableHeightLayoutCache 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 描述 VariableHeightLayoutCache()构造一个VariableHeightLayoutCache。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 RectanglegetBounds(TreePath path, Rectangle placeIn)返回Rectangle它包围在其中所确定的项目的标签部path将被绘制。booleangetExpandedState(TreePath path)如果路径被展开且可见,则返回true。TreePathgetPathClosestTo(int x, int y)返回最接近x,y的节点的路径。TreePathgetPathForRow(int row)返回row的路径。intgetPreferredHeight()返回首选高度。intgetPreferredWidth(Rectangle bounds)返回visibleRegion该区域的首选宽度和高度。intgetRowCount()返回可见行数。intgetRowForPath(TreePath path)返回路径中识别的最后一个项目可见的行。intgetVisibleChildCount(TreePath path)返回path的可见子path。Enumeration<TreePath>getVisiblePathsFrom(TreePath path)返回一个Enumerator,从传入的位置开始可见的路径递增。voidinvalidatePathBounds(TreePath path)指示LayoutCache,对于边界path是无效的,并需要进行更新。voidinvalidateSizes()通知TreeState它需要重新计算它所引用的所有大小。booleanisExpanded(TreePath path)如果path标识的值目前已被扩展,则返回true。voidsetExpandedState(TreePath path, boolean isExpanded)标记路径path扩展状态为isExpanded。voidsetModel(TreeModel newModel)设置将提供数据的TreeModel。voidsetNodeDimensions(AbstractLayoutCache.NodeDimensions nd)设置负责在树中绘制节点的渲染器。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, getRowHeight, getRowsForPaths, getSelectionModel, isFixedRowHeight, isRootVisible, setSelectionModel
-
-
-
-
方法详细信息
-
setModel
@BeanProperty(description="The TreeModel that will provide the data.") public void setModel(TreeModel newModel)
设置将提供数据的TreeModel。- 重写:
-
setModel中的AbstractLayoutCache - 参数
-
newModel- 这是提供数据的TreeModel
-
setRootVisible
@BeanProperty(description="Whether or not the root node from the TreeModel is visible.") public void setRootVisible(boolean rootVisible)
确定TreeModel中的TreeModel是否可见。- 重写:
-
setRootVisible在AbstractLayoutCache - 参数
-
rootVisible- 如果要显示树的根节点,rootVisibletrue - 另请参见:
-
AbstractLayoutCache.rootVisible
-
setRowHeight
@BeanProperty(description="The height of each cell.") public void setRowHeight(int rowHeight)
设置每个单元格的高度。 如果指定的值小于或等于零,则会查询当前单元格渲染器对于每一行的高度。- 重写:
-
setRowHeight在AbstractLayoutCache - 参数
-
rowHeight- 每个单元格的高度,以像素为单位
-
setNodeDimensions
public void setNodeDimensions(AbstractLayoutCache.NodeDimensions nd)
设置负责在树中绘制节点的渲染器。- 重写:
-
setNodeDimensions在AbstractLayoutCache - 参数
-
nd- 渲染器
-
setExpandedState
public void setExpandedState(TreePath path, boolean isExpanded)
标记路径path扩展状态为isExpanded。- Specified by:
-
setExpandedState在AbstractLayoutCache - 参数
-
path- 感兴趣的TreePath -
isExpanded- 如果路径应该展开,isExpandedtrue,否则为false
-
getExpandedState
public boolean getExpandedState(TreePath path)
如果路径被展开且可见,则返回true。- Specified by:
-
getExpandedState在AbstractLayoutCache - 参数
-
path- 被查询的路径 - 结果
- 如果路径被扩展和可见,则为true,否则为false
-
getBounds
public Rectangle getBounds(TreePath path, Rectangle placeIn)
返回包含Rectangle标识的项目的标签部分的path。- Specified by:
-
getBounds在AbstractLayoutCache - 参数
-
path- 要绘制的路径 -
placeIn- 封闭矩形的边界 - 结果
-
如果节点无法确定,则包围矩形的边界为
null
-
getPathForRow
public TreePath getPathForRow(int row)
返回row的路径。 如果row不可见,则返回null。- Specified by:
-
getPathForRow在AbstractLayoutCache - 参数
-
row- 感兴趣的位置 - 结果
-
row的路径,或null如果row不可见
-
getRowForPath
public int getRowForPath(TreePath path)
返回路径中识别的最后一个项目可见的行。 如果路径中的任何元素当前不可见,则返回-1。- Specified by:
-
getRowForPath在AbstractLayoutCache - 参数
-
path- 感兴趣的TreePath - 结果
- 路径中最后一个项目可见的行
-
getRowCount
public int getRowCount()
返回可见行数。- Specified by:
-
getRowCount在AbstractLayoutCache - 结果
- 可见行数
-
invalidatePathBounds
public void invalidatePathBounds(TreePath path)
指示LayoutCache,对于边界path是无效的,并需要进行更新。- Specified by:
-
invalidatePathBounds在AbstractLayoutCache - 参数
-
path- 现在无效的TreePath
-
getPreferredHeight
public int getPreferredHeight()
返回首选高度。- 重写:
-
getPreferredHeight在AbstractLayoutCache - 结果
- 首选高度
-
getPreferredWidth
public int getPreferredWidth(Rectangle bounds)
返回visibleRegion该区域的首选宽度和高度。- 重写:
-
getPreferredWidth在AbstractLayoutCache - 参数
-
bounds- 正在查询的区域 - 结果
- 传入区域的首选宽度
-
getPathClosestTo
public TreePath getPathClosestTo(int x, int y)
返回最接近x,y的节点的路径。 如果目前没有任何可见的null,将返回null,否则将始终返回有效的路径。 如果您需要测试返回的对象是否完全在x处,那么您应该获得返回路径的边界,并对其进行测试x,y。- Specified by:
-
getPathClosestTo在AbstractLayoutCache - 参数
-
x- x坐标 -
y- y坐标 - 结果
- 到最接近x,y的节点的路径
-
getVisiblePathsFrom
public Enumeration<TreePath> getVisiblePathsFrom(TreePath path)
返回一个Enumerator,从传入的位置开始可见的路径递增。 枚举的顺序是基于路径的显示方式。- Specified by:
-
getVisiblePathsFrom在AbstractLayoutCache - 参数
-
path- 位置在TreePath开始 - 结果
-
一个
Enumerator,增加可见路径
-
getVisibleChildCount
public int getVisibleChildCount(TreePath path)
返回path的可见子path。- Specified by:
-
getVisibleChildCount在AbstractLayoutCache - 参数
-
path- 被查询的路径 - 结果
-
可见儿童人数
path
-
invalidateSizes
public void invalidateSizes()
通知TreeState它需要重新计算它所引用的所有大小。- Specified by:
-
invalidateSizes在AbstractLayoutCache
-
isExpanded
public boolean isExpanded(TreePath path)
如果path标识的值目前已被扩展,则返回true。- Specified by:
-
isExpanded在AbstractLayoutCache - 参数
-
path- 要检查的TreePath - 结果
-
如果
path识别的值目前正在扩展,pathtrue
-
treeNodesChanged
public void treeNodesChanged(TreeModelEvent e)
节点(或一组兄弟节点)以某种方式更改后调用。 节点没有更改树中的位置或更改其子数组,但其他属性已更改,并可能影响演示。 示例:文件的名称已更改,但它位于文件系统中的相同位置。e.path返回更改节点的父节点的路径。e.childIndices返回已更改节点的索引(s)。- Specified by:
-
treeNodesChanged在AbstractLayoutCache - 参数
-
e- 感兴趣的TreeModelEvent
-
treeNodesInserted
public void treeNodesInserted(TreeModelEvent e)
在节点插入到树中之后调用。e.path返回新节点的父节点。e.childIndices按升序返回新节点的索引。- Specified by:
-
treeNodesInserted在AbstractLayoutCache - 参数
-
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- 感兴趣的TreeModelEvent
-
-