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) }; }
/** * 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); }
shape = createRectangle(lineToTopRight.getX(), lineToTopRight.getY(), getWidth(), getHeight()); } else { shape = getRangeShape(start, paragraph.length()); int topRightIndex = bottomRightIndex - 1; LineTo lineToTopRight = (LineTo) shape[topRightIndex]; shape[topRightIndex] = new LineTo(getWidth(), lineToTopRight.getY()); shape[bottomRightIndex] = new LineTo(getWidth(), getHeight()); for (int i = 0; i < adjustLength; i++) { if (shape[i] instanceof MoveTo) { ((LineTo)shape[i + 1]).setX(getWidth()); ((LineTo)shape[i + 2]).setX(getWidth());
LineTo e3 = new LineTo(); e3.xProperty().bind(e2.xProperty().add(arrowWidth)); e3.setY(arrowHeight / 2.0); path.getElements().add(e3); LineTo e4 = new LineTo(); e4.xProperty().bind(e2.xProperty()); e4.setY(arrowHeight); path.getElements().add(e4); LineTo e6 = new LineTo(arrowWidth, arrowHeight / 2.0); path.getElements().add(e6); }else{
lineCTop = new LineTo(); lineCTop.xProperty().bind( Bindings.add(lineBTop.xProperty(), arrowSizeProperty)); lineCTop.yProperty().bind( Bindings.subtract(topEdgeProperty, arrowSizeProperty)); lineDTop = new LineTo(); lineDTop.xProperty().bind( Bindings.add(lineCTop.xProperty(), arrowSizeProperty)); lineDTop.yProperty().bind(topEdgeProperty); lineFTop = new LineTo(); lineFTop.xProperty().bind(centerXProperty); lineFTop.yProperty().bind( Bindings.subtract(topEdgeProperty, arrowSizeProperty)); lineGTop = new LineTo(); lineGTop.xProperty().bind( Bindings.add(centerXProperty, arrowSizeProperty)); lineGTop.yProperty().bind(topEdgeProperty); lineITop = new LineTo(); lineITop.xProperty().bind( Bindings.subtract(Bindings.subtract( rightEdgeMinusRadiusProperty, arrowIndentProperty), arrowSizeProperty)); lineITop.yProperty().bind( Bindings.subtract(topEdgeProperty, arrowSizeProperty));
@Override public void lineToAbs(double x, double y) { l.add(makeAbsolute(true, new LineTo(x, y))); }
@Override public void lineToRel(double x, double y) { l.add(makeAbsolute(false, new LineTo(x, y))); }
@Override public void lineToRel(double x, double y) { l.add(makeAbsolute(false, new LineTo(x, y))); }
@Override public void lineToAbs(double x, double y) { l.add(makeAbsolute(true, new LineTo(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 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 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)); path1.getElements().add(new LineTo(x, my)); path1.getElements().add(new ClosePath()); if (element.isDoubleFramed()) { my += ptsSize; path2.getElements().add(new MoveTo(x, y)); path2.getElements().add(new LineTo(mx, y)); path2.getElements().add(new LineTo(mx, my)); path2.getElements().add(new LineTo(x, my)); path2.getElements().add(new ClosePath()); return new Path[] {path1, path2};
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)); path1.getElements().add(new LineTo(x, my)); path1.getElements().add(new ClosePath()); if (path2 != null) { my += ptsSize; path2.getElements().add(new MoveTo(x, y)); path2.getElements().add(new LineTo(mx, y)); path2.getElements().add(new LineTo(mx, my)); path2.getElements().add(new LineTo(x, my)); path2.getElements().add(new ClosePath());
switch (pelement.getType()) { case LINE_TO: pelt = new LineTo( gis2screenx(pelement.getToX(), bounds), gis2screeny(pelement.getToY(), bounds));
switch (pelement.getType()) { case LINE_TO: pelt = new LineTo( gis2screenx(pelement.getToX(), bounds), gis2screeny(pelement.getToY(), bounds));