Example usage for javafx.geometry Bounds getHeight

List of usage examples for javafx.geometry Bounds getHeight

Introduction

In this page you can find the example usage for javafx.geometry Bounds getHeight.

Prototype

public final double getHeight() 

Source Link

Document

The height of this Bounds .

Usage

From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java

/**
 * Refreshes the complete layout and returns the bounds of the given
 * Component./*from   w  w  w .j av a  2s  . c o  m*/
 *
 * @param comp
 *            the Component
 * @param clickOp
 *            not used
 * @return Rectangle with the Bounds
 */
private Rectangle getComponentBounds(final Object comp, ClickOptions clickOp) {

    ComponentHandler.syncStageResize();
    Rectangle bounds = null;
    if (comp instanceof Stage) {
        Stage s = (Stage) comp;
        bounds = new Rectangle(new Point(Rounding.round(s.getX()), Rounding.round(s.getY())));

        // This is not multi display compatible
        Screen screen = Screen.getPrimary();
        final Rectangle2D screenBounds = screen.getBounds();
        int displayWidth = Rounding.round(screenBounds.getWidth());
        int displayHeight = Rounding.round(screenBounds.getHeight());
        if (s.isFullScreen()) {
            bounds.width = Rounding.round(displayWidth);
            bounds.height = Rounding.round(displayHeight);
        } else if (s.isMaximized()) {
            int x = Rounding.round(s.getX());
            int y = Rounding.round(s.getY());
            // trimming the bounds to the display if necessary
            bounds.width = Rounding.round(s.getWidth());
            bounds.height = Rounding.round(s.getHeight());
            if (x < 0 || y < 0) {
                bounds.x = 0;
                bounds.y = 0;
                if (bounds.width > displayWidth) {
                    bounds.width = displayWidth;
                }
                if (bounds.height > displayHeight) {
                    bounds.height = displayHeight;
                }
            }
        } else {
            bounds.width = Rounding.round(s.getWidth());
            bounds.height = Rounding.round(s.getHeight());
        }
    } else {
        final Node node = (Node) comp;
        if (clickOp.isScrollToVisible()) {
            ensureComponentVisible(node);
        }
        bounds = EventThreadQueuerJavaFXImpl.invokeAndWait("Robot get node bounds", new Callable<Rectangle>() { //$NON-NLS-1$

            @Override
            public Rectangle call() throws Exception {
                Rectangle bs = new Rectangle(getLocation(node, new Point(0, 0)));
                Bounds b = node.getBoundsInParent();
                bs.width = Rounding.round(b.getWidth());
                bs.height = Rounding.round(b.getHeight());
                return bs;
            }
        });

    }
    return bounds;
}

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

/** {@inheritDoc} **/
public void clickOnIndex(final Integer index, ClickOptions co) {
    final int actualItemCount = EventThreadQueuerJavaFXImpl.invokeAndWait("scrollIndexVisible", //$NON-NLS-1$
            new Callable<Integer>() {
                public Integer call() throws Exception {
                    final ObservableList items = getRealComponent().getItems();
                    int itemCount = items != null ? items.size() : -1;
                    return new Integer(itemCount);
                }/*from   w  ww .j  av a  2s  . c o m*/
            }).intValue();

    if (index >= actualItemCount || (index < 0)) {
        throw new StepExecutionException("List index '" + index //$NON-NLS-1$
                + "' is out of range", //$NON-NLS-1$
                EventFactory.createActionError(TestErrorEvent.INVALID_INDEX));
    }

    Rectangle r = EventThreadQueuerJavaFXImpl.invokeAndWait("scrollIndexVisible", //$NON-NLS-1$
            new Callable<Rectangle>() {
                public Rectangle call() throws Exception {
                    final T listView = getRealComponent();
                    listView.scrollTo(index.intValue());
                    listView.layout();
                    TraverseHelper<ListCell> helper = new TraverseHelper<ListCell>();
                    List<ListCell> lCells = helper.getInstancesOf(listView, ListCell.class);
                    for (ListCell cell : lCells) {
                        if (cell.getIndex() == index.intValue() && cell.getListView() == listView) {

                            Bounds b = cell.getBoundsInParent();
                            Point2D pos = cell.localToScreen(0, 0);
                            Point2D parentPos = listView.localToScreen(0, 0);
                            return new Rectangle(Rounding.round(pos.getX() - parentPos.getX()),
                                    Rounding.round(pos.getY() - parentPos.getY()), Rounding.round(b.getWidth()),
                                    Rounding.round(b.getHeight()));
                        }
                    }
                    return null;
                }
            });

    getRobot().click(getRealComponent(), r, co.setClickType(ClickOptions.ClickType.RELEASED));
}

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

@Override
public Rectangle getNodeBounds(final Object node) {
    Rectangle result = EventThreadQueuerJavaFXImpl.invokeAndWait("getNodeBounds", new Callable<Rectangle>() { //$NON-NLS-1$
        @Override//w w  w.  j av a  2s  .c  o  m
        public Rectangle call() throws Exception {
            List<? extends TreeCell> tCells = ComponentHandler.getAssignableFrom(TreeCell.class);
            for (TreeCell<?> cell : tCells) {
                TreeItem<?> item = cell.getTreeItem();
                TreeView<?> tree = (TreeView<?>) getTree();
                if ((item != null && item.equals(node))) {
                    // Update the layout coordinates otherwise
                    // we would get old position values
                    tree.layout();

                    Point2D posTree = tree.localToScreen(0, 0);
                    Point2D posCell = cell.localToScreen(0, 0);
                    Bounds b = cell.getBoundsInParent();
                    Rectangle cBounds = new Rectangle(
                            Math.abs(Rounding.round((posCell.getX() - posTree.getX()))),
                            Math.abs(Rounding.round((posCell.getY() - posTree.getY()))),
                            Rounding.round(b.getWidth()), Rounding.round(b.getHeight()));
                    return cBounds;
                }
            }
            return null;
        }
    });
    return result;
}

From source file:org.nmrfx.processor.gui.spectra.DrawSpectrum.java

public void drawSlice(DatasetAttributes datasetAttr, SliceAttributes sliceAttr, int orientation,
        double slicePosX, double slicePosY, Bounds bounds, double ph0, double ph1) {
    int sliceDim = orientation;
    Vec sliceVec = new Vec(32, false);
    boolean drawReal = datasetAttr.getDrawReal();
    boolean offsetTracking = sliceAttr.getOffsetTracking();
    try {//w  w w .j  a va  2  s . c om
        datasetAttr.getSlice(sliceVec, sliceDim, slicePosX, slicePosY);
        double level = datasetAttr.lvlProperty().get();
        double scale = -sliceAttr.getScaleValue() / level;
        //System.out.println(orientation + " " + slicePosX + " " + slicePosY);
        if (sliceDim == 0) {
            double offset;
            if (offsetTracking) {
                offset = axes[1].getDisplayPosition(slicePosY);
            } else {
                offset = bounds.getHeight() * (1.0 - sliceAttr.getOffsetYValue());
            }
            drawVector(sliceVec, orientation, 0, AXMODE.PPM, drawReal, ph0, ph1, null,
                    (index, intensity) -> axes[0].getDisplayPosition(index),
                    (index, intensity) -> intensity * scale + offset, false);
        } else {
            double offset;
            if (offsetTracking) {
                offset = axes[0].getDisplayPosition(slicePosX);
            } else {
                offset = bounds.getWidth() * sliceAttr.getOffsetXValue();
            }
            drawVector(sliceVec, orientation, 0, AXMODE.PPM, drawReal, ph0, ph1, null,
                    (index, intensity) -> -intensity * scale + offset,
                    (index, intensity) -> axes[1].getDisplayPosition(index), false);
        }
    } catch (IOException ioE) {
        System.out.println(ioE.getMessage());
    }
}