public final Point2D normalize(final double length) { final double x = getX(); final double y = getY(); if (((x == 0) && (y == 0)) || (length == 0)) { return this; } final double angle = Math.atan2(y, x); m_jso.set(Math.cos(angle) * length, Math.sin(angle) * length); return this; }
public final void normalize(double length) { double x = getX(); double y = getY(); if (((x == 0) && (y == 0)) || (length == 0)) { return; } double angle = Math.atan2(y, x); setX(Math.cos(angle) * length); setY(Math.sin(angle) * length); }
@Override public boolean apply(Node<?> node, double percent) { double x = m_origin.getX() + ((m_target.getX() - m_origin.getX()) * percent); double y = m_origin.getY() + ((m_target.getY() - m_origin.getY()) * percent); node.getAttributes().putPoint2D(m_attribute.getProperty(), new Point2D(x, y)); return true; } }
/** * Called when the Drag operation is done. * It basically updates the node's new (X,Y) attributes. * * Used internally. */ public void dragDone() { // update X,Y attributes m_prim.setX(m_prmx + m_lclp.getX()); m_prim.setY(m_prmy + m_lclp.getY()); }
/** * Sets the x and y coordinates to those of point P. * * @param p Point2D * @return this Point2D */ public final Point2D set(Point2D p) { m_jso.setX(p.getX()); m_jso.setY(p.getY()); return this; }
public final BoundingBox add(Point2D point) { m_jso.addX(point.getX()); m_jso.addY(point.getY()); return this; }
@Override public List<ControlPoint> getShapeControlPoints() { Counter counter = new Counter(-1); return StreamSupport.stream(getControlPoints().spliterator(), false) .map(point -> ControlPoint.build(new Point2D(point.getX(), point.getY()), counter.increment())) .sequential() .collect(Collectors.toList()); }
@Override public void onNodeDragStart(final NodeDragStartEvent nodeDragStartEvent) { dragStartLocations.clear(); for (WiresBaseShape shape : children) { dragStartLocations.add(new Pair<WiresBaseShape, Point2D>(shape, new Point2D(shape.getLocation().getX(), shape.getLocation().getY()))); } } });
private static final double closingArc(final PathPartList list, final Point2D p0, final Point2D p2, final Point2D p4, final Point2D plast, final Point2D p0new, final double radius) { final Point2D p1 = new Point2D(); final Point2D p3 = new Point2D(); final double closingRadius = adjustStartEndOffsets(p0, p2, p4, radius, p1, p3); list.M(p3.getX(), p3.getY()); plast.setX(p1.getX()); plast.setY(p1.getY()); p0new.setX(p3.getX()); p0new.setY(p3.getY()); return closingRadius; }
@Override public Point2D getShapeAbsoluteLocation() { final com.ait.lienzo.client.core.types.Point2D location = get().getAbsoluteLocation(); return Point2D.create(location.getX(), location.getY()); }
@Override public boolean add(final WiresConnector connector, final int index, final com.ait.lienzo.client.core.types.Point2D locatoin) { final Edge edge = getEdge(connector); if (validateControlPointState(edge)) { control.addControlPoints(edge, ControlPoint.build(locatoin.getX(), locatoin.getY(), index - 1)); return true; } return false; }
public static BoundingBox getBoundingBoxForQuadraticCurve(final Point2DArray points) { final NFastDoubleArray cubicPoints = quadraticToCubic(points.get(0).getX(), points.get(0).getY(), points.get(1).getX(), points.get(1).getY(), points.get(2).getX(), points.get(2).getY()); final double[] xval = new double[4]; final double[] yval = new double[4]; for (int i = 0; i < cubicPoints.size(); i = i + 2) { xval[i] = cubicPoints.get(i); yval[i] = cubicPoints.get(i + 1); } return getBoundingBoxOfCubicCurve(xval, yval); }
@Override public boolean contains(final double cx, final double cy) { final double _x = cx - getX(); final double _y = cy - getY(); return Math.sqrt(GeometryUtil.ptSegDistSq(arrow.getPoints().get(0).getX(), arrow.getPoints().get(0).getY(), arrow.getPoints().get(1).getX(), arrow.getPoints().get(1).getY(), _x, _y)) < BOUNDARY_SIZE; }
@Override public boolean contains(final double cx, final double cy) { final double _x = cx - getX(); final double _y = cy - getY(); return Math.sqrt(GeometryUtil.ptSegDistSq(line.getPoints().get(0).getX(), line.getPoints().get(0).getY(), line.getPoints().get(1).getX(), line.getPoints().get(1).getY(), _x, _y)) < BOUNDARY_SIZE; }
@Override public void addDecisionTable(final GuidedDecisionTableView gridWidget) { //Ensure the first Decision Table is visible if (gridLayer.getGridWidgets().isEmpty()) { final Point2D translation = getTranslation(gridWidget); final Transform t = gridLayer.getViewport().getTransform(); t.translate(translation.getX(), translation.getY()); } gridLayer.add(gridWidget); gridLayer.batch(); }
@Override public WiresShapeToolbox grid(final Point2DGrid grid) { toolbox.grid(grid); // Add some padding to fit the grid with a shape.. final Point2D go = getGridOffset(grid, toolbox.getAt()); gridOffset.setX(go.getX()); gridOffset.setY(go.getY()); return reposition(); }
@Override public boolean apply(final Node<?> node, final double percent) { final Point2D posn = m_calc.calculate(percent); if (posn != null) { node.getAttributes().put(Attribute.X.getProperty(), posn.getX()); node.getAttributes().put(Attribute.Y.getProperty(), posn.getY()); return true; } return false; }
@Override public void onNodeDragMove(final NodeDragMoveEvent event) { final IPrimitive<?> primitive = (IPrimitive<?>) event.getSource(); final Point2D adjust = m_connectorControl.adjustControlPointAt(primitive.getX(), primitive.getY(), event.getX(), event.getY()); if (adjust != null) { primitive.setX(adjust.getX()); primitive.setY(adjust.getY()); } } }
public void draw(final Point2DArray points) { final Point2D p1 = points.get(1); final double px = p1.getX(); final double py = p1.getY(); final double w2 = getWidth() / 2; final double dt = Geometry.getClockwiseAngleBetweenThreePoints(new Point2D(px, py + getHeight()), p1, points.get(0)); m_path.setX(px - w2).setY(py).setOffset(w2, 0).setRotation(dt); }