javafx.scene.shape.CubicCurveTo Java Examples
The following examples show how to use
javafx.scene.shape.CubicCurveTo.
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: 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 #2
Source File: ViewFactory.java From latexdraw with GNU General Public License v3.0 | 6 votes |
@Override public void flushPathElement(final PathElement elt) { if(elt instanceof LineTo) { final LineTo lineTo = (LineTo) elt; lineTo.xProperty().unbind(); lineTo.yProperty().unbind(); }else { if(elt instanceof MoveTo) { final MoveTo moveTo = (MoveTo) elt; moveTo.xProperty().unbind(); moveTo.yProperty().unbind(); }else { if(elt instanceof CubicCurveTo) { final CubicCurveTo cct = (CubicCurveTo) elt; cct.xProperty().unbind(); cct.yProperty().unbind(); cct.controlX1Property().unbind(); cct.controlX2Property().unbind(); cct.controlY1Property().unbind(); cct.controlY2Property().unbind(); } } } }
Example #3
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 #4
Source File: RadarNodeChart.java From tilesfx with Apache License 2.0 | 6 votes |
private void addCircle(final Path PATH, final double CENTER_X, final double CENTER_Y, final double RADIUS) { // Control point calculation: (4/3)*tan(pi/8) = 4*(sqrt(2)-1)/3 = 0.552284749831 double cp = RADIUS * 0.552284749831; MoveTo mt1 = new MoveTo(CENTER_X, CENTER_Y - RADIUS); CubicCurveTo cc1 = new CubicCurveTo(CENTER_X + cp, CENTER_Y - RADIUS, CENTER_X + RADIUS, CENTER_Y - cp, CENTER_X + RADIUS, CENTER_Y); CubicCurveTo cc2 = new CubicCurveTo(CENTER_X + RADIUS, CENTER_Y + cp, CENTER_X + cp, CENTER_Y + RADIUS, CENTER_X, CENTER_Y + RADIUS); CubicCurveTo cc3 = new CubicCurveTo(CENTER_X - cp, CENTER_Y + RADIUS, CENTER_X - RADIUS, CENTER_Y + cp, CENTER_X - RADIUS, CENTER_Y); CubicCurveTo cc4 = new CubicCurveTo(CENTER_X - RADIUS, CENTER_Y - cp, CENTER_X - cp, CENTER_Y - RADIUS, CENTER_X, CENTER_Y - RADIUS); PATH.getElements().addAll(mt1, cc1, cc2, cc3, cc4); }
Example #5
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 #6
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 #7
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 #8
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 #9
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 #10
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); }
Example #11
Source File: TransitionPath.java From netbeans with Apache License 2.0 | 5 votes |
private void init(Stage primaryStage) { Group root = new Group(); primaryStage.setResizable(false); primaryStage.setScene(new Scene(root, 400,260)); Rectangle rect = new Rectangle (0, 0, 40, 40); rect.setArcHeight(10); rect.setArcWidth(10); rect.setFill(Color.ORANGE); root.getChildren().add(rect); Path path = PathBuilder.create() .elements( new MoveTo(20,20), new CubicCurveTo(380, 0, 380, 120, 200, 120), new CubicCurveTo(0, 120, 0, 240, 380, 240) ) .build(); path.setStroke(Color.DODGERBLUE); path.getStrokeDashArray().setAll(5d,5d); root.getChildren().add(path); pathTransition = PathTransitionBuilder.create() .duration(Duration.seconds(4)) .path(path) .node(rect) .orientation(OrientationType.ORTHOGONAL_TO_TANGENT) .cycleCount(Timeline.INDEFINITE) .autoReverse(true) .build(); }
Example #12
Source File: Helper.java From tilesfx with Apache License 2.0 | 5 votes |
public static final Path smoothPath(final ObservableList<PathElement> ELEMENTS, final boolean FILLED) { if (ELEMENTS.isEmpty()) { return new Path(); } final Point[] dataPoints = new Point[ELEMENTS.size()]; for (int i = 0; i < ELEMENTS.size(); i++) { final PathElement element = ELEMENTS.get(i); if (element instanceof MoveTo) { MoveTo move = (MoveTo) element; dataPoints[i] = new Point(move.getX(), move.getY()); } else if (element instanceof LineTo) { LineTo line = (LineTo) element; dataPoints[i] = new Point(line.getX(), line.getY()); } } double zeroY = ((MoveTo) ELEMENTS.get(0)).getY(); List<PathElement> smoothedElements = new ArrayList<>(); Pair<Point[], Point[]> result = calcCurveControlPoints(dataPoints); Point[] firstControlPoints = result.getKey(); Point[] secondControlPoints = result.getValue(); // Start path dependent on filled or not if (FILLED) { smoothedElements.add(new MoveTo(dataPoints[0].getX(), zeroY)); smoothedElements.add(new LineTo(dataPoints[0].getX(), dataPoints[0].getY())); } else { smoothedElements.add(new MoveTo(dataPoints[0].getX(), dataPoints[0].getY())); } // Add curves for (int i = 2; i < dataPoints.length; i++) { final int ci = i - 1; smoothedElements.add(new CubicCurveTo( firstControlPoints[ci].getX(), firstControlPoints[ci].getY(), secondControlPoints[ci].getX(), secondControlPoints[ci].getY(), dataPoints[i].getX(), dataPoints[i].getY())); } // Close the path if filled if (FILLED) { smoothedElements.add(new LineTo(dataPoints[dataPoints.length - 1].getX(), zeroY)); smoothedElements.add(new ClosePath()); } return new Path(smoothedElements); }
Example #13
Source File: StockTileSkin.java From OEE-Designer with MIT License | 5 votes |
private void drawTriangle() { MoveTo moveTo = new MoveTo(0.056 * size * 0.5, 0.032 * size * 0.5); CubicCurveTo cubicCurveTo1 = new CubicCurveTo(0.060 * size * 0.5, 0.028 * size * 0.5, 0.064 * size * 0.5, 0.028 * size * 0.5, 0.068 * size * 0.5, 0.032 * size * 0.5); CubicCurveTo cubicCurveTo2 = new CubicCurveTo(0.068 * size * 0.5, 0.032 * size * 0.5, 0.120 * size * 0.5, 0.080 * size * 0.5, 0.12 * size * 0.5, 0.080 * size * 0.5); CubicCurveTo cubicCurveTo3 = new CubicCurveTo(0.128 * size * 0.5, 0.088 * size * 0.5, 0.124 * size * 0.5, 0.096 * size * 0.5, 0.112 * size * 0.5, 0.096 * size * 0.5); CubicCurveTo cubicCurveTo4 = new CubicCurveTo(0.112 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5); CubicCurveTo cubicCurveTo5 = new CubicCurveTo(0.0, 0.096 * size * 0.5, -0.004 * size * 0.5, 0.088 * size * 0.5, 0.004 * size * 0.5, 0.080 * size * 0.5); CubicCurveTo cubicCurveTo6 = new CubicCurveTo(0.004 * size * 0.5, 0.080 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5); ClosePath closePath = new ClosePath(); triangle.getElements().setAll(moveTo, cubicCurveTo1, cubicCurveTo2, cubicCurveTo3, cubicCurveTo4, cubicCurveTo5, cubicCurveTo6, closePath); }
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: StockTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
private void drawTriangle() { MoveTo moveTo = new MoveTo(0.056 * size * 0.5, 0.032 * size * 0.5); CubicCurveTo cubicCurveTo1 = new CubicCurveTo(0.060 * size * 0.5, 0.028 * size * 0.5, 0.064 * size * 0.5, 0.028 * size * 0.5, 0.068 * size * 0.5, 0.032 * size * 0.5); CubicCurveTo cubicCurveTo2 = new CubicCurveTo(0.068 * size * 0.5, 0.032 * size * 0.5, 0.120 * size * 0.5, 0.080 * size * 0.5, 0.12 * size * 0.5, 0.080 * size * 0.5); CubicCurveTo cubicCurveTo3 = new CubicCurveTo(0.128 * size * 0.5, 0.088 * size * 0.5, 0.124 * size * 0.5, 0.096 * size * 0.5, 0.112 * size * 0.5, 0.096 * size * 0.5); CubicCurveTo cubicCurveTo4 = new CubicCurveTo(0.112 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5); CubicCurveTo cubicCurveTo5 = new CubicCurveTo(0.0, 0.096 * size * 0.5, -0.004 * size * 0.5, 0.088 * size * 0.5, 0.004 * size * 0.5, 0.080 * size * 0.5); CubicCurveTo cubicCurveTo6 = new CubicCurveTo(0.004 * size * 0.5, 0.080 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5); ClosePath closePath = new ClosePath(); triangle.getElements().setAll(moveTo, cubicCurveTo1, cubicCurveTo2, cubicCurveTo3, cubicCurveTo4, cubicCurveTo5, cubicCurveTo6, closePath); }
Example #16
Source File: LowerRightRegion.java From tilesfx with Apache License 2.0 | 5 votes |
private void resize() { width = getWidth() - getInsets().getLeft() - getInsets().getRight(); height = getHeight() - getInsets().getTop() - getInsets().getBottom(); size = width < height ? width : height; if (width > 0 && height > 0) { path.getElements().clear(); if (isRoundedCorner()) { path.getElements().add(new MoveTo(size, 0)); path.getElements().add(new LineTo(size, size * 0.81)); path.getElements().add(new CubicCurveTo(size, size * 0.915, size * 0.915, size, size * 0.81, size)); path.getElements().add(new LineTo(0, size)); path.getElements().add(new ClosePath()); } else { path.getElements().add(new MoveTo(size, 0)); path.getElements().add(new LineTo(size, size)); path.getElements().add(new LineTo(0, size)); path.getElements().add(new ClosePath()); } icon.getElements().clear(); icon.getElements().add(new MoveTo(size * 0.688, size * 0.494)); icon.getElements().add(new LineTo(size * 0.746, size * 0.494)); icon.getElements().add(new LineTo(size * 0.746, size * 0.768)); icon.getElements().add(new LineTo(size * 0.812, size * 0.704)); icon.getElements().add(new LineTo(size * 0.852, size * 0.744)); icon.getElements().add(new LineTo(size * 0.718, size * 0.878)); icon.getElements().add(new LineTo(size * 0.582, size * 0.744)); icon.getElements().add(new LineTo(size * 0.624, size * 0.704)); icon.getElements().add(new LineTo(size * 0.688, size * 0.768)); icon.getElements().add(new ClosePath()); redraw(); } }
Example #17
Source File: HighLowTileSkin.java From tilesfx with Apache License 2.0 | 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 #18
Source File: ViewFactory.java From latexdraw with GNU General Public License v3.0 | 5 votes |
@Override public boolean equals(final Object o) { if(this == o) { return true; } if(!(o instanceof CubicCurveTo)) { return false; } final CubicCurveTo that = (CubicCurveTo) o; if(Double.compare(that.getControlX1(), getControlX1()) != 0) { return false; } if(Double.compare(that.getControlY1(), getControlY1()) != 0) { return false; } if(Double.compare(that.getControlX2(), getControlX2()) != 0) { return false; } if(Double.compare(that.getControlY2(), getControlY2()) != 0) { return false; } if(Double.compare(that.getX(), getX()) != 0) { return false; } return Double.compare(that.getY(), getY()) == 0; }
Example #19
Source File: ViewBezierCurve.java From latexdraw with GNU General Public License v3.0 | 5 votes |
private final CubicCurveTo addCurveTo(final Point pt, final Point ctrl1, final Point ctrl2) { final CubicCurveTo curveto = pathProducer.createCubicCurveTo(0d, 0d, 0d, 0d, 0d, 0d); curveto.xProperty().bind(pt.xProperty()); curveto.yProperty().bind(pt.yProperty()); curveto.controlX1Property().bind(ctrl1.xProperty()); curveto.controlY1Property().bind(ctrl1.yProperty()); curveto.controlX2Property().bind(ctrl2.xProperty()); curveto.controlY2Property().bind(ctrl2.yProperty()); border.getElements().add(curveto); return curveto; }
Example #20
Source File: ViewArrowableTraitPath.java From latexdraw with GNU General Public License v3.0 | 5 votes |
@Override protected void clipPath(final Path path) { final Path clip = pathProducer.clonePath(path); clip.setFill(path.getFill()); clip.setStrokeWidth(path.getStrokeWidth()); if(!clip.getElements().isEmpty()) { // Defensive programming final Optional<Point> pt1 = getArrowReducedPoint(arrows.get(0).arrow); final Optional<Point> pt2 = getArrowReducedPoint(arrows.get(arrows.size() - 1).arrow); if(pt1.isPresent() && clip.getElements().get(0) instanceof MoveTo) { // Defensive programming // Changing the first point to the one at the beginning of the arrow. final MoveTo moveTo = (MoveTo) clip.getElements().get(0); moveTo.setX(pt1.get().getX()); moveTo.setY(pt1.get().getY()); } pt2.ifPresent(pt -> { if(clip.getElements().get(clip.getElements().size() - 1) instanceof LineTo) { final LineTo lineTo = (LineTo) clip.getElements().get(clip.getElements().size() - 1); lineTo.setX(pt.getX()); lineTo.setY(pt.getY()); }else if(clip.getElements().get(clip.getElements().size() - 1) instanceof CubicCurveTo) { final CubicCurveTo ccTo = (CubicCurveTo) clip.getElements().get(clip.getElements().size() - 1); ccTo.setX(pt.getX()); ccTo.setY(pt.getY()); } }); } clip.setStrokeWidth(path.getStrokeWidth()); clip.setStrokeLineCap(path.getStrokeLineCap()); path.setClip(clip); }
Example #21
Source File: TileSparklineSkin.java From Medusa with Apache License 2.0 | 5 votes |
public void smooth(final List<Double> DATA_LIST) { int size = DATA_LIST.size(); double[] x = new double[size]; double[] y = new double[size]; low = Statistics.getMin(DATA_LIST); high = Statistics.getMax(DATA_LIST); if (Double.compare(low, high) == 0) { low = minValue; high = maxValue; } range = high - low; double minX = graphBounds.getX(); double maxX = minX + graphBounds.getWidth(); double minY = graphBounds.getY(); double maxY = minY + graphBounds.getHeight(); double stepX = graphBounds.getWidth() / (noOfDatapoints - 1); double stepY = graphBounds.getHeight() / range; for (int i = 0 ; i < size ; i++) { x[i] = minX + i * stepX; y[i] = maxY - Math.abs(low - DATA_LIST.get(i)) * stepY; } Pair<Double[], Double[]> px = computeControlPoints(x); Pair<Double[], Double[]> py = computeControlPoints(y); sparkLine.getElements().clear(); for (int i = 0 ; i < size - 1 ; i++) { sparkLine.getElements().add(new MoveTo(x[i], y[i])); sparkLine.getElements().add(new CubicCurveTo(px.getKey()[i], py.getKey()[i], px.getValue()[i], py.getValue()[i], x[i + 1], y[i + 1])); } dot.setCenterX(maxX); dot.setCenterY(y[size - 1]); }
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 Point3D evalCubicBezier(CubicCurveTo c, Point3D ini, double t){ Point3D p=new Point3D((float)(Math.pow(1-t,3)*ini.x+ 3*t*Math.pow(1-t,2)*c.getControlX1()+ 3*(1-t)*t*t*c.getControlX2()+ Math.pow(t, 3)*c.getX()), (float)(Math.pow(1-t,3)*ini.y+ 3*t*Math.pow(1-t, 2)*c.getControlY1()+ 3*(1-t)*t*t*c.getControlY2()+ Math.pow(t, 3)*c.getY()), 0f); return p; }
Example #25
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 #26
Source File: ToolBarShapeHelper.java From chart-fx with Apache License 2.0 | 5 votes |
public static Shape getToolBarShape(final double width, final double height, final double radii) { final double centreX = 0.0; final double centreY = 0.0; final double halfWidth = 0.5 * width + 2 * radii; final double halfHeight = 0.5 * height; Path path = new Path(); // go to left-top most corner path.getElements().add(new MoveTo(centreX - halfWidth - 4 * radii, centreY - halfHeight)); // cubic sweep down path.getElements().add(new CubicCurveTo(// centreX - halfWidth - 2 * radii, centreY - halfHeight, // first control point centreX - halfWidth - 2 * radii, centreY + halfHeight, // second control point centreX - halfWidth, centreY + halfHeight)); // to coordinate // line on bottom path.getElements().add(new LineTo(centreX + halfWidth, centreY + halfHeight)); // cubic sweep up path.getElements().add(new CubicCurveTo(// centreX + halfWidth + 2 * radii, centreY + halfHeight, // first control point centreX + halfWidth + 2 * radii, centreY - halfHeight, // second control point centreX + halfWidth + 4 * radii, centreY - halfHeight)); // to coordinate // return to top left corner path.getElements().add(new LineTo(centreX - halfWidth - 2 * radii, centreY - halfHeight)); return path; }
Example #27
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 #28
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 #29
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 #30
Source File: PlainClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
private void createMinutePointer() { double width = size * 0.04723347; double height = size * 0.47503374; minute.setCache(false); minute.getElements().clear(); minute.getElements().add(new MoveTo(0.18571428571428572 * width, 0.9502840909090909 * height)); minute.getElements().add(new CubicCurveTo(0.18571428571428572 * width, 0.9332386363636364 * height, 0.32857142857142857 * width, 0.9190340909090909 * height, 0.5 * width, 0.9190340909090909 * height)); minute.getElements().add(new CubicCurveTo(0.6714285714285714 * width, 0.9190340909090909 * height, 0.8142857142857143 * width, 0.9332386363636364 * height, 0.8142857142857143 * width, 0.9502840909090909 * height)); minute.getElements().add(new CubicCurveTo(0.8142857142857143 * width, 0.9673295454545454 * height, 0.6714285714285714 * width, 0.9815340909090909 * height, 0.5 * width, 0.9815340909090909 * height)); minute.getElements().add(new CubicCurveTo(0.32857142857142857 * width, 0.9815340909090909 * height, 0.18571428571428572 * width, 0.9673295454545454 * height, 0.18571428571428572 * width, 0.9502840909090909 * height)); minute.getElements().add(new ClosePath()); minute.getElements().add(new MoveTo(0.0, 0.9502840909090909 * height)); minute.getElements().add(new CubicCurveTo(0.0, 0.9772727272727273 * height, 0.22857142857142856 * width, height, 0.5 * width, height)); minute.getElements().add(new CubicCurveTo(0.7714285714285715 * width, height, width, 0.9772727272727273 * height, width, 0.9502840909090909 * height)); minute.getElements().add(new CubicCurveTo(width, 0.9318181818181818 * height, 0.9 * width, 0.9147727272727273 * height, 0.7428571428571429 * width, 0.90625 * height)); minute.getElements().add(new CubicCurveTo(0.7428571428571429 * width, 0.90625 * height, 0.7428571428571429 * width, 0.05113636363636364 * height, 0.7428571428571429 * width, 0.05113636363636364 * height)); minute.getElements().add(new LineTo(0.5 * width, 0.0)); minute.getElements().add(new LineTo(0.2571428571428571 * width, 0.05113636363636364 * height)); minute.getElements().add(new CubicCurveTo(0.2571428571428571 * width, 0.05113636363636364 * height, 0.2571428571428571 * width, 0.90625 * height, 0.2571428571428571 * width, 0.90625 * height)); minute.getElements().add(new CubicCurveTo(0.1 * width, 0.9147727272727273 * height, 0.0, 0.9318181818181818 * height, 0.0, 0.9502840909090909 * height)); minute.getElements().add(new ClosePath()); minute.setCache(true); minute.setCacheHint(CacheHint.ROTATE); }