JavaTM 2 Platform
Standard Ed. 6

javax.swing.tree
类 FixedHeightLayoutCache

java.lang.Object
  继承者 javax.swing.tree.AbstractLayoutCache
      继承者 javax.swing.tree.FixedHeightLayoutCache
所有已实现的接口:
RowMapper

public class FixedHeightLayoutCache
extends AbstractLayoutCache

注:在以后的版本中,这将变得更加开放。

警告:此类的已序列化对象与以后的 Swing 版本不兼容。当前的序列化支持适用于短期存储或运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder


嵌套类摘要
 
从类 javax.swing.tree.AbstractLayoutCache 继承的嵌套类/接口
AbstractLayoutCache.NodeDimensions
 
字段摘要
 
从类 javax.swing.tree.AbstractLayoutCache 继承的字段
nodeDimensions, rootVisible, rowHeight, treeModel, treeSelectionModel
 
构造方法摘要
FixedHeightLayoutCache()
           
 
方法摘要
 Rectangle getBounds(TreePath path, Rectangle placeIn)
          返回给出绘制路径所需边界的矩形。
 boolean getExpandedState(TreePath path)
          如果该路径已扩展,并且可见,则返回 true。
 TreePath getPathClosestTo(int x, int y)
          返回最接近 x,y 的节点的路径。
 TreePath getPathForRow(int row)
          返回传入行的路径。
 int getRowCount()
          返回可视的行数。
 int getRowForPath(TreePath path)
          返回路径中标识的最后一项可见的行。
 int getVisibleChildCount(TreePath path)
          返回行的可见子对象数。
 Enumeration<TreePath> getVisiblePathsFrom(TreePath path)
          返回表示从传入位置开始的可见路径的增量的 Enumerator。
 void invalidatePathBounds(TreePath path)
          不执行任何操作,FixedHeightLayoutCache 不缓存宽度(即所有可以更改的宽度)。
 void invalidateSizes()
          通知 TreeState 需要重新计算它引用的所有大小。
 boolean isExpanded(TreePath path)
          如果当前扩展了由行标识的值,则返回 true。
 void setExpandedState(TreePath path, boolean isExpanded)
          将路径 path 的扩展状态标记为 isExpanded
 void setModel(TreeModel newModel)
          设置将提供数据的 TreeModel。
 void setRootVisible(boolean rootVisible)
          确定 TreeModel 的根节点是否可见。
 void setRowHeight(int rowHeight)
          设置每个单元格的高度。
 void treeNodesChanged(TreeModelEvent e)
          在已经以某种方式更改节点(或同级节点集)后调用。
 void treeNodesInserted(TreeModelEvent e)
          将节点插入树之后进行调用。
 void treeNodesRemoved(TreeModelEvent e)
          将节点从树移除之后进行调用。
 void treeStructureChanged(TreeModelEvent e)
          树彻底更改给定节点以下的结构之后进行调用。
 
从类 javax.swing.tree.AbstractLayoutCache 继承的方法
getModel, getNodeDimensions, getNodeDimensions, getPreferredHeight, getPreferredWidth, getRowHeight, getRowsForPaths, getSelectionModel, isFixedRowHeight, isRootVisible, setNodeDimensions, setSelectionModel
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

FixedHeightLayoutCache

public FixedHeightLayoutCache()
方法详细信息

setModel

public void setModel(TreeModel newModel)
设置将提供数据的 TreeModel。

覆盖:
AbstractLayoutCache 中的 setModel
参数:
newModel - 将提供数据的 TreeModel

setRootVisible

public void setRootVisible(boolean rootVisible)
确定 TreeModel 的根节点是否可见。

覆盖:
AbstractLayoutCache 中的 setRootVisible
参数:
rootVisible - 如果将显示树的根节点,则为 true
另请参见:
AbstractLayoutCache.rootVisible

setRowHeight

public void setRowHeight(int rowHeight)
设置每个单元格的高度。如果 rowHeight 小于或等于 0,则将抛出 IllegalArgumentException。

覆盖:
AbstractLayoutCache 中的 setRowHeight
参数:
rowHeight - 每个单元格的高度(以像素为单位)

getRowCount

public int getRowCount()
返回可视的行数。

指定者:
AbstractLayoutCache 中的 getRowCount
返回:
显示的行数

invalidatePathBounds

public void invalidatePathBounds(TreePath path)
不执行任何操作,FixedHeightLayoutCache 不缓存宽度(即所有可以更改的宽度)。

指定者:
AbstractLayoutCache 中的 invalidatePathBounds
参数:
path - 正在被更新的路径

invalidateSizes

public void invalidateSizes()
通知 TreeState 需要重新计算它引用的所有大小。

指定者:
AbstractLayoutCache 中的 invalidateSizes

isExpanded

public boolean isExpanded(TreePath path)
如果当前扩展了由行标识的值,则返回 true。

指定者:
AbstractLayoutCache 中的 isExpanded

getBounds

public Rectangle getBounds(TreePath path,
                           Rectangle placeIn)
返回给出绘制路径所需边界的矩形。

指定者:
AbstractLayoutCache 中的 getBounds
参数:
path - 指定节点的 TreePath
placeIn - 提供可用空间的 Rectangle 对象
返回:
指定要使用的空间的 Rectangle 对象

getPathForRow

public TreePath getPathForRow(int row)
返回传入行的路径。如果行不可见,则返回 null。

指定者:
AbstractLayoutCache 中的 getPathForRow
参数:
row - 查询的行
返回:
给定的行的 TreePath

getRowForPath

public int getRowForPath(TreePath path)
返回路径中标识的最后一项可见的行。如果路径中任何元素当前不可见,则返回 -1。

指定者:
AbstractLayoutCache 中的 getRowForPath
参数:
path - 查询的 TreePath
返回:
路径中最后一项可视的行,如果路径中任何元素当前不可视,则返回 -1

getPathClosestTo

public TreePath getPathClosestTo(int x,
                                 int y)
返回最接近 x,y 的节点的路径。如果当前没有任何可见的内容,则返回 null,否则,始终返回一个有效路径。如果需要测试返回的对象是否正好位于 x, y,您应获取返回路径的边界,并根据它测试 x, y。

指定者:
AbstractLayoutCache 中的 getPathClosestTo
参数:
x - 所需位置的水平组件
y - 所需位置的垂直组件
返回:
最接近指定点的 TreePath

getVisibleChildCount

public int getVisibleChildCount(TreePath path)
返回行的可见子对象数。

指定者:
AbstractLayoutCache 中的 getVisibleChildCount
参数:
path - 正被查询的路径
返回:
指定路径的可视子节点数

getVisiblePathsFrom

public Enumeration<TreePath> getVisiblePathsFrom(TreePath path)
返回表示从传入位置开始的可见路径的增量的 Enumerator。该枚举的排序基于路径的显示方式。

指定者:
AbstractLayoutCache 中的 getVisiblePathsFrom
参数:
path - 枚举的起始位置
返回:
在所需位置开始的 Enumerator

setExpandedState

public void setExpandedState(TreePath path,
                             boolean isExpanded)
将路径 path 的扩展状态标记为 isExpanded

指定者:
AbstractLayoutCache 中的 setExpandedState
参数:
path - 正在被扩展或折叠的路径
isExpanded - 如果应该扩展路径,则为 true,否则为 false

getExpandedState

public boolean getExpandedState(TreePath path)
如果该路径已扩展,并且可见,则返回 true。

指定者:
AbstractLayoutCache 中的 getExpandedState
参数:
path - 正在被查询的路径
返回:
如果路径已扩展并且可视,则返回 true,否则返回 false

treeNodesChanged

public void treeNodesChanged(TreeModelEvent e)

在已经以某种方式更改节点(或同级节点集)后调用。没有更改节点在树中的位置,也没有改变他们的子数组,但是其他的属性已更改,并且可能影响表示形式。示例:文件的名称已更改,但是它在文件系统中的位置不变。

e.path() 返回已更改节点的父节点的路径。

e.childIndices() 返回更改节点的索引。

指定者:
AbstractLayoutCache 中的 treeNodesChanged
参数:
e - TreeModelEvent

treeNodesInserted

public void treeNodesInserted(TreeModelEvent e)

将节点插入树之后进行调用。

e.path() 返回新节点的父节点

e.childIndices() 按升序返回新节点的索引。

指定者:
AbstractLayoutCache 中的 treeNodesInserted
参数:
e - TreeModelEvent

treeNodesRemoved

public void treeNodesRemoved(TreeModelEvent e)

将节点从树移除之后进行调用。注意,如果从树移除子树,则对于移除的子树的根而言,此方法仅调用一次,对于移除的每个兄弟子树集而言,则不是一次。

e.path() 返回删除节点的前一个父节点。

e.childIndices() 返回节点按升序删除之前具有的索引。

指定者:
AbstractLayoutCache 中的 treeNodesRemoved
参数:
e - TreeModelEvent

treeStructureChanged

public void treeStructureChanged(TreeModelEvent e)

树彻底更改给定节点以下的结构之后进行调用。如果 e.getPath() 返回的路径长度为一,并且第一个元素不标识当前根节点,则第一个元素应成为树的新根节点。

e.path() 保持节点的路径。

e.childIndices() 返回 null。

指定者:
AbstractLayoutCache 中的 treeStructureChanged
参数:
e - TreeModelEvent

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策