Example usage for javafx.geometry Point2D Point2D

List of usage examples for javafx.geometry Point2D Point2D

Introduction

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

Prototype

public Point2D(@NamedArg("x") double x, @NamedArg("y") double y) 

Source Link

Document

Creates a new instance of Point2D .

Usage

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

public void onMousePressed(final BaseObject baseObject, final MouseEvent event) {
    if (this.showConfigFrameOfObject(baseObject)) {
        event.consume();//from  ww w .j a  v  a2  s  .co m
    }
    if (baseObject instanceof BaseNode) {
        final BaseNode baseNode = (BaseNode) baseObject;
        this.dragPressedPoint = new Point2D(event.getX(), event.getY());
        this.dragOriginalObjectPosition = baseNode.getPosition();
    }
}

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();
        }/*from  w ww  .j  a  v  a 2  s  .  com*/
    }
}

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

void setDescription(final String value) {
    final String oldValue = this.descriptionInput.getText();
    if (StringUtils.isBlank(oldValue) && StringUtils.isNotBlank(value)) {
        final double defaultXY = 10d;
        this.descriptionNode.setPosition(new Point2D(defaultXY, defaultXY));
        this.descriptionNode.show();
    }/*from   w w w.  ja  v  a  2 s.  c  om*/
    if (StringUtils.isBlank(value)) {
        this.descriptionNode.hide();
    }
    this.descriptionInput.setText(value);
    this.descriptionNode.setContent(this.descriptionInput.getText());
}

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

private void mouseMovedOnPane(final MouseEvent event) {
    // Using double properties here to avoid spamming the heap with immutable objects like Point2D
    this.lastMousePositionOnPaneX = event.getX();
    this.lastMousePositionOnPaneY = event.getY();

    if (this.connectorSourceNode != null) {
        Validate.notNull(this.connector);
        if (this.currentConnectorTargetNode == null) {
            // Otherwise, connector was already aligned when object was hovered
            this.connector.align(this.connectorSourceNode, new Point2D(event.getX(), event.getY()));
        }//from  ww w  .j a va 2  s.  co m
    }
}

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

void startDrawingConnector(final BaseNode aConnectorSourceObject, final BaseEdge aConnector) {
    Validate.notNull(aConnectorSourceObject);
    Validate.notNull(aConnector);//from w w w.j  a v  a2 s.c  o m
    this.connectorSourceNode = aConnectorSourceObject;
    this.connector = aConnector;
    this.addObject(aConnector);
    this.connector.align(this.connectorSourceNode,
            new Point2D(this.lastMousePositionOnPaneX, this.lastMousePositionOnPaneY));
}

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

private Point2D getCenterPoint() {
    final double halfWay = 0.5;
    return new Point2D(this.rectangle.getX() + this.rectangle.getWidth() * halfWay,
            this.rectangle.getY() + this.rectangle.getHeight() * halfWay);
}

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

private List<Line> getBoundingLines() {
    final double l = this.rectangle.getX();
    final double t = this.rectangle.getY();
    final double b = t + this.rectangle.getHeight();
    final double r = l + this.rectangle.getWidth();
    final Point2D lt = new Point2D(l, t);
    final Point2D rt = new Point2D(r, t);
    final Point2D rb = new Point2D(r, b);
    final Point2D lb = new Point2D(l, b);
    return Arrays.asList(this.createLineBetweenTwoPoints(lt, rt), this.createLineBetweenTwoPoints(rt, rb),
            this.createLineBetweenTwoPoints(rb, lb), this.createLineBetweenTwoPoints(lb, lt));
}

From source file:com.panemu.tiwulfx.control.skin.LookupFieldSkin.java

private Point2D getPrefPopupPosition() {
    Point2D p = getSkinnable().localToScene(0.0, 0.0);
    Point2D p2 = new Point2D(
            p.getX() + getSkinnable().getScene().getX() + getSkinnable().getScene().getWindow().getX(),
            p.getY() + getSkinnable().getScene().getY() + getSkinnable().getScene().getWindow().getY()
                    + getSkinnable().getHeight());
    return p2;/*  ww  w  .  j av  a  2 s . c  om*/
}

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

@Override
protected Point2D getPosition() {
    return new Point2D(this.rectangle.getX(), this.rectangle.getY());
}

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

void loadFromJson(final IEdgeDefinition edge, final JSONObject edgeDesignerConfig) {
    Validate.notNull(edge);//from  w w w  . ja  va 2  s.co m
    Validate.notNull(edgeDesignerConfig);

    this.setId(edge.getId());
    this.setName(edge.getName());
    this.setDescription(edge.getDescription());
    this.setCheckExp(edge.getCheckExp());
    this.setRegExp(edge.getRegExp());
    this.setOnWalk(edge.getOnWalk());
    this.setTriggerOnEof(edge.getTriggerOnEof());
    this.setTriggerAlways(edge.getTriggerAlways());
    this.setRequiredConditions(edge.getRequiredConditions());
    this.timeIntervalSinceLastMicrotransition.fromTimeInterval(edge.getTimeIntervalSinceLastMicrotransition());
    this.timeIntervalSinceLastTransition.fromTimeInterval(edge.getTimeIntervalSinceLastTransition());
    this.timeIntervalSinceAutomatonStart.fromTimeInterval(edge.getTimeIntervalSinceAutomatonStart());
    this.timeIntervalForEvent.fromTimeInterval(edge.getTimeIntervalForEvent());
    this.timingConditionsUpdated();
    this.setChannel(edge.getChannel());

    PropertyNode.loadAllPropertyNodesFromJson(this.getPropertyNodes(), edgeDesignerConfig);

    final Double posX = edgeDesignerConfig.optDouble(JSON_KEY_EDGE_POS_X);
    final Double posY = edgeDesignerConfig.optDouble(JSON_KEY_EDGE_POS_Y);
    if (!Double.isNaN(posX) && !Double.isNaN(posY)) {
        this.setPosition(new Point2D(posX, posY));
    }
}