javafx.scene.shape.ClosePath Java Examples
The following examples show how to use
javafx.scene.shape.ClosePath.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlainAmpSkin.java From Medusa with Apache License 2.0 | 6 votes |
private void drawAverage() { double scaledWidth = width * 1.106; double centerX = width * 0.5; double centerY = height * 1.4; double minValue = gauge.getMinValue(); // Draw average average.getElements().clear(); double averageAngle = START_ANGLE - (gauge.getAverage() - minValue) * angleStep; double averageSize = Helper.clamp(2.0, 2.5, 0.01 * scaledWidth); double sinValue = Math.sin(Math.toRadians(averageAngle)); double cosValue = Math.cos(Math.toRadians(averageAngle)); average.getElements().add(new MoveTo(centerX + scaledWidth * 0.38 * sinValue, centerY + scaledWidth * 0.38 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle - averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle - averageSize)); average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle + averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle + averageSize)); average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue)); average.getElements().add(new ClosePath()); average.setFill(gauge.getAverageColor()); average.setStroke(gauge.getTickMarkColor()); }
Example #2
Source File: ShapeConverter.java From Enzo with Apache License 2.0 | 6 votes |
private static Path processPath(final List<String> PATH_LIST, final PathReader READER) { final Path PATH = new Path(); PATH.setFillRule(FillRule.EVEN_ODD); while (!PATH_LIST.isEmpty()) { if ("M".equals(READER.read())) { PATH.getElements().add(new MoveTo(READER.nextX(), READER.nextY())); } else if ("L".equals(READER.read())) { PATH.getElements().add(new LineTo(READER.nextX(), READER.nextY())); } else if ("C".equals(READER.read())) { PATH.getElements().add(new CubicCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY())); } else if ("Q".equals(READER.read())) { PATH.getElements().add(new QuadCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY())); } else if ("H".equals(READER.read())) { PATH.getElements().add(new HLineTo(READER.nextX())); } else if ("L".equals(READER.read())) { PATH.getElements().add(new VLineTo(READER.nextY())); } else if ("A".equals(READER.read())) { PATH.getElements().add(new ArcTo(READER.nextX(), READER.nextY(), 0, READER.nextX(), READER.nextY(), false, false)); } else if ("Z".equals(READER.read())) { PATH.getElements().add(new ClosePath()); } } return PATH; }
Example #3
Source File: SectionSkin.java From Medusa with Apache License 2.0 | 6 votes |
private void createNeedle() { double needleWidth = size * 0.04; double needleHeight = size * 0.4675; needle.getElements().clear(); needle.getElements().add(new MoveTo(0.3125 * needleWidth, 0.015957446808510637 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.3125 * needleWidth, 0.005319148936170213 * needleHeight, 0.4375 * needleWidth, 0.0, 0.5 * needleWidth, 0.0)); needle.getElements().add(new CubicCurveTo(0.5625 * needleWidth, 0.0, 0.6875 * needleWidth, 0.005319148936170213 * needleHeight, 0.6875 * needleWidth, 0.015957446808510637 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.6875 * needleWidth, 0.015957446808510637 * needleHeight, needleWidth, 0.9946808510638298 * needleHeight, needleWidth, 0.9946808510638298 * needleHeight)); needle.getElements().add(new LineTo(0.0, 0.9946808510638298 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.0, 0.9946808510638298 * needleHeight, 0.3125 * needleWidth, 0.015957446808510637 * needleHeight, 0.3125 * needleWidth, 0.015957446808510637 * needleHeight)); needle.getElements().add(new ClosePath()); needle.setFill(new LinearGradient(needle.getLayoutBounds().getMinX(), 0, needle.getLayoutBounds().getMaxX(), 0, false, CycleMethod.NO_CYCLE, new Stop(0.0, gauge.getNeedleColor().darker()), new Stop(0.5, gauge.getNeedleColor()), new Stop(1.0, gauge.getNeedleColor().darker()))); }
Example #4
Source File: SmoothAreaChartTileSkin.java From OEE-Designer with MIT License | 6 votes |
private void drawChart(final List<Point> POINTS) { if (POINTS.isEmpty()) return; Point[] points = smoothing ? Helper.subdividePoints(POINTS.toArray(new Point[0]), 8) : POINTS.toArray(new Point[0]); fillPath.getElements().clear(); fillPath.getElements().add(new MoveTo(0, height)); strokePath.getElements().clear(); strokePath.getElements().add(new MoveTo(points[0].getX(), points[0].getY())); for (Point p : points) { fillPath.getElements().add(new LineTo(p.getX(), p.getY())); strokePath.getElements().add(new LineTo(p.getX(), p.getY())); } fillPath.getElements().add(new LineTo(width, height)); fillPath.getElements().add(new LineTo(0, height)); fillPath.getElements().add(new ClosePath()); if (dataPointsVisible) { drawDataPoints(POINTS, tile.isFillWithGradient() ? tile.getGradientStops().get(0).getColor() : tile.getBarColor()); } }
Example #5
Source File: SmoothAreaChartTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
private void drawChart(final List<Point> POINTS) { if (POINTS.isEmpty()) return; Point[] points = smoothing ? Helper.subdividePoints(POINTS.toArray(new Point[0]), 8) : POINTS.toArray(new Point[0]); if (0 == points.length || null == points[0]) { return; } fillPath.getElements().clear(); fillPath.getElements().add(new MoveTo(0, height)); strokePath.getElements().clear(); strokePath.getElements().add(new MoveTo(points[0].getX(), points[0].getY())); for (Point p : points) { fillPath.getElements().add(new LineTo(p.getX(), p.getY())); strokePath.getElements().add(new LineTo(p.getX(), p.getY())); } fillPath.getElements().add(new LineTo(width, height)); fillPath.getElements().add(new LineTo(0, height)); fillPath.getElements().add(new ClosePath()); if (dataPointsVisible) { drawDataPoints(POINTS, tile.isFillWithGradient() ? tile.getGradientStops().get(0).getColor() : tile.getBarColor()); } }
Example #6
Source File: AmpSkin.java From Medusa with Apache License 2.0 | 6 votes |
private void drawAverage() { double scaledWidth = width * 1.106; double centerX = width * 0.5; double centerY = height * 0.77; double minValue = gauge.getMinValue(); // Draw average average.getElements().clear(); double averageAngle = START_ANGLE - (gauge.getAverage() - minValue) * angleStep; double averageSize = Helper.clamp(2.0, 2.5, 0.01 * scaledWidth); double sinValue = Math.sin(Math.toRadians(averageAngle)); double cosValue = Math.cos(Math.toRadians(averageAngle)); average.getElements().add(new MoveTo(centerX + scaledWidth * 0.38 * sinValue, centerY + scaledWidth * 0.38 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle - averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle - averageSize)); average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle + averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle + averageSize)); average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue)); average.getElements().add(new ClosePath()); average.setFill(gauge.getAverageColor()); average.setStroke(gauge.getTickMarkColor()); }
Example #7
Source File: ViewFactory.java From latexdraw with GNU General Public License v3.0 | 6 votes |
@Override public Optional<PathElement> createPathElement(final PathElement elt) { if(elt instanceof LineTo) { return Optional.of(createLineTo(((LineTo) elt).getX(), ((LineTo) elt).getY())); } if(elt instanceof MoveTo) { return Optional.of(createMoveTo(((MoveTo) elt).getX(), ((MoveTo) elt).getY())); } if(elt instanceof ClosePath) { return Optional.of(createClosePath()); } if(elt instanceof CubicCurveTo) { final CubicCurveTo curve = (CubicCurveTo) elt; return Optional.of(createCubicCurveTo(curve.getControlX1(), curve.getControlY1(), curve.getControlX2(), curve.getControlY2(), curve.getX(), curve.getY())); } return Optional.empty(); }
Example #8
Source File: RenderBoxHelperFX.java From paintera with GNU General Public License v2.0 | 6 votes |
public void renderCanvas(final Interval targetInterval, final Path canvas) { final double tX0 = targetInterval.min(0); final double tX1 = targetInterval.max(0); final double tY0 = targetInterval.min(1); final double tY1 = targetInterval.max(1); final double[] c000 = new double[] {tX0, tY0, 0}; final double[] c100 = new double[] {tX1, tY0, 0}; final double[] c010 = new double[] {tX0, tY1, 0}; final double[] c110 = new double[] {tX1, tY1, 0}; canvas.getElements().add(new MoveTo(perspectiveX(c000), perspectiveY(c000))); canvas.getElements().add(new LineTo(perspectiveX(c100), perspectiveY(c100))); canvas.getElements().add(new LineTo(perspectiveX(c110), perspectiveY(c110))); canvas.getElements().add(new LineTo(perspectiveX(c010), perspectiveY(c010))); canvas.getElements().add(new ClosePath()); }
Example #9
Source File: ArrowHead.java From graph-editor with Eclipse Public License 1.0 | 6 votes |
/** * Draws the arrow-head for its current size and position values. */ public void draw() { getElements().clear(); getElements().add(new MoveTo(x, y + length / 2)); getElements().add(new LineTo(x + width / 2, y - length / 2)); if (radius > 0) { final ArcTo arcTo = new ArcTo(); arcTo.setX(x - width / 2); arcTo.setY(y - length / 2); arcTo.setRadiusX(radius); arcTo.setRadiusY(radius); arcTo.setSweepFlag(true); getElements().add(arcTo); } else { getElements().add(new LineTo(x - width / 2, y - length / 2)); } getElements().add(new ClosePath()); }
Example #10
Source File: Gauge2TileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
private void drawNeedle() { double needleWidth = size * 0.04536638; double needleHeight = size * 0.23706897; needle.setCache(false); needle.getElements().clear(); needle.getElements().add(new MoveTo(needleWidth * 0.813182897862233, needleHeight *0.227272727272727)); needle.getElements().add(new CubicCurveTo(needleWidth * 0.754441805225653, needleHeight *0.0743545454545455, needleWidth *0.788052256532067, needleHeight * 0, needleWidth * 0.499643705463183, needleHeight * 0)); needle.getElements().add(new CubicCurveTo(needleWidth * 0.211235154394299, needleHeight *0, needleWidth *0.248907363420428, needleHeight * 0.0741090909090909, needleWidth * 0.186104513064133, needleHeight * 0.227272727272727)); needle.getElements().add(new LineTo(needleWidth * 0.000831353919239905, needleHeight * 0.886363636363636)); needle.getElements().add(new CubicCurveTo(needleWidth * -0.0155581947743468, needleHeight *0.978604545454545, needleWidth *0.211235154394299, needleHeight * 1, needleWidth * 0.499643705463183, needleHeight * 1)); needle.getElements().add(new CubicCurveTo(needleWidth * 0.788052256532067, needleHeight *1, needleWidth *1.0253919239905, needleHeight * 0.976459090909091, needleWidth * 0.998456057007126, needleHeight * 0.886363636363636)); needle.getElements().add(new LineTo(needleWidth * 0.813182897862233, needleHeight *0.227272727272727)); needle.getElements().add(new ClosePath()); needle.getElements().add(new MoveTo(needleWidth * 0.552826603325416, needleHeight *0.854286363636364)); needle.getElements().add(new CubicCurveTo(needleWidth * 0.536223277909739, needleHeight *0.852981818181818, needleWidth *0.518313539192399, needleHeight * 0.852272727272727, needleWidth * 0.499643705463183, needleHeight * 0.852272727272727)); needle.getElements().add(new CubicCurveTo(needleWidth * 0.480237529691211, needleHeight *0.852272727272727, needleWidth *0.46166270783848, needleHeight * 0.853040909090909, needleWidth * 0.444513064133017, needleHeight * 0.854445454545455)); needle.getElements().add(new CubicCurveTo(needleWidth * 0.37313539192399, needleHeight *0.858890909090909, needleWidth *0.321496437054632, needleHeight * 0.871736363636364, needleWidth * 0.321496437054632, needleHeight * 0.886868181818182)); needle.getElements().add(new CubicCurveTo(needleWidth * 0.321496437054632, needleHeight *0.905681818181818, needleWidth *0.401330166270784, needleHeight * 0.920959090909091, needleWidth * 0.499643705463183, needleHeight * 0.920959090909091)); needle.getElements().add(new LineTo(needleWidth * 0.500285035629454, needleHeight *0.920959090909091)); needle.getElements().add(new CubicCurveTo(needleWidth * 0.598598574821853, needleHeight *0.920959090909091, needleWidth *0.678432304038005, needleHeight * 0.905681818181818, needleWidth * 0.678432304038005, needleHeight * 0.886868181818182)); needle.getElements().add(new CubicCurveTo(needleWidth * 0.678432304038005, needleHeight *0.871554545454545, needleWidth *0.625534441805226, needleHeight * 0.858581818181818, needleWidth * 0.552826603325416, needleHeight * 0.854286363636364)); needle.getElements().add(new ClosePath()); needle.setCache(true); needle.setCacheHint(CacheHint.ROTATE); }
Example #11
Source File: CustomPlainAmpSkin.java From medusademo with Apache License 2.0 | 6 votes |
private void drawAverage() { double scaledWidth = width * 1.106; double centerX = width * 0.5; double centerY = height * 1.4; double minValue = gauge.getMinValue(); // Draw average average.getElements().clear(); double averageAngle = START_ANGLE - (gauge.getAverage() - minValue) * angleStep; double averageSize = Helper.clamp(2.0, 2.5, 0.01 * scaledWidth); double sinValue = Math.sin(Math.toRadians(averageAngle)); double cosValue = Math.cos(Math.toRadians(averageAngle)); average.getElements().add(new MoveTo(centerX + scaledWidth * 0.38 * sinValue, centerY + scaledWidth * 0.38 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle - averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle - averageSize)); average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle + averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle + averageSize)); average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue)); average.getElements().add(new ClosePath()); average.setFill(gauge.getAverageColor()); average.setStroke(gauge.getTickMarkColor()); }
Example #12
Source File: LeaderBoardItem.java From OEE-Designer with MIT License | 5 votes |
private void drawTriangle() { MoveTo moveTo = new MoveTo(0, 0.028 * size); LineTo lineTo1 = new LineTo(0.022 * size, 0); LineTo lineTo2 = new LineTo(0.044 * size, 0.028 * size); LineTo lineTo3 = new LineTo(0, 0.028 * size); ClosePath closePath = new ClosePath(); triangle.getElements().setAll(moveTo, lineTo1, lineTo2, lineTo3, closePath); }
Example #13
Source File: InteractiveGaugeSkin.java From medusademo with Apache License 2.0 | 5 votes |
private void drawAverage() { double centerX = size * 0.5; double centerY = size * 0.5; // Draw average average.getElements().clear(); double averageAngle; if (ScaleDirection.CLOCKWISE == scaleDirection) { averageAngle = startAngle - (getSkinnable().getAverage() - minValue) * angleStep; } else { averageAngle = startAngle + (getSkinnable().getAverage() - minValue) * angleStep; } double averageSize = Helper.clamp(3.0, 3.5, 0.01 * size); double sinValue = Math.sin(Math.toRadians(averageAngle)); double cosValue = Math.cos(Math.toRadians(averageAngle)); switch (tickLabelLocation) { case OUTSIDE: average.getElements().add(new MoveTo(centerX + size * 0.38 * sinValue, centerY + size * 0.38 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle - averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle - averageSize)); average.getElements().add(new LineTo(centerX + size * 0.34 * sinValue, centerY + size * 0.34 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle + averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle + averageSize)); average.getElements().add(new LineTo(centerX + size * 0.34 * sinValue, centerY + size * 0.34 * cosValue)); average.getElements().add(new ClosePath()); break; case INSIDE: default: average.getElements().add(new MoveTo(centerX + size * 0.465 * sinValue, centerY + size * 0.465 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle - averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle - averageSize)); average.getElements().add(new LineTo(centerX + size * 0.425 * sinValue, centerY + size * 0.425 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle + averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle + averageSize)); average.getElements().add(new LineTo(centerX + size * 0.425 * sinValue, centerY + size * 0.425 * cosValue)); average.getElements().add(new ClosePath()); break; } average.setFill(getSkinnable().getAverageColor()); average.setStroke(getSkinnable().getTickMarkColor()); }
Example #14
Source File: HighLowTileSkin.java From OEE-Designer with MIT License | 5 votes |
private void drawTriangle() { MoveTo moveTo = new MoveTo(0.056 * size, 0.032 * size); CubicCurveTo cubicCurveTo1 = new CubicCurveTo(0.060 * size, 0.028 * size, 0.064 * size, 0.028 * size, 0.068 * size, 0.032 * size); CubicCurveTo cubicCurveTo2 = new CubicCurveTo(0.068 * size, 0.032 * size, 0.120 * size, 0.080 * size, 0.12 * size, 0.080 * size); CubicCurveTo cubicCurveTo3 = new CubicCurveTo(0.128 * size, 0.088 * size, 0.124 * size, 0.096 * size, 0.112 * size, 0.096 * size); CubicCurveTo cubicCurveTo4 = new CubicCurveTo(0.112 * size, 0.096 * size, 0.012 * size, 0.096 * size, 0.012 * size, 0.096 * size); CubicCurveTo cubicCurveTo5 = new CubicCurveTo(0.0, 0.096 * size, -0.004 * size, 0.088 * size, 0.004 * size, 0.080 * size); CubicCurveTo cubicCurveTo6 = new CubicCurveTo(0.004 * size, 0.080 * size, 0.056 * size, 0.032 * size, 0.056 * size, 0.032 * size); ClosePath closePath = new ClosePath(); triangle.getElements().setAll(moveTo, cubicCurveTo1, cubicCurveTo2, cubicCurveTo3, cubicCurveTo4, cubicCurveTo5, cubicCurveTo6, closePath); }
Example #15
Source File: LeaderBoardItem.java From tilesfx with Apache License 2.0 | 5 votes |
private void drawTriangle() { MoveTo moveTo = new MoveTo(0, 0.028 * size); LineTo lineTo1 = new LineTo(0.022 * size, 0); LineTo lineTo2 = new LineTo(0.044 * size, 0.028 * size); LineTo lineTo3 = new LineTo(0, 0.028 * size); ClosePath closePath = new ClosePath(); triangle.getElements().setAll(moveTo, lineTo1, lineTo2, lineTo3, closePath); }
Example #16
Source File: JFXToSVG.java From latexdraw with GNU General Public License v3.0 | 5 votes |
private SVGPathSeg createSVGPathSeg(final PathElement elt) { if(elt instanceof LineTo) { return createSVGPathSegLineto((LineTo) elt); } if(elt instanceof MoveTo) { return createSVGPathSegMoveto((MoveTo) elt); } if(elt instanceof ClosePath) { return new SVGPathSegClosePath(); } if(elt instanceof CubicCurveTo) { return createSVGPathSegCurvetoCubic((CubicCurveTo) elt); } return null; }
Example #17
Source File: RotationHandler.java From latexdraw with GNU General Public License v3.0 | 5 votes |
/** * The constructor by default. * @param border The selection border. */ public RotationHandler(final @NotNull Rectangle border) { super(); final Arc arc = new Arc(); arc.setCenterX(DEFAULT_SIZE / 2d); arc.setRadiusX(DEFAULT_SIZE / 2d); arc.setRadiusY(DEFAULT_SIZE / 2d); arc.setType(ArcType.OPEN); arc.setLength(270d); arc.setStroke(DEFAULT_COLOR); arc.setStrokeWidth(2.5d); arc.setStrokeLineCap(StrokeLineCap.BUTT); arc.setFill(new Color(1d, 1d, 1d, 0d)); getChildren().add(arc); final Path arrows = new Path(); arrows.setStroke(null); arrows.setFill(new Color(0d, 0d, 0d, 0.4)); arrows.getElements().add(new MoveTo(DEFAULT_SIZE + DEFAULT_SIZE / 4d, 0d)); arrows.getElements().add(new LineTo(DEFAULT_SIZE, DEFAULT_SIZE / 2d)); arrows.getElements().add(new LineTo(DEFAULT_SIZE - DEFAULT_SIZE / 4d, 0d)); arrows.getElements().add(new ClosePath()); getChildren().add(arrows); translateXProperty().bind(Bindings.createDoubleBinding(() -> border.getLayoutX() + border.getWidth(), border.xProperty(), border.widthProperty(), border.layoutXProperty())); translateYProperty().bind(Bindings.createDoubleBinding(() -> border.getLayoutY() + DEFAULT_SIZE, border.yProperty(), border.heightProperty(), border.layoutYProperty())); }
Example #18
Source File: PathSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public PathSample() { super(180,90); // Create path shape - square Path path1 = new Path(); path1.getElements().addAll( new MoveTo(25, 25), new HLineTo(65), new VLineTo(65), new LineTo(25, 65), new ClosePath() ); path1.setFill(null); path1.setStroke(Color.RED); path1.setStrokeWidth(2); // Create path shape - curves Path path2 = new Path(); path2.getElements().addAll( new MoveTo(100, 45), new CubicCurveTo(120, 20, 130, 80, 140, 45), new QuadCurveTo(150, 0, 160, 45), new ArcTo(20, 40, 0, 180, 45, true, true) ); path2.setFill(null); path2.setStroke(Color.DODGERBLUE); path2.setStrokeWidth(2); // show the path shapes; getChildren().add(new Group(path1, path2)); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Path 1 Stroke", path1.strokeProperty()), new SimplePropertySheet.PropDesc("Path 2 Stroke", path2.strokeProperty()) ); // END REMOVE ME }
Example #19
Source File: PathSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public PathSample() { super(180,90); // Create path shape - square Path path1 = new Path(); path1.getElements().addAll( new MoveTo(25, 25), new HLineTo(65), new VLineTo(65), new LineTo(25, 65), new ClosePath() ); path1.setFill(null); path1.setStroke(Color.RED); path1.setStrokeWidth(2); // Create path shape - curves Path path2 = new Path(); path2.getElements().addAll( new MoveTo(100, 45), new CubicCurveTo(120, 20, 130, 80, 140, 45), new QuadCurveTo(150, 0, 160, 45), new ArcTo(20, 40, 0, 180, 45, true, true) ); path2.setFill(null); path2.setStroke(Color.DODGERBLUE); path2.setStrokeWidth(2); // show the path shapes; getChildren().add(new Group(path1, path2)); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Path 1 Stroke", path1.strokeProperty()), new SimplePropertySheet.PropDesc("Path 2 Stroke", path2.strokeProperty()) ); // END REMOVE ME }
Example #20
Source File: TestViewShape.java From latexdraw with GNU General Public License v3.0 | 5 votes |
protected List<PathElement> duplicatePath(final List<PathElement> path) { return path.stream().map(elt -> { final PathElement dupelt; if(elt instanceof MoveTo) { final MoveTo moveTo = (MoveTo) elt; dupelt = factory.createMoveTo(moveTo.getX(), moveTo.getY()); }else { if(elt instanceof LineTo) { final LineTo lineTo = (LineTo) elt; dupelt = factory.createLineTo(lineTo.getX(), lineTo.getY()); }else { if(elt instanceof ClosePath) { dupelt = factory.createClosePath(); }else { if(elt instanceof CubicCurveTo) { final CubicCurveTo cct = (CubicCurveTo) elt; dupelt = factory.createCubicCurveTo(cct.getControlX1(), cct.getControlY1(), cct.getControlX2(), cct.getControlY2(), cct.getX(), cct.getY()); }else { throw new IllegalArgumentException(); } } } } dupelt.setAbsolute(elt.isAbsolute()); return dupelt; }).collect(Collectors.toList()); }
Example #21
Source File: QuarterSkin.java From Medusa with Apache License 2.0 | 5 votes |
private void drawAverage() { double scaledSize = size * 1.95; // Draw average average.getElements().clear(); double averageAngle; if (ScaleDirection.CLOCKWISE == scaleDirection) { averageAngle = startAngle - (gauge.getAverage() - minValue) * angleStep; } else { averageAngle = startAngle + (gauge.getAverage() - minValue) * angleStep; } double averageSize = Helper.clamp(3.0, 3.5, 0.01 * size); double sinValue = Math.sin(Math.toRadians(averageAngle)); double cosValue = Math.cos(Math.toRadians(averageAngle)); switch (tickLabelLocation) { case OUTSIDE: average.getElements().add(new MoveTo(centerX + scaledSize * 0.38 * sinValue, centerY + scaledSize * 0.38 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle - averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle - averageSize)); average.getElements().add(new LineTo(centerX + scaledSize * 0.34 * sinValue, centerY + scaledSize * 0.34 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle + averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle + averageSize)); average.getElements().add(new LineTo(centerX + scaledSize * 0.34 * sinValue, centerY + scaledSize * 0.34 * cosValue)); average.getElements().add(new ClosePath()); break; case INSIDE: default: average.getElements().add(new MoveTo(centerX + scaledSize * 0.465 * sinValue, centerY + scaledSize * 0.465 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle - averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle - averageSize)); average.getElements().add(new LineTo(centerX + scaledSize * 0.425 * sinValue, centerY + scaledSize * 0.425 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle + averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle + averageSize)); average.getElements().add(new LineTo(centerX + scaledSize * 0.425 * sinValue, centerY + scaledSize * 0.425 * cosValue)); average.getElements().add(new ClosePath()); break; } average.setFill(gauge.getAverageColor()); average.setStroke(gauge.getTickMarkColor()); }
Example #22
Source File: FatClockSkin.java From Medusa with Apache License 2.0 | 5 votes |
private void createHourPointer() { double width = size * 0.09733333; double height = size * 0.42066667; hour.setCache(false); hour.getElements().clear(); hour.getElements().add(new MoveTo(0.0, 0.0)); hour.getElements().add(new CubicCurveTo(0.0, 0.0, 0.0, 0.884310618066561 * height, 0.0, 0.884310618066561 * height)); hour.getElements().add(new CubicCurveTo(0.0, 0.9477020602218701 * height, 0.22602739726027396 * width, height, 0.5 * width, height)); hour.getElements().add(new CubicCurveTo(0.773972602739726 * width, height, width, 0.9477020602218701 * height, width, 0.884310618066561 * height)); hour.getElements().add(new CubicCurveTo(width, 0.884310618066561 * height, width, 0.0, width, 0.0)); hour.getElements().add(new LineTo(0.0, 0.0)); hour.getElements().add(new ClosePath()); hour.setCache(true); hour.setCacheHint(CacheHint.ROTATE); }
Example #23
Source File: FatClockSkin.java From Medusa with Apache License 2.0 | 5 votes |
private void createMinutePointer() { double width = size * 0.09733333; double height = size * 0.548; minute.setCache(false); minute.getElements().clear(); minute.getElements().add(new MoveTo(0.0, 0.0)); minute.getElements().add(new CubicCurveTo(0.0, 0.0, 0.0, 0.9111922141119222 * height, 0.0, 0.9111922141119222 * height)); minute.getElements().add(new CubicCurveTo(0.0, 0.9598540145985401 * height, 0.22602739726027396 * width, height, 0.5 * width, height)); minute.getElements().add(new CubicCurveTo(0.773972602739726 * width, height, width, 0.9598540145985401 * height, width, 0.9111922141119222 * height)); minute.getElements().add(new CubicCurveTo(width, 0.9111922141119222 * height, width, 0.0, width, 0.0)); minute.getElements().add(new LineTo(0.0, 0.0)); minute.getElements().add(new ClosePath()); minute.setCache(true); minute.setCacheHint(CacheHint.ROTATE); }
Example #24
Source File: Text3DHelper.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
private Path generatePath(){ Path path = new Path(new MoveTo(list.get(0).x,list.get(0).y)); list.stream().skip(1).forEach(p->path.getElements().add(new LineTo(p.x,p.y))); path.getElements().add(new ClosePath()); path.setStroke(Color.GREEN); // Path must be filled to allow Shape.intersect path.setFill(Color.RED); return path; }
Example #25
Source File: PathBuilder.java From jsilhouette with Apache License 2.0 | 5 votes |
public Path build() { Path path = new Path(); path.getElements().addAll(elements); path.getElements().add(new ClosePath()); elements.clear(); return path; }
Example #26
Source File: Geometry2Shape.java From gef with Eclipse Public License 2.0 | 5 votes |
/** * Converts the given {@link Path} to an array of JavaFX {@link PathElement} * s. * * @param path * The {@link Path} to convert. * @return The new array of {@link PathElement}s. */ public static PathElement[] toPathElements(Path path) { Segment[] segments = path.getSegments(); PathElement[] elements = new PathElement[segments.length]; for (int i = 0; i < segments.length; i++) { Point[] points = segments[i].getPoints(); // if (points.length > 0) { // System.out.println(i + ": " + points[points.length - 1]); // } switch (segments[i].getType()) { case Segment.MOVE_TO: elements[i] = new MoveTo(points[0].x, points[0].y); break; case Segment.LINE_TO: elements[i] = new LineTo(points[0].x, points[0].y); break; case Segment.QUAD_TO: elements[i] = new QuadCurveTo(points[0].x, points[0].y, points[1].x, points[1].y); break; case Segment.CUBIC_TO: elements[i] = new CubicCurveTo(points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y); break; case Segment.CLOSE: elements[i] = new ClosePath(); break; default: throw new IllegalStateException( "Unknown Path.Segment: <" + segments[i] + ">"); } } return elements; }
Example #27
Source File: GaugeSkin.java From Medusa with Apache License 2.0 | 5 votes |
private void drawAverage() { double centerX = size * 0.5; double centerY = size * 0.5; // Draw average average.getElements().clear(); double averageAngle; if (ScaleDirection.CLOCKWISE == scaleDirection) { averageAngle = startAngle - (gauge.getAverage() - minValue) * angleStep; } else { averageAngle = startAngle + (gauge.getAverage() - minValue) * angleStep; } double averageSize = Helper.clamp(3.0, 3.5, 0.01 * size); double sinValue = Math.sin(Math.toRadians(averageAngle)); double cosValue = Math.cos(Math.toRadians(averageAngle)); switch (tickLabelLocation) { case OUTSIDE: average.getElements().add(new MoveTo(centerX + size * 0.38 * sinValue, centerY + size * 0.38 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle - averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle - averageSize)); average.getElements().add(new LineTo(centerX + size * 0.34 * sinValue, centerY + size * 0.34 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle + averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle + averageSize)); average.getElements().add(new LineTo(centerX + size * 0.34 * sinValue, centerY + size * 0.34 * cosValue)); average.getElements().add(new ClosePath()); break; case INSIDE: default: average.getElements().add(new MoveTo(centerX + size * 0.465 * sinValue, centerY + size * 0.465 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle - averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle - averageSize)); average.getElements().add(new LineTo(centerX + size * 0.425 * sinValue, centerY + size * 0.425 * cosValue)); sinValue = Math.sin(Math.toRadians(averageAngle + averageSize)); cosValue = Math.cos(Math.toRadians(averageAngle + averageSize)); average.getElements().add(new LineTo(centerX + size * 0.425 * sinValue, centerY + size * 0.425 * cosValue)); average.getElements().add(new ClosePath()); break; } average.setFill(gauge.getAverageColor()); average.setStroke(gauge.getTickMarkColor()); }
Example #28
Source File: BatterySkin.java From Medusa with Apache License 2.0 | 5 votes |
private Path createVerticalBattery(final Path PATH) { PATH.getElements().clear(); PATH.getElements().add(new MoveTo(0.25 * size, 0.175 * size)); PATH.getElements().add(new CubicCurveTo(0.25 * size, 0.175 * size, 0.25 * size, 0.925 * size, 0.25 * size, 0.925 * size)); PATH.getElements().add(new CubicCurveTo(0.25 * size, 0.96875 * size, 0.28125 * size, size, 0.325 * size, size)); PATH.getElements().add(new CubicCurveTo(0.325 * size, size, 0.675 * size, size, 0.675 * size, size)); PATH.getElements().add(new CubicCurveTo(0.71875 * size, size, 0.75 * size, 0.96875 * size, 0.75 * size, 0.925 * size)); PATH.getElements().add(new CubicCurveTo(0.75 * size, 0.925 * size, 0.75 * size, 0.175 * size, 0.75 * size, 0.175 * size)); PATH.getElements().add(new CubicCurveTo(0.75 * size, 0.13125 * size, 0.71875 * size, 0.1 * size, 0.675 * size, 0.1 * size)); PATH.getElements().add(new CubicCurveTo(0.675 * size, 0.1 * size, 0.6 * size, 0.1 * size, 0.6 * size, 0.1 * size)); PATH.getElements().add(new LineTo(0.6 * size, 0.0)); PATH.getElements().add(new LineTo(0.4 * size, 0.0)); PATH.getElements().add(new LineTo(0.4 * size, 0.1 * size)); PATH.getElements().add(new CubicCurveTo(0.4 * size, 0.1 * size, 0.325 * size, 0.1 * size, 0.325 * size, 0.1 * size)); PATH.getElements().add(new CubicCurveTo(0.28125 * size, 0.1 * size, 0.25 * size, 0.13125 * size, 0.25 * size, 0.175 * size)); PATH.getElements().add(new ClosePath()); return PATH; }
Example #29
Source File: BatterySkin.java From Medusa with Apache License 2.0 | 5 votes |
private Path createHorizontalBattery(final Path PATH) { PATH.getElements().clear(); PATH.getElements().add(new MoveTo(0.825 * size, 0.25 * size)); PATH.getElements().add(new CubicCurveTo(0.825 * size, 0.25 * size, 0.075 * size, 0.25 * size, 0.075 * size, 0.25 * size)); PATH.getElements().add(new CubicCurveTo(0.03125 * size, 0.25 * size, 0.0, 0.28125 * size, 0.0, 0.325 * size)); PATH.getElements().add(new CubicCurveTo(0.0, 0.325 * size, 0.0, 0.675 * size, 0.0, 0.675 * size)); PATH.getElements().add(new CubicCurveTo(0.0, 0.71875 * size, 0.03125 * size, 0.75 * size, 0.075 * size, 0.75 * size)); PATH.getElements().add(new CubicCurveTo(0.075 * size, 0.75 * size, 0.825 * size, 0.75 * size, 0.825 * size, 0.75 * size)); PATH.getElements().add(new CubicCurveTo(0.86875 * size, 0.75 * size, 0.9 * size, 0.71875 * size, 0.9 * size, 0.675 * size)); PATH.getElements().add(new CubicCurveTo(0.9 * size, 0.675 * size, 0.9 * size, 0.6 * size, 0.9 * size, 0.6 * size)); PATH.getElements().add(new LineTo(size, 0.6 * size)); PATH.getElements().add(new LineTo(size, 0.4 * size)); PATH.getElements().add(new LineTo(0.9 * size, 0.4 * size)); PATH.getElements().add(new CubicCurveTo(0.9 * size, 0.4 * size, 0.9 * size, 0.325 * size, 0.9 * size, 0.325 * size)); PATH.getElements().add(new CubicCurveTo(0.9 * size, 0.28125 * size, 0.86875 * size, 0.25 * size, 0.825 * size, 0.25 * size)); PATH.getElements().add(new ClosePath()); return PATH; }
Example #30
Source File: KpiSkin.java From Medusa with Apache License 2.0 | 5 votes |
private void drawNeedle() { double needleWidth = size * 0.064; double needleHeight = size * 0.44; needle.setCache(false); needle.getElements().clear(); needle.getElements().add(new MoveTo(0.1875 * needleWidth, 0.0)); needle.getElements().add(new CubicCurveTo(0.1875 * needleWidth, 0.0, 0.1875 * needleWidth, 0.8727272727272727 * needleHeight, 0.1875 * needleWidth, 0.8727272727272727 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.0625 * needleWidth, 0.8818181818181818 * needleHeight, 0.0, 0.9 * needleHeight, 0.0, 0.9272727272727272 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.0, 0.9636363636363636 * needleHeight, 0.25 * needleWidth, needleHeight, 0.5 * needleWidth, needleHeight)); needle.getElements().add(new CubicCurveTo(0.75 * needleWidth, needleHeight, needleWidth, 0.9636363636363636 * needleHeight, needleWidth, 0.9272727272727272 * needleHeight)); needle.getElements().add(new CubicCurveTo(needleWidth, 0.9 * needleHeight, 0.9375 * needleWidth, 0.8818181818181818 * needleHeight, 0.8125 * needleWidth, 0.8727272727272727 * needleHeight)); needle.getElements().add(new CubicCurveTo(0.8125 * needleWidth, 0.8727272727272727 * needleHeight, 0.8125 * needleWidth, 0.0, 0.8125 * needleWidth, 0.0)); needle.getElements().add(new LineTo(0.1875 * needleWidth, 0.0)); needle.getElements().add(new ClosePath()); needle.setCache(true); needle.setCacheHint(CacheHint.ROTATE); }