Example usage for javafx.scene.control TreeTableView layout

List of usage examples for javafx.scene.control TreeTableView layout

Introduction

In this page you can find the example usage for javafx.scene.control TreeTableView layout.

Prototype

public final void layout() 

Source Link

Document

Executes a top-down layout pass on the scene graph under this parent.

Usage

From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java

@Override
public Rectangle getVisibleRowBounds(final Rectangle rowBounds) {
    Rectangle result = EventThreadQueuerJavaFXImpl.invokeAndWait("getVisibleRowBounds", //$NON-NLS-1$
            new Callable<Rectangle>() {

                @Override/*  www.j a  v  a 2  s.c  om*/
                public Rectangle call() throws Exception {
                    TreeTableView<?> tree = getTree();
                    // Update the layout coordinates otherwise
                    // we would get old position values
                    tree.layout();
                    Rectangle visibleTreeBounds = new Rectangle(0, 0, Rounding.round(tree.getWidth()),
                            Rounding.round(tree.getHeight()));
                    return rowBounds.intersection(visibleTreeBounds);
                }
            });
    return result;
}

From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java

@Override
public Rectangle getNodeBounds(final Object node) {
    scrollNodeToVisible(node);//from  w  ww .j av a 2 s.c o m
    return EventThreadQueuerJavaFXImpl.invokeAndWait("getNodeBounds", new Callable<Rectangle>() { //$NON-NLS-1$

        @Override
        public Rectangle call() throws Exception {
            TreeTableView<?> treeTable = getTree();
            treeTable.layout();
            TreeItem<?> item = (TreeItem<?>) node;
            List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>().getInstancesOf(treeTable,
                    TreeTableCell.class);
            for (TreeTableCell<?, ?> cell : cells) {
                // Nullchecks because of the virtual flow cells
                // are created which might not be associated
                // with a row or an item
                TreeTableRow<?> ttRow = cell.getTreeTableRow();
                if (ttRow == null) {
                    continue;
                }
                TreeItem<?> checkItem = ttRow.getTreeItem();
                if (checkItem == null) {
                    continue;
                }
                if (item != null && checkItem.equals(item)
                        && treeTable.getColumns().indexOf(cell.getTableColumn()) == m_column) {
                    Rectangle b = NodeBounds.getAbsoluteBounds(cell);
                    Rectangle treeB = NodeBounds.getAbsoluteBounds(treeTable);
                    return new Rectangle(Math.abs(treeB.x - b.x), Math.abs(treeB.y - b.y),
                            Rounding.round(b.getWidth()), Rounding.round(b.getHeight()));
                }
            }
            return null;
        }
    });
}