@Override public void moveToRel(double x, double y) { l.add(makeAbsolute(false, new MoveTo(x, y))); }
/** * Create a path shape out of a list of points. * When the path is created the vessel will be added to the * TravellingVessels container. * @param vessel vessel that is traveling the path. * @param pointedPath input points. * @param scale scaling that is used on the path due to the sacle of the map. * @return shape representing a path. */ public Optional<Path> createPath(INavigableVessel vessel, List<Point2D> pointedPath, double scale) { Path path = new Path(); path.setStroke(Color.RED); path.setStrokeWidth(2); if (!pointedPath.isEmpty()) { Point2D p = pointedPath.get(0); MoveTo moveTo = new MoveTo(); moveTo.setX(p.getX() * scale); moveTo.setY(p.getY() * scale); path.getElements().add(moveTo); for (int i = 1; i < pointedPath.size(); i++) { p = pointedPath.get(i); LineTo lineTo = new LineTo(); lineTo.setX(p.getX() * scale); lineTo.setY(p.getY() * scale); path.getElements().add(lineTo); } } vessels.addVessel(vessel, Optional.ofNullable(path), pointedPath); return Optional.ofNullable(path); }
/** * Find the x coordinate where we the character for the given index starts * * @param index * the index * @return the location or <code>0</code> if not found */ @SuppressWarnings("deprecation") public double getCharLocation(int index) { int realIndex = index; for (Integer i : this.tabPositions) { if (i.intValue() < realIndex) { realIndex += this.tabCharAdvance.get() - 1; } } this.textNode.setImpl_caretPosition(realIndex); PathElement[] pathElements = this.textNode.getImpl_caretShape(); for (PathElement e : pathElements) { if (e instanceof MoveTo) { return this.textNode.localToParent(((MoveTo) e).getX(), 0).getX(); } } return 0.0; } }
@Override public void moveToRel(double x, double y) { l.add(makeAbsolute(false, new MoveTo(x, y))); }
@Override public void moveToAbs(double x, double y) { l.add(makeAbsolute(true, new MoveTo(x, y))); }
@Override public void moveToAbs(double x, double y) { l.add(makeAbsolute(true, new MoveTo(x, y))); }
@Nonnull public static Path createArrowToTop(int lineLength) { Path arrowHeadPath = new Path(); arrowHeadPath.getStyleClass().add("arrow"); arrowHeadPath.getElements().add(new MoveTo(0, -ARROW_LENGTH)); //start @ top of arrow arrowHeadPath.getElements().add(new LineTo(ARROW_WIDTH_HALF, 0)); //bottom right arrowHeadPath.getElements().add(new LineTo(-ARROW_WIDTH_HALF, 0)); //bottom left arrowHeadPath.getElements().add(new LineTo(0, -ARROW_LENGTH)); //back to top of arrow arrowHeadPath.getElements().add(new MoveTo(0, 0)); //middle bottom arrowHeadPath.getElements().add(new LineTo(0, lineLength)); //middle bottom return arrowHeadPath; } }
private PathElement[] createRectangle(double topLeftX, double topLeftY, double bottomRightX, double bottomRightY) { return new PathElement[] { new MoveTo(topLeftX, topLeftY), new LineTo(bottomRightX, topLeftY), new LineTo(bottomRightX, bottomRightY), new LineTo(topLeftX, bottomRightY), new LineTo(topLeftX, topLeftY) }; }
private Node createInsertionMarker(double lineHeight) { double lineWidth = lineHeight / 15d; double arrowSide = lineHeight / 2d; double arrowHeight = arrowSide / 2d; Path marker = new Path(); marker.getElements().add(new MoveTo(- arrowSide / 2d, - arrowHeight)); marker.getElements().add(new LineTo(+ arrowSide / 2d, - arrowHeight)); marker.getElements().add(new LineTo(+ lineWidth / 2d, 0)); marker.getElements().add(new LineTo(+ lineWidth / 2d, lineHeight)); marker.getElements().add(new LineTo(+ arrowSide / 2d, lineHeight + arrowHeight)); marker.getElements().add(new LineTo(- arrowSide / 2d, lineHeight + arrowHeight)); marker.getElements().add(new LineTo(- lineWidth / 2d, lineHeight)); marker.getElements().add(new LineTo(- lineWidth / 2d, 0)); marker.getElements().add(new ClosePath()); marker.setVisible(false); marker.getStyleClass().add("insertion-marker"); //$NON-NLS-1$ marker.setMouseTransparent(true); return marker; }
double mx = element.getX() + ptsSize; double my = element.getY() + ptsSize; path1.getElements().add(new MoveTo(x, y)); path1.getElements().add(new LineTo(mx, y)); path1.getElements().add(new LineTo(mx, my)); mx += ptsSize; my += ptsSize; path2.getElements().add(new MoveTo(x, y)); path2.getElements().add(new LineTo(mx, y)); path2.getElements().add(new LineTo(mx, my));
double mx = pts.getX() + ptsSize; double my = pts.getY() + ptsSize; path1.getElements().add(new MoveTo(x, y)); path1.getElements().add(new LineTo(mx, y)); path1.getElements().add(new LineTo(mx, my)); mx += ptsSize; my += ptsSize; path2.getElements().add(new MoveTo(x, y)); path2.getElements().add(new LineTo(mx, y)); path2.getElements().add(new LineTo(mx, my));
MoveTo e1 = new MoveTo(0, 0); path.getElements().add(e1);