/** Is the tree root visible. Default value is true. */ public boolean isRootVisible() { if (getLayoutCache() == null) { return cachedRootVisible != null ? cachedRootVisible.booleanValue() : true; } else { return getLayoutCache().isRootVisible(); } }
/** Overridden to pass the fixed row height to the tree layout cache */ @Override public void setRowHeight(int val) { super.setRowHeight(val); if (getLayoutCache() != null) { getLayoutCache().setRowHeight(val); } }
public TreePath getClosestPathForLocation(int x, int y) { Insets i = getInsets(); if (i != null) { return getLayoutCache().getPathClosestTo(x - i.left, y - i.top); } else { return getLayoutCache().getPathClosestTo(x,y); } }
private int rowForNode(Node n) { TreeNode tn = Visualizer.findVisualizer(n); if (tn != null) { ArrayList<TreeNode> al = new ArrayList<TreeNode> (); while (tn != null) { al.add(tn); tn = tn.getParent(); } Collections.reverse(al); TreePath tp = new TreePath(al.toArray()); int row = outline.getLayoutCache().getRowForPath(tp); return row; } return -1; }
public Rectangle getPathBounds(TreePath path) { Insets i = getInsets(); Rectangle bounds = getLayoutCache().getBounds(path, null); if(bounds != null && i != null) { bounds.x += i.left; bounds.y += i.top; } return bounds; }
public Node nodeForRow(int row) { int r = outline.convertRowIndexToModel(row); TreePath tp = outline.getLayoutCache().getPathForRow(r); return Visualizer.findNode(tp.getLastPathComponent()); } public String getShortDescription(int column) {
@Override public Node nodeForRow(int row) { int r = outline.convertRowIndexToModel(row); TreePath tp = outline.getLayoutCache().getPathForRow(r); return Visualizer.findNode(tp.getLastPathComponent()); }
public javax.swing.Icon getIcon(Object o) { Node n = Visualizer.findNode(o); if (n == null) { throw new IllegalStateException("TreeNode must be VisualizerNode but was: " + o + " of class " + o.getClass().getName()); } boolean expanded = false; if (o instanceof TreeNode) { TreeNode tn = (TreeNode)o; ArrayList<TreeNode> al = new ArrayList<TreeNode> (); while (tn != null) { al.add(tn); tn = tn.getParent(); } Collections.reverse(al); TreePath tp = new TreePath(al.toArray()); AbstractLayoutCache layout = table.getLayoutCache(); expanded = layout.isExpanded(tp); } java.awt.Image image = null; if (expanded) { image = n.getOpenedIcon(java.beans.BeanInfo.ICON_COLOR_16x16); } else { image = n.getIcon(java.beans.BeanInfo.ICON_COLOR_16x16); } return new ImageIcon(image); }
/** Set whether or not the root is visible */ public void setRootVisible (boolean val) { if (getOutlineModel() == null) { cachedRootVisible = val ? Boolean.TRUE : Boolean.FALSE; } if (val != isRootVisible()) { //TODO - need to force a property change on the model, //the layout cache doesn't have direct listener support getLayoutCache().setRootVisible(val); firePropertyChange("rootVisible", !val, val); //NOI18N } }
protected void configureTreeCellEditor( Component editor, int row, int column ) { if( !(editor instanceof JComponent) ) { return; } TreeCellEditorBorder b = new TreeCellEditorBorder(); TreePath path = getLayoutCache().getPathForRow(convertRowIndexToModel(row)); Object o = getValueAt(row, column); RenderDataProvider rdp = getRenderDataProvider(); b.icon = rdp.getIcon(o); b.nestingDepth = Math.max( 0, path.getPathCount() - (isRootVisible() ? 1 : 2) ); b.isLeaf = getOutlineModel().isLeaf(o); b.isExpanded = getLayoutCache().isExpanded(path); ((JComponent)editor).setBorder(b); }
public void actionPerformed(ActionEvent e) { if( getSelectedRowCount() == 1 && isTreeColumnIndex (getSelectedColumn()) ) { int selRow = getSelectedRow(); TreePath selPath = getLayoutCache().getPathForRow(selRow); if( null != selPath && !getOutlineModel().isLeaf(selPath.getLastPathComponent()) ) { boolean expanded = getLayoutCache().isExpanded(selPath); if( expanded && !expand ) { collapsePath(selPath); return; } else if( !expanded && expand ) { expandPath(selPath); return; } } } if( null != origAction ) origAction.actionPerformed(e); } }
return 0; TreePath tp1 = getLayoutCache().getPathForRow(index1); TreePath tp2 = getLayoutCache().getPathForRow(index2); if (tp1.isDescendant(tp2)) { return -1; parent2 = tp2.getParentPath(); int r1 = getLayoutCache().getRowForPath(tp1); int r2 = getLayoutCache().getRowForPath(tp2);
TreePath path = getLayoutCache().getPathForRow(convertRowIndexToModel(row)); if (!getOutlineModel().isLeaf(path.getLastPathComponent())) { int handleWidth = DefaultOutlineCellRenderer.getExpansionHandleWidth(); me.getClickCount() > 1) { boolean expanded = getLayoutCache().isExpanded(path); if (!expanded) { getTreePathSupport().expandPath(path); Object lastChild = getOutlineModel().getChild(ourObject, cCount - 1); TreePath lastChildPath = path.pathByAddingChild(lastChild); int lastRow = getLayoutCache().getRowForPath(lastChildPath); Rectangle rect = getCellRect(lastRow, 0, true); scrollRectToVisible(rect);
TreePath tp = view.getOutline().getLayoutCache().getPathForRow( view.getOutline().convertRowIndexToModel(row)); if (LOGABLE) { log("tp == " + tp); //NOI18N if (!view.getOutline().getLayoutCache().isExpanded(tp)) { log("tree path is not expanded"); // NOI18N TreePath path = view.getOutline().getLayoutCache().getPathForRow( view.getOutline().convertRowIndexToModel(row)); if( null != path ) { TreePath parentPath = path.getParentPath(); if( null != parentPath ) { int parentRow = view.getOutline().getLayoutCache().getRowForPath(parentPath); dropIndex = row-parentRow; final TreePath path = view.getOutline().getLayoutCache().getPathForRow( view.getOutline().convertRowIndexToModel(row)); boolean expanded = view.getOutline().getLayoutCache().isExpanded(path); if ( ((timer == null) || !timer.isRunning()) && (dropNode != null) && !dropNode.isLeaf()
Outline tbl = (Outline) table; if (tbl.isTreeColumnIndex(column)) { AbstractLayoutCache layout = tbl.getLayoutCache(); row = tbl.convertRowIndexToModel(row); boolean leaf = tbl.getOutlineModel().isLeaf(value);