Java 类javax.swing.tree.VariableHeightLayoutCache 实例源码

项目:incubator-netbeans    文件:DefaultOutlineModel.java   
/** 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);
    }
}
项目:cn1    文件:BasicTreeUITest.java   
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));
}
项目:cn1    文件:BasicTreeUITest.java   
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));
}
项目:cn1    文件:BasicTreeUITest.java   
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);
}
项目:freeVM    文件:BasicTreeUITest.java   
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));
}
项目:freeVM    文件:BasicTreeUITest.java   
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));
}
项目:freeVM    文件:BasicTreeUITest.java   
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);
}
项目:freeVM    文件:BasicTreeUITest.java   
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));
}
项目:freeVM    文件:BasicTreeUITest.java   
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));
}
项目:freeVM    文件:BasicTreeUITest.java   
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);
}
项目:cn1    文件:BasicTreeUITest.java   
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));
}
项目:cn1    文件:BasicTreeUITest.java   
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());
}
项目:freeVM    文件:BasicTreeUITest.java   
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));
}
项目:freeVM    文件:BasicTreeUITest.java   
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());
}
项目:freeVM    文件:BasicTreeUITest.java   
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));
}
项目:freeVM    文件:BasicTreeUITest.java   
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());
}
项目:cn1    文件:BasicTreeUI.java   
protected AbstractLayoutCache createLayoutCache() {
    return rowHeight > 0 && largeModel ? (AbstractLayoutCache)new FixedHeightLayoutCache()
                                       : (AbstractLayoutCache)new VariableHeightLayoutCache();
}
项目:freeVM    文件:BasicTreeUI.java   
protected AbstractLayoutCache createLayoutCache() {
    return rowHeight > 0 && largeModel ? (AbstractLayoutCache)new FixedHeightLayoutCache()
                                       : (AbstractLayoutCache)new VariableHeightLayoutCache();
}
项目:freeVM    文件:BasicTreeUI.java   
protected AbstractLayoutCache createLayoutCache() {
    return rowHeight > 0 && largeModel ? (AbstractLayoutCache)new FixedHeightLayoutCache()
                                       : (AbstractLayoutCache)new VariableHeightLayoutCache();
}
项目:javify    文件:BasicTreeUI.java   
/**
 * 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();
}
项目:jvm-stm    文件:BasicTreeUI.java   
/**
 * 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();
}
项目:JamVM-PH    文件:BasicTreeUI.java   
/**
 * 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();
}
项目:classpath    文件:BasicTreeUI.java   
/**
 * 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();
}