Example usage for javafx.geometry Point2D getY

List of usage examples for javafx.geometry Point2D getY

Introduction

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

Prototype

public final double getY() 

Source Link

Document

The y coordinate.

Usage

From source file:Main.java

public static void addMarker(final XYChart<?, ?> chart, final StackPane chartWrap) {
    final Line valueMarker = new Line();
    final Node chartArea = chart.lookup(".chart-plot-background");

    chartArea.setOnMouseMoved(new EventHandler<MouseEvent>() {
        @Override/*ww  w  . ja  va2  s .c o m*/
        public void handle(MouseEvent event) {
            Point2D scenePoint = chart.localToScene(event.getSceneX(), event.getSceneY());
            Point2D position = chartWrap.sceneToLocal(scenePoint.getX(), scenePoint.getY());

            Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal());
            valueMarker.setStartY(0);
            valueMarker.setEndY(chartWrap.sceneToLocal(chartAreaBounds).getMaxY()
                    - chartWrap.sceneToLocal(chartAreaBounds).getMinY());

            valueMarker.setStartX(0);
            valueMarker.setEndX(0);
            valueMarker.setTranslateX(position.getX() - chartWrap.getWidth() / 2);

            double ydelta = chartArea.localToScene(0, 0).getY() - chartWrap.localToScene(0, 0).getY();
            valueMarker.setTranslateY(-ydelta * 2);
        }
    });

    chartWrap.getChildren().add(valueMarker);
}

From source file:de.pixida.logtest.designer.automaton.LineIntersector.java

static PointPosition getPointSideOfLine(final Point2D point, final Point2D lineStart, final Point2D lineEnd) {
    final double value = (lineEnd.getX() - lineStart.getX()) * (point.getY() - lineStart.getY())
            - (point.getX() - lineStart.getX()) * (lineEnd.getY() - point.getY());
    if (Math.abs(value) < EPSILON) {
        return PointPosition.ON_SAME_LINE;
    }//from   w  w w  . j ava  2s. c  om
    if (value < 0.0) {
        return PointPosition.RIGHT_OF_THE_LINE;
    }
    return PointPosition.LEFT_OF_THE_LINE;
}

From source file:de.pixida.logtest.designer.automaton.LineIntersector.java

static Point2D calculateIntersection(final Point2D point, final Point2D vec, final Line line) {
    final Point2D q = new Point2D(line.getStartX(), line.getStartY());
    final Point2D w = new Point2D(line.getEndX(), line.getEndY()).subtract(q);

    // q + t1 * w = point + t2 * vec => q - point = (vec w) (t2 -t1)^T
    final double det = det2x2LineWiseDefined(vec.getX(), w.getX(), vec.getY(), w.getY());
    final double epsilon = 1E-5;
    if (Math.abs(det) < epsilon) {
        return null;
    }//from  w  w  w .j a v a  2  s  .com
    final double detInv = 1.0 / det;
    final double t2 = det2x2LineWiseDefined(q.getX() - point.getX(), w.getX(), q.getY() - point.getY(),
            w.getY()) * detInv;

    final Point2D intersection = vec.multiply(t2).add(point);
    return intersection;
}

From source file:Main.java

public void placeMarker(Node newNode) {
    double nodeMinX = newNode.getLayoutBounds().getMinX();
    double nodeMinY = newNode.getLayoutBounds().getMinY();
    Point2D nodeInScene = newNode.localToScene(nodeMinX, nodeMinY);
    Point2D nodeInMarkerLocal = marker.sceneToLocal(nodeInScene);
    Point2D nodeInMarkerParent = marker.localToParent(nodeInMarkerLocal);

    marker.relocate(nodeInMarkerParent.getX() + marker.getLayoutBounds().getMinX(),
            nodeInMarkerParent.getY() + marker.getLayoutBounds().getMinY());
}

From source file:de.pixida.logtest.designer.automaton.RectangularNode.java

private Line createLineBetweenTwoPoints(final Point2D from, final Point2D to) {
    return new Line(from.getX(), from.getY(), to.getX(), to.getY());
}

From source file:de.pixida.logtest.designer.automaton.Graph.java

public void onMouseDragged(final BaseObject baseObject, final MouseEvent event) {
    if (baseObject instanceof BaseNode) {
        final BaseNode baseNode = (BaseNode) baseObject;
        Validate.notNull(this.dragPressedPoint);
        Validate.notNull(this.dragOriginalObjectPosition);

        final Point2D mouseMovement = new Point2D(event.getX(), event.getY()).subtract(this.dragPressedPoint);
        if (mouseMovement.getX() != 0d || mouseMovement.getY() != 0d) {
            Point2D newRectPos = this.dragOriginalObjectPosition.add(mouseMovement);
            newRectPos = new Point2D(Math.max(0d, newRectPos.getX()), Math.max(0d, newRectPos.getY()));
            baseNode.moveTo(newRectPos);
            this.handleMinorChange();
        }//  w w w  .  j av a  2 s .c  o  m
    }
}

From source file:de.pixida.logtest.designer.automaton.RectangularNode.java

@Override
protected void setPosition(final Point2D position) {
    this.rectangle.setX(Math.max(0d, position.getX()));
    this.rectangle.setY(Math.max(0d, position.getY()));
}

From source file:com.panemu.tiwulfx.form.BaseControl.java

public BaseControl(String propertyName, E control) {
    this.inputControl = control;
    this.propertyName = propertyName;
    HBox.setHgrow(control, Priority.ALWAYS);
    setAlignment(Pos.CENTER_LEFT);//from  w  w w. j a va  2s.  c o m
    control.setMaxWidth(Double.MAX_VALUE);
    control.setMinHeight(USE_PREF_SIZE);
    getChildren().add(control);
    getChildren().add(imagePlaceHolder);

    required.addListener(imageListener);
    valid.addListener(imageListener);

    this.getStyleClass().add("form-control");
    value = new SimpleObjectProperty<>();
    bindValuePropertyWithControl(control);
    bindEditablePropertyWithControl(control);

    addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.getEventType() == MouseEvent.MOUSE_MOVED && !isValid() && !getPopup().isShowing()) {
                Point2D p = BaseControl.this.localToScene(0.0, 0.0);
                getPopup().show(BaseControl.this, p.getX() + getScene().getX() + getScene().getWindow().getX(),
                        p.getY() + getScene().getY() + getScene().getWindow().getY()
                                + getInputComponent().getHeight() - 1);
            } else if (event.getEventType() == MouseEvent.MOUSE_EXITED && getPopup().isShowing()) {
                getPopup().hide();
            }
        }
    });
    getInputComponent().addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent t) {
            if (!isValid() && getPopup().isShowing()) {
                getPopup().hide();
            }
        }
    });
}

From source file:com.panemu.tiwulfx.form.BaseListControl.java

public BaseListControl(String propertyName, E control) {
    this.inputControl = control;
    this.propertyName = propertyName;
    HBox.setHgrow(control, Priority.ALWAYS);
    setAlignment(Pos.CENTER_LEFT);/*from w  w w.  ja  va 2s .c  o m*/
    control.setMaxWidth(Double.MAX_VALUE);
    control.setMinHeight(USE_PREF_SIZE);
    getChildren().add(control);
    getChildren().add(imagePlaceHolder);

    required.addListener(imageListener);
    valid.addListener(imageListener);

    this.getStyleClass().add("form-control");
    value = new SimpleListProperty<>();
    bindValuePropertyWithControl(control);
    bindEditablePropertyWithControl(control);

    addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.getEventType() == MouseEvent.MOUSE_MOVED && !isValid() && !getPopup().isShowing()) {
                Point2D p = BaseListControl.this.localToScene(0.0, 0.0);
                getPopup().show(BaseListControl.this,
                        p.getX() + getScene().getX() + getScene().getWindow().getX(),
                        p.getY() + getScene().getY() + getScene().getWindow().getY()
                                + getInputComponent().getHeight() - 1);
            } else if (event.getEventType() == MouseEvent.MOUSE_EXITED && getPopup().isShowing()) {
                getPopup().hide();
            }
        }
    });
    getInputComponent().addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent t) {
            if (!isValid() && getPopup().isShowing()) {
                getPopup().hide();
            }
        }
    });
}

From source file:net.rptools.image.listeners.DrawHandler.java

/**
 * Main work method./*w  ww .  j av  a  2  s .  c o m*/
 * @param phase phase of drawing we are in
 * @param newEnd new end of current draw
 * @param pen pen color
 * @param fill fill color
 * @param radius pen radius
 */
@ThreadPolicy(ThreadPolicy.ThreadId.JFX)
private void draw(final String phase, final Point2D newEnd, final String pen, final String fill,
        final int radius) {
    LOGGER.debug("phase={}; draw={}; pen={}; fill={}; radius={}", phase, newEnd, pen, fill, radius);

    if (phase.equals(START)) {
        currentShape = new Polygon();
        getLayer().getDrawable().getChildren().add(currentShape);
    }

    if (currentShape == null) {
        return;
    }

    currentShape.getPoints().addAll(newEnd.getX(), newEnd.getY());

    switch (fill.charAt(0)) {
    case '#':
        currentShape.setFill(Color.web(fill));
        break;
    case '-':
        currentShape.setFill(null);
        break;
    default:
        if (currentFill == null) {
            currentFill = getLayer().loadImage(fill);
        }
        currentShape.setFill(
                new ImagePattern(currentFill, 0, 0, currentFill.getWidth(), currentFill.getHeight(), false));
    }
    switch (pen.charAt(0)) {
    case '#':
        currentShape.setStroke(Color.web(pen));
        break;
    case '-':
        currentShape.setStroke(null);
        break;
    default:
        if (currentPen == null) {
            currentPen = getLayer().loadImage(pen);
        }
        currentShape.setStroke(
                new ImagePattern(currentPen, 0, 0, currentPen.getWidth(), currentPen.getHeight(), false));
    }
    currentShape.setStrokeLineCap(StrokeLineCap.ROUND);
    currentShape.setStrokeLineJoin(StrokeLineJoin.ROUND);
    currentShape.setStrokeWidth(radius);

    if (phase.equals(END)) {
        finalizeDrawing();
        currentShape = null;
        currentPen = null;
        currentFill = null;
    }
    LOGGER.debug("draw polygon completed={}", currentShape == null);
}