Example usage for javafx.geometry Point2D getX

List of usage examples for javafx.geometry Point2D getX

Introduction

In this page you can find the example usage for javafx.geometry Point2D getX.

Prototype

public final double getX() 

Source Link

Document

The x coordinate.

Usage

From source file:org.samcrow.frameviewer.trajectory.ui.FrameController.java

/**
 * Returns the trajectory near the requested frame position, or null
 * if none exists/*w ww  .j a  v a2s.  c  o m*/
 * <p>
 * @param framePosition
 * @return
 */
protected final Trajectory0 getTrajectoryNear(Point2D framePosition) {
    for (Trajectory0 trajectory : getTrajectories()) {
        try {
            final Point0 point = trajectory.get(getCurrentFrame());
            if (point != null) {
                // Find distance
                final double MAX_RADIUS = 6;
                final double MAX_RADIUS_SQUARED = MAX_RADIUS * MAX_RADIUS;

                final double dx = framePosition.getX() - point.getX();
                final double dy = framePosition.getY() - point.getY();

                final double distanceSquared = dx * dx + dy * dy;

                if (distanceSquared <= MAX_RADIUS_SQUARED) {
                    return trajectory;
                }

            }
            // else continue
        } catch (IndexOutOfBoundsException ex) {
            // Continue
        }
    }
    return null;
}

From source file:ua.com.ecotep.debtprevention.VnaklController.java

@FXML
private void handleDocSelectorAction(ActionEvent event) {
    if (selCl == null) {
        AlertDialog.showSimpleMessage("?    .",
                AlertDialog.ICON_INFO, parentInterface.getCurrentWindow());
        return;//from   w  w w. j ava2s .com
    }
    Task<Object> task = DPSession.getInstance().getTask();
    if ((task != null) && (task.isRunning())) {
        AlertDialog.showSimpleMessage(
                "?    ?, -? .",
                AlertDialog.ICON_FORBIDDEN, parentInterface.getCurrentWindow());
        return;
    }
    Scene sceneParent = parentInterface.getCurrentWindow().getScene();
    final Point2D windowCoord = new Point2D(sceneParent.getWindow().getX(), sceneParent.getWindow().getY());
    final Point2D sceneCoord = new Point2D(sceneParent.getX(), sceneParent.getY());
    final Point2D nodeCoord = addDocButton.localToScene(0.0, 0.0);
    final double coordX = Math.round(windowCoord.getX() + sceneCoord.getX() + nodeCoord.getX());
    final double coordY = Math
            .round(windowCoord.getY() + sceneCoord.getY() + nodeCoord.getY() + addDocButton.getHeight() + 6);

    try {
        selectorPopup = new Popup();
        selectorPopup.setAutoHide(true);
        selectorPopup.setAutoFix(true);
        selectorPopup.setHideOnEscape(true);

        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(getClass().getResource("/fxml/DocSelectScene.fxml"));

        AnchorPane root = (AnchorPane) loader.load();
        DocSelectController controller = loader.getController();
        controller.setParentInterface(this);
        Scene scene = new Scene(root);
        scene.setFill(null);
        selectorPopup.getContent().add(root);

        selectorPopup.setX(coordX);
        selectorPopup.setY(coordY);
        selectorPopup.show(parentInterface.getCurrentWindow());

    } catch (IOException ex) {
        Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
        AlertDialog.showSimpleMessage(
                "? ?    !",
                AlertDialog.ICON_ERROR, parentInterface.getCurrentWindow());
    }
}

From source file:view.EditorView.java

/**
 * Updates the position of tempRoomForRoomInsertion when the current edit mode is EditMode.INSERT_ROOM
 *//* ww w  . j  av  a2s .c o  m*/
private void insertRoomUpdateTempRoomPosition() {
    if (tempRoomForRoomInsertion != null) {
        // convert coordinates
        Point2D point = drawing.screenToLocal(currentMouseX - tempRoomForRoomInsertion.getWidth() / 2.0,
                currentMouseY - tempRoomForRoomInsertion.getHeight() / 2.0);
        tempRoomForRoomInsertion.setX(point.getX());
        tempRoomForRoomInsertion.setY(point.getY());
    }
}