public int getRowForPath(TreePath path) { return treeState.getRowForPath(path); }
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; }
/** * Expand this tree row. * If tree is inside a {@link SScrollPane} try to * adjust pane, so that as much as possible new * nodes are visible. * @param p the TreePath to expand */ public void expandPath(TreePath p) { treeState.setExpandedState(p, true); if (viewport != null) { Rectangle area = new Rectangle(viewport); area.y = treeState.getRowForPath(p); area.height = model.getChildCount(p.getLastPathComponent()) + 1; scrollRectToVisible(area); } fireTreeExpanded(p); reload(); }
/** Create a change TableModelEvent for the passed TreeModelEvent and the * contiguous subrange of the TreeModelEvent's getChildIndices() value */ private TableModelEvent createTableChangeEvent (TreeModelEvent e, int[] indices) { TableModelEvent result = null; TreePath path = e.getTreePath(); int row = getLayout().getRowForPath(path); int first = null == indices ? row : indices[0]; int last = null == indices ? row : indices[indices.length-1]; //TODO - does not need to be ALL_COLUMNS, but we need a way to determine //which column index is the tree result = new TableModelEvent (getModel(), first, last, TableModelEvent.ALL_COLUMNS, TableModelEvent.UPDATE); return result; }
int firstRow = getLayout().getRowForPath(path) + 1; if (firstRow == -1) {
Enumeration<?> paintingEnumerator = treeState .getVisiblePathsFrom(initialPath); int row = treeState.getRowForPath(initialPath); int endY = paintBounds.y + paintBounds.height;
Enumeration<?> paintingEnumerator = treeState .getVisiblePathsFrom(initialPath); int row = treeState.getRowForPath(initialPath); int endY = paintBounds.y + paintBounds.height;
int row = getLayout().getRowForPath(path); if (row == -1) {
/** Updates the layout to mark the descendants of the events path as also * expanded if they were the last it was expanded, then fires a table change. */ public void treeExpanded(TreeExpansionEvent event) { assert SwingUtilities.isEventDispatchThread(); log ("treeExpanded", event); //Mysterious how the event could be null, but JTree tests it //so we will too. if(event != null) { updateExpandedDescendants(event.getPath()); } log ("about to fire", pendingExpansionEvent); //Now fire a change on the owning row so its display is updated (it //may have just become an expandable node) TreePath path = event.getPath(); int row = getLayout().getRowForPath(path); TableModelEvent evt = new TableModelEvent (getModel(), row, row, 0, TableModelEvent.UPDATE); if (row == -1) { evt = new TableModelEvent(getModel()); } fireTableChange(new TableModelEvent[] {evt, pendingExpansionEvent}); pendingExpansionEvent = null; inProgressEvent = null; }
parent2 = tp2.getParentPath(); int r1 = getLayoutCache().getRowForPath(tp1); int r2 = getLayoutCache().getRowForPath(tp2);
public void treeCollapsed(TreeExpansionEvent event) { assert SwingUtilities.isEventDispatchThread(); log ("treeExpanded", event); //FixedHeightLayoutCache tests if the event is null. //Don't know how it could be, but there's probably a reason... if(event != null) { TreePath path = event.getPath(); //Tell the layout about the change if(path != null && getTreePathSupport().isVisible(path)) { getLayout().setExpandedState(path, false); } } log ("about to fire", pendingExpansionEvent); //Now fire a change on the owning row so its display is updated (it //may have just become an expandable node) TreePath path = event.getPath(); int row = getLayout().getRowForPath(path); TableModelEvent evt = new TableModelEvent (getModel(), row, row, 0, TableModelEvent.UPDATE); fireTableChange(new TableModelEvent[] {evt, pendingExpansionEvent}); pendingExpansionEvent = null; inProgressEvent = null; }
TreePath initialPath = getClosestPathForLocation(tree, 0, paintBounds.y); Enumeration paintingEnumerator = treeState.getVisiblePathsFrom(initialPath); int row = treeState.getRowForPath(initialPath); int endY = paintBounds.y + paintBounds.height; TreeModel treeModel = tree.getModel();
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);
int row = getLayout().getRowForPath(path);
int row = getLayout().getRowForPath(path);
TreePath parentPath = path.getParentPath(); if( null != parentPath ) { int parentRow = view.getOutline().getLayoutCache().getRowForPath(parentPath); dropIndex = row-parentRow;