java类javax.swing.tree.VariableHeightLayoutCache的实例源码

DefaultOutlineModel.java 文件源码 项目:incubator-netbeans 阅读 19 收藏 0 点赞 0 评论 0
/** Creates a new instance of DefaultOutlineModel.  <strong><b>Note</b> 
 * Do not fire table structure changes from the wrapped TableModel (value
 * changes are okay).  Changes that affect the number of rows must come
 * from the TreeModel.
 * @param treeModel The tree model
 * @param tableModel The table model
 * @param largeModel <code>true</code> if it's a large model tree, <code>false</code> otherwise.
 * @param nodesColumnLabel Label of the node's column
 */
protected DefaultOutlineModel(TreeModel treeModel, TableModel tableModel, boolean largeModel, String nodesColumnLabel) {
    this.treeModel = treeModel;
    this.tableModel = tableModel;
    if (nodesColumnLabel != null) {
        this.nodesColumnLabel = nodesColumnLabel;
    }

    layout = largeModel ? (AbstractLayoutCache) new FixedHeightLayoutCache() 
        : (AbstractLayoutCache) new VariableHeightLayoutCache();

    broadcaster = new EventBroadcaster (this);

    layout.setRootVisible(true);
    layout.setModel(this);
    treePathSupport = new TreePathSupport(this, layout);
    treePathSupport.addTreeExpansionListener(broadcaster);
    treePathSupport.addTreeWillExpandListener(broadcaster);
    treeModel.addTreeModelListener(broadcaster);
    tableModel.addTableModelListener(broadcaster);
    if (tableModel instanceof ProxyTableModel) {
        ((ProxyTableModel) tableModel).setOutlineModel(this);
    }
}
BasicTreeUITest.java 文件源码 项目:cn1 阅读 17 收藏 0 点赞 0 评论 0
public void testGetPathForRow() {
    TreePath p = new TreePath(new Object[] { root, node2 });
    assertTrue(tree.isRootVisible());
    assertNull(ui.getPathForRow(tree, 7));
    assertEquals(p, ui.treeState.getPathForRow(2));
    assertEquals(p, ui.getPathForRow(new JTree(), 2));
    tree.expandPath(p);
    assertEquals(new TreePath(new Object[] { root, node2, node22 }), ui.getPathForRow(tree,
            4));
    assertEquals(new TreePath(new Object[] { root, node3 }), ui.getPathForRow(tree, 5));
    ui.treeState = new VariableHeightLayoutCache() {
        @Override
        public TreePath getPathForRow(final int row) {
            return new TreePath(new Object[] { node3 });
        }
    };
    assertEquals(new TreePath(new Object[] { node3 }), ui.getPathForRow(tree, -400));
    assertEquals(ui.treeState.getPathForRow(2), ui.getPathForRow(tree, 5));
}
BasicTreeUITest.java 文件源码 项目:cn1 阅读 19 收藏 0 点赞 0 评论 0
public void testGetRowCount() {
    assertTrue(tree.isRootVisible());
    assertEquals(4, ui.treeState.getRowCount());
    assertEquals(4, ui.getRowCount(new JTree()));
    TreePath p = new TreePath(new Object[] { root, node2 });
    tree.expandPath(p);
    assertEquals(6, ui.getRowCount(tree));
    ui.treeState = new VariableHeightLayoutCache() {
        @Override
        public int getRowCount() {
            return -200;
        }
    };
    assertEquals(ui.getRowCount(new JTree()), ui.treeState.getRowCount());
    assertEquals(-200, ui.getRowCount(tree));
}
BasicTreeUITest.java 文件源码 项目:cn1 阅读 47 收藏 0 点赞 0 评论 0
public void testCreateLayoutCache() {
    tree.setRowHeight(0);
    assertNotNull(ui.createLayoutCache());
    assertNotSame(ui.createLayoutCache(), ui.createLayoutCache());
    assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache);
    assertTrue(ui.treeState instanceof VariableHeightLayoutCache);
    tree.setRowHeight(10);
    assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache);
    assertTrue(ui.treeState instanceof VariableHeightLayoutCache);
    tree.setRowHeight(0);
    tree.setLargeModel(true);
    assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache);
    assertTrue(ui.treeState instanceof VariableHeightLayoutCache);
    tree.setRowHeight(10);
    assertTrue(ui.createLayoutCache() instanceof FixedHeightLayoutCache);
    assertTrue(ui.treeState instanceof FixedHeightLayoutCache);
}
BasicTreeUITest.java 文件源码 项目:freeVM 阅读 21 收藏 0 点赞 0 评论 0
public void testGetPathForRow() {
    TreePath p = new TreePath(new Object[] { root, node2 });
    assertTrue(tree.isRootVisible());
    assertNull(ui.getPathForRow(tree, 7));
    assertEquals(p, ui.treeState.getPathForRow(2));
    assertEquals(p, ui.getPathForRow(new JTree(), 2));
    tree.expandPath(p);
    assertEquals(new TreePath(new Object[] { root, node2, node22 }), ui.getPathForRow(tree,
            4));
    assertEquals(new TreePath(new Object[] { root, node3 }), ui.getPathForRow(tree, 5));
    ui.treeState = new VariableHeightLayoutCache() {
        @Override
        public TreePath getPathForRow(final int row) {
            return new TreePath(new Object[] { node3 });
        }
    };
    assertEquals(new TreePath(new Object[] { node3 }), ui.getPathForRow(tree, -400));
    assertEquals(ui.treeState.getPathForRow(2), ui.getPathForRow(tree, 5));
}
BasicTreeUITest.java 文件源码 项目:freeVM 阅读 25 收藏 0 点赞 0 评论 0
public void testGetRowCount() {
    assertTrue(tree.isRootVisible());
    assertEquals(4, ui.treeState.getRowCount());
    assertEquals(4, ui.getRowCount(new JTree()));
    TreePath p = new TreePath(new Object[] { root, node2 });
    tree.expandPath(p);
    assertEquals(6, ui.getRowCount(tree));
    ui.treeState = new VariableHeightLayoutCache() {
        @Override
        public int getRowCount() {
            return -200;
        }
    };
    assertEquals(ui.getRowCount(new JTree()), ui.treeState.getRowCount());
    assertEquals(-200, ui.getRowCount(tree));
}
BasicTreeUITest.java 文件源码 项目:freeVM 阅读 21 收藏 0 点赞 0 评论 0
public void testCreateLayoutCache() {
    tree.setRowHeight(0);
    assertNotNull(ui.createLayoutCache());
    assertNotSame(ui.createLayoutCache(), ui.createLayoutCache());
    assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache);
    assertTrue(ui.treeState instanceof VariableHeightLayoutCache);
    tree.setRowHeight(10);
    assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache);
    assertTrue(ui.treeState instanceof VariableHeightLayoutCache);
    tree.setRowHeight(0);
    tree.setLargeModel(true);
    assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache);
    assertTrue(ui.treeState instanceof VariableHeightLayoutCache);
    tree.setRowHeight(10);
    assertTrue(ui.createLayoutCache() instanceof FixedHeightLayoutCache);
    assertTrue(ui.treeState instanceof FixedHeightLayoutCache);
}
BasicTreeUITest.java 文件源码 项目:freeVM 阅读 22 收藏 0 点赞 0 评论 0
public void testGetPathForRow() {
    TreePath p = new TreePath(new Object[] { root, node2 });
    assertTrue(tree.isRootVisible());
    assertNull(ui.getPathForRow(tree, 7));
    assertEquals(p, ui.treeState.getPathForRow(2));
    assertEquals(p, ui.getPathForRow(new JTree(), 2));
    tree.expandPath(p);
    assertEquals(new TreePath(new Object[] { root, node2, node22 }), ui.getPathForRow(tree,
            4));
    assertEquals(new TreePath(new Object[] { root, node3 }), ui.getPathForRow(tree, 5));
    ui.treeState = new VariableHeightLayoutCache() {
        @Override
        public TreePath getPathForRow(final int row) {
            return new TreePath(new Object[] { node3 });
        }
    };
    assertEquals(new TreePath(new Object[] { node3 }), ui.getPathForRow(tree, -400));
    assertEquals(ui.treeState.getPathForRow(2), ui.getPathForRow(tree, 5));
}
BasicTreeUITest.java 文件源码 项目:freeVM 阅读 26 收藏 0 点赞 0 评论 0
public void testGetRowCount() {
    assertTrue(tree.isRootVisible());
    assertEquals(4, ui.treeState.getRowCount());
    assertEquals(4, ui.getRowCount(new JTree()));
    TreePath p = new TreePath(new Object[] { root, node2 });
    tree.expandPath(p);
    assertEquals(6, ui.getRowCount(tree));
    ui.treeState = new VariableHeightLayoutCache() {
        @Override
        public int getRowCount() {
            return -200;
        }
    };
    assertEquals(ui.getRowCount(new JTree()), ui.treeState.getRowCount());
    assertEquals(-200, ui.getRowCount(tree));
}
BasicTreeUITest.java 文件源码 项目:freeVM 阅读 24 收藏 0 点赞 0 评论 0
public void testCreateLayoutCache() {
    tree.setRowHeight(0);
    assertNotNull(ui.createLayoutCache());
    assertNotSame(ui.createLayoutCache(), ui.createLayoutCache());
    assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache);
    assertTrue(ui.treeState instanceof VariableHeightLayoutCache);
    tree.setRowHeight(10);
    assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache);
    assertTrue(ui.treeState instanceof VariableHeightLayoutCache);
    tree.setRowHeight(0);
    tree.setLargeModel(true);
    assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache);
    assertTrue(ui.treeState instanceof VariableHeightLayoutCache);
    tree.setRowHeight(10);
    assertTrue(ui.createLayoutCache() instanceof FixedHeightLayoutCache);
    assertTrue(ui.treeState instanceof FixedHeightLayoutCache);
}
BasicTreeUITest.java 文件源码 项目:cn1 阅读 23 收藏 0 点赞 0 评论 0
public void testUpdateExpandedDescendants() {
    TreePath pathToExpand = new TreePath(tree.getModel().getRoot())
            .pathByAddingChild(node1);
    tree.expandPath(pathToExpand);
    assertTrue(ui.treeState.isExpanded(pathToExpand));
    ui.treeState = new VariableHeightLayoutCache();
    ui.treeState.setModel(tree.getModel());
    assertFalse(ui.treeState.isExpanded(pathToExpand));
    ui.updateExpandedDescendants(new TreePath(tree.getModel().getRoot()));
    assertTrue(ui.treeState.isExpanded(pathToExpand));
}
BasicTreeUITest.java 文件源码 项目:cn1 阅读 21 收藏 0 点赞 0 评论 0
public void testConfigureLayoutCache() {
    TreePath expandedPath = new TreePath(tree.getModel().getRoot())
            .pathByAddingChild(node1);
    tree.expandPath(expandedPath);
    ui.treeState = new VariableHeightLayoutCache();
    ui.configureLayoutCache();
    assertSame(tree.getModel(), ui.treeState.getModel());
    assertSame(tree.getSelectionModel(), ui.treeState.getSelectionModel());
    assertSame(ui.nodeDimensions, ui.treeState.getNodeDimensions());
    assertEquals(tree.getRowHeight(), ui.treeState.getRowHeight());
    assertTrue(ui.treeState.isExpanded(expandedPath));
    assertTrue(ui.treeState.isRootVisible());
}
BasicTreeUITest.java 文件源码 项目:freeVM 阅读 27 收藏 0 点赞 0 评论 0
public void testUpdateExpandedDescendants() {
    TreePath pathToExpand = new TreePath(tree.getModel().getRoot())
            .pathByAddingChild(node1);
    tree.expandPath(pathToExpand);
    assertTrue(ui.treeState.isExpanded(pathToExpand));
    ui.treeState = new VariableHeightLayoutCache();
    ui.treeState.setModel(tree.getModel());
    assertFalse(ui.treeState.isExpanded(pathToExpand));
    ui.updateExpandedDescendants(new TreePath(tree.getModel().getRoot()));
    assertTrue(ui.treeState.isExpanded(pathToExpand));
}
BasicTreeUITest.java 文件源码 项目:freeVM 阅读 22 收藏 0 点赞 0 评论 0
public void testConfigureLayoutCache() {
    TreePath expandedPath = new TreePath(tree.getModel().getRoot())
            .pathByAddingChild(node1);
    tree.expandPath(expandedPath);
    ui.treeState = new VariableHeightLayoutCache();
    ui.configureLayoutCache();
    assertSame(tree.getModel(), ui.treeState.getModel());
    assertSame(tree.getSelectionModel(), ui.treeState.getSelectionModel());
    assertSame(ui.nodeDimensions, ui.treeState.getNodeDimensions());
    assertEquals(tree.getRowHeight(), ui.treeState.getRowHeight());
    assertTrue(ui.treeState.isExpanded(expandedPath));
    assertTrue(ui.treeState.isRootVisible());
}
BasicTreeUITest.java 文件源码 项目:freeVM 阅读 20 收藏 0 点赞 0 评论 0
public void testUpdateExpandedDescendants() {
    TreePath pathToExpand = new TreePath(tree.getModel().getRoot())
            .pathByAddingChild(node1);
    tree.expandPath(pathToExpand);
    assertTrue(ui.treeState.isExpanded(pathToExpand));
    ui.treeState = new VariableHeightLayoutCache();
    ui.treeState.setModel(tree.getModel());
    assertFalse(ui.treeState.isExpanded(pathToExpand));
    ui.updateExpandedDescendants(new TreePath(tree.getModel().getRoot()));
    assertTrue(ui.treeState.isExpanded(pathToExpand));
}
BasicTreeUITest.java 文件源码 项目:freeVM 阅读 30 收藏 0 点赞 0 评论 0
public void testConfigureLayoutCache() {
    TreePath expandedPath = new TreePath(tree.getModel().getRoot())
            .pathByAddingChild(node1);
    tree.expandPath(expandedPath);
    ui.treeState = new VariableHeightLayoutCache();
    ui.configureLayoutCache();
    assertSame(tree.getModel(), ui.treeState.getModel());
    assertSame(tree.getSelectionModel(), ui.treeState.getSelectionModel());
    assertSame(ui.nodeDimensions, ui.treeState.getNodeDimensions());
    assertEquals(tree.getRowHeight(), ui.treeState.getRowHeight());
    assertTrue(ui.treeState.isExpanded(expandedPath));
    assertTrue(ui.treeState.isRootVisible());
}
BasicTreeUI.java 文件源码 项目:cn1 阅读 20 收藏 0 点赞 0 评论 0
protected AbstractLayoutCache createLayoutCache() {
    return rowHeight > 0 && largeModel ? (AbstractLayoutCache)new FixedHeightLayoutCache()
                                       : (AbstractLayoutCache)new VariableHeightLayoutCache();
}
BasicTreeUI.java 文件源码 项目:freeVM 阅读 20 收藏 0 点赞 0 评论 0
protected AbstractLayoutCache createLayoutCache() {
    return rowHeight > 0 && largeModel ? (AbstractLayoutCache)new FixedHeightLayoutCache()
                                       : (AbstractLayoutCache)new VariableHeightLayoutCache();
}
BasicTreeUI.java 文件源码 项目:freeVM 阅读 24 收藏 0 点赞 0 评论 0
protected AbstractLayoutCache createLayoutCache() {
    return rowHeight > 0 && largeModel ? (AbstractLayoutCache)new FixedHeightLayoutCache()
                                       : (AbstractLayoutCache)new VariableHeightLayoutCache();
}
BasicTreeUI.java 文件源码 项目:javify 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Creates the object responsible for managing what is expanded, as well as
 * the size of nodes.
 *
 * @return the object responsible for managing what is expanded.
 */
protected AbstractLayoutCache createLayoutCache()
{
  return new VariableHeightLayoutCache();
}
BasicTreeUI.java 文件源码 项目:jvm-stm 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Creates the object responsible for managing what is expanded, as well as
 * the size of nodes.
 * 
 * @return the object responsible for managing what is expanded.
 */
protected AbstractLayoutCache createLayoutCache()
{
  return new VariableHeightLayoutCache();
}
BasicTreeUI.java 文件源码 项目:JamVM-PH 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Creates the object responsible for managing what is expanded, as well as
 * the size of nodes.
 * 
 * @return the object responsible for managing what is expanded.
 */
protected AbstractLayoutCache createLayoutCache()
{
  return new VariableHeightLayoutCache();
}
BasicTreeUI.java 文件源码 项目:classpath 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Creates the object responsible for managing what is expanded, as well as
 * the size of nodes.
 *
 * @return the object responsible for managing what is expanded.
 */
protected AbstractLayoutCache createLayoutCache()
{
  return new VariableHeightLayoutCache();
}


问题


面经


文章

微信
公众号

扫码关注公众号