Example usage for javafx.geometry Bounds getWidth

List of usage examples for javafx.geometry Bounds getWidth

Introduction

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

Prototype

public final double getWidth() 

Source Link

Document

The width of this Bounds .

Usage

From source file:Main.java

/**
 * Converts a Bound to a Dimension.  Note that some information will be
 * lost (depth, x, y, etc) yet the width and height will be preserved
 * @param pBound/*  www.j a  va 2s  .  co m*/
 * @return
 */
public static Dimension convertToDimension(Bounds pBound) {
    Dimension result = new Dimension();
    result.setSize(pBound.getWidth(), pBound.getHeight());
    return result;
}

From source file:com.eviware.loadui.ui.fx.util.NodeUtils.java

public static Bounds absoluteBoundsOf(Node node) {
    double tX = node.getScene().getWindow().getX() + node.getScene().getX();
    double tY = node.getScene().getWindow().getY() + node.getScene().getY();
    Bounds boundsInScene = node.localToScene(node.getBoundsInLocal());
    return new BoundingBox(boundsInScene.getMinX() + tX, boundsInScene.getMinY() + tY, boundsInScene.getWidth(),
            boundsInScene.getHeight());//ww  w  .j  ava  2 s.  c  om
}

From source file:Main.java

public void setCamTranslate(final Cam cam) {
    final Bounds bounds = cam.getBoundsInLocal();
    final double pivotX = bounds.getMinX() + bounds.getWidth() / 2;
    final double pivotY = bounds.getMinY() + bounds.getHeight() / 2;
    cam.t.setX(-pivotX);//from w  w w. ja va 2 s .co  m
    cam.t.setY(-pivotY);
}

From source file:Main.java

public void setCamPivot(final Cam cam) {
    final Bounds bounds = cam.getBoundsInLocal();
    final double pivotX = bounds.getMinX() + bounds.getWidth() / 2;
    final double pivotY = bounds.getMinY() + bounds.getHeight() / 2;
    final double pivotZ = bounds.getMinZ() + bounds.getDepth() / 2;
    cam.p.setX(pivotX);/*w w w.java 2  s  . com*/
    cam.p.setY(pivotY);
    cam.p.setZ(pivotZ);
    cam.ip.setX(-pivotX);
    cam.ip.setY(-pivotY);
    cam.ip.setZ(-pivotZ);
}

From source file:Main.java

public void setCamScale(final Cam cam, final Scene scene) {
    final Bounds bounds = cam.getBoundsInLocal();
    final double pivotX = bounds.getMinX() + bounds.getWidth() / 2;
    final double pivotY = bounds.getMinY() + bounds.getHeight() / 2;
    final double pivotZ = bounds.getMinZ() + bounds.getDepth() / 2;

    double width = scene.getWidth();
    double height = scene.getHeight();

    double scaleFactor = 1.0;
    double scaleFactorY = 1.0;
    double scaleFactorX = 1.0;
    if (bounds.getWidth() > 0.0001) {
        scaleFactorX = width / bounds.getWidth(); // / 2.0;
    }/*from w  ww  .j  a  va 2  s. c o  m*/
    if (bounds.getHeight() > 0.0001) {
        scaleFactorY = height / bounds.getHeight(); //  / 1.5;
    }
    if (scaleFactorX > scaleFactorY) {
        scaleFactor = scaleFactorY;
    } else {
        scaleFactor = scaleFactorX;
    }
    cam.s.setX(scaleFactor);
    cam.s.setY(scaleFactor);
    cam.s.setZ(scaleFactor);
}

From source file:Main.java

public void resetCam() {
    cam.t.setX(0.0);/*from w ww.  java2  s .  c  o m*/
    cam.t.setY(0.0);
    cam.t.setZ(0.0);
    cam.rx.setAngle(45.0);
    cam.ry.setAngle(-7.0);
    cam.rz.setAngle(0.0);
    cam.s.setX(1.25);
    cam.s.setY(1.25);
    cam.s.setZ(1.25);

    cam.p.setX(0.0);
    cam.p.setY(0.0);
    cam.p.setZ(0.0);

    cam.ip.setX(0.0);
    cam.ip.setY(0.0);
    cam.ip.setZ(0.0);

    final Bounds bounds = cam.getBoundsInLocal();
    final double pivotX = bounds.getMinX() + bounds.getWidth() / 2;
    final double pivotY = bounds.getMinY() + bounds.getHeight() / 2;
    final double pivotZ = bounds.getMinZ() + bounds.getDepth() / 2;

    cam.p.setX(pivotX);
    cam.p.setY(pivotY);
    cam.p.setZ(pivotZ);

    cam.ip.setX(-pivotX);
    cam.ip.setY(-pivotY);
    cam.ip.setZ(-pivotZ);
}

From source file:eu.mihosoft.vrl.fxscad.MainController.java

private void setMeshScale(MeshContainer meshContainer, Bounds t1, final MeshView meshView) {
    double maxDim = Math.max(meshContainer.getWidth(),
            Math.max(meshContainer.getHeight(), meshContainer.getDepth()));

    double minContDim = Math.min(t1.getWidth(), t1.getHeight());

    double scale = minContDim / (maxDim * 2);

    meshView.setScaleX(scale);/*from   ww w  .  j  a  v a2 s. com*/
    meshView.setScaleY(scale);
    meshView.setScaleZ(scale);
}

From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java

private void setMeshScale(MeshContainer meshContainer, Bounds t1, final MeshView meshView) {
    if (meshContainer != null) {
        double maxDim = Math.max(meshContainer.getWidth(),
                Math.max(meshContainer.getHeight(), meshContainer.getDepth()));

        double minContDim = Math.min(t1.getWidth(), t1.getHeight());

        double scale = minContDim / (maxDim * 2);

        meshView.setScaleX(scale);//  w  w  w .  ja  va 2s .  c om
        meshView.setScaleY(scale);
        meshView.setScaleZ(scale);
    }
}

From source file:Main.java

private void showBounds() {
    if (layoutCbx.isSelected()) {
        Bounds b = mainRect.getLayoutBounds();
        layoutBoundsRect.setX(b.getMinX());
        layoutBoundsRect.setY(b.getMinY());
        layoutBoundsRect.setWidth(b.getWidth());
        layoutBoundsRect.setHeight(b.getHeight());

        layoutBoundsRect.setVisible(true);
    } else {//from w  w  w  . jav  a  2s . c o m
        layoutBoundsRect.setVisible(false);
    }

    if (localCbx.isSelected()) {
        Bounds b1 = mainRect.getBoundsInLocal();

        Bounds b = b1; // mainRect.localToParent(b1);
        localBoundsRect.setX(b.getMinX());
        localBoundsRect.setY(b.getMinY());
        localBoundsRect.setWidth(b.getWidth());
        localBoundsRect.setHeight(b.getHeight());
        localBoundsRect.setVisible(true);
    } else {
        localBoundsRect.setVisible(false);
    }

    if (parentCbx.isSelected()) {
        Bounds b = mainRect.getBoundsInParent();
        parentBoundsRect.setX(b.getMinX());
        parentBoundsRect.setY(b.getMinY());
        parentBoundsRect.setWidth(b.getWidth());
        parentBoundsRect.setHeight(b.getHeight());
        parentBoundsRect.setVisible(true);
    } else {
        parentBoundsRect.setVisible(false);
    }
}

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

/**
 * Gets a location inside the component. If <code>offset</code> is
 * <code>null</code>, it returns the middle of the component otherwise it
 * adds the offset to the upper left corner.
 *
 * @param comp//  w ww . jav a  2 s  .  c o  m
 *            the component to get the location for
 * @param offset
 *            the offset
 * @throws IllegalArgumentException
 *             if <code>component</code> is null
 * @return the <b>global </b> coordinates of <code>component</code>
 */
private Point getLocation(Node comp, final Point offset) throws IllegalArgumentException {

    Validate.notNull(comp, "component must not be null"); //$NON-NLS-1$

    Scene s = comp.getScene();
    s.getRoot().layout();

    Point2D pos = comp.localToScreen(0, 0);

    double x = pos.getX();
    double y = pos.getY();
    if (offset == null) {
        final Bounds boundsInParent = comp.getBoundsInParent();
        x += boundsInParent.getWidth() / 2;
        y += boundsInParent.getHeight() / 2;
    } else {
        x += offset.x;
        y += offset.y;
    }

    return new Point(Rounding.round(x), Rounding.round(y));
}