javafx.scene.shape.MoveTo Java Examples
The following examples show how to use
javafx.scene.shape.MoveTo.
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: StateTransitionEdgeViewer.java From JetUML with GNU General Public License v3.0 | 6 votes |
@Override public Canvas createIcon(Edge pEdge) { //CSOFF: Magic numbers Canvas canvas = new Canvas(BUTTON_SIZE, BUTTON_SIZE); GraphicsContext graphics = canvas.getGraphicsContext2D(); graphics.scale(0.6, 0.6); Line line = new Line(new Point(2,2), new Point(40,40)); final double tangent = Math.tan(Math.toRadians(DEGREES_10)); double dx = (line.getX2() - line.getX1()) / 2; double dy = (line.getY2() - line.getY1()) / 2; Point control = new Point((int)((line.getX1() + line.getX2()) / 2 + tangent * dy), (int)((line.getY1() + line.getY2()) / 2 - tangent * dx)); Path path = new Path(); MoveTo moveTo = new MoveTo(line.getPoint1().getX(), line.getPoint1().getY()); QuadCurveTo curveTo = new QuadCurveTo(control.getX(), control.getY(), line.getPoint2().getX(), line.getPoint2().getY()); path.getElements().addAll(moveTo, curveTo); ToolGraphics.strokeSharpPath(graphics, path, LineStyle.SOLID); ArrowHead.V.view().draw(graphics, control, new Point(40, 40)); return canvas; }
Example #2
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 #3
Source File: ObjectReferenceEdgeViewer.java From JetUML with GNU General Public License v3.0 | 6 votes |
private Path getCShape(Line pConnectionPoints) { final int x1 = Math.max(pConnectionPoints.getX1(), pConnectionPoints.getX2()) + ENDSIZE; final int y1 = pConnectionPoints.getY1(); final int x2 = x1 + ENDSIZE; final int y2 = pConnectionPoints.getY2(); final int ymid = (pConnectionPoints.getY1() + pConnectionPoints.getY2()) / 2; MoveTo moveTo = new MoveTo(pConnectionPoints.getX1(), y1); LineTo lineTo1 = new LineTo(x1, y1); QuadCurveTo quadTo1 = new QuadCurveTo(x2, y1, x2, ymid); QuadCurveTo quadTo2 = new QuadCurveTo(x2, y2, x1, y2); LineTo lineTo2 = new LineTo(pConnectionPoints.getX2(), y2); Path path = new Path(); path.getElements().addAll(moveTo, lineTo1, quadTo1, quadTo2, lineTo2); return path; }
Example #4
Source File: ParagraphOverlayGraphicFactory.java From markdown-writer-fx with BSD 2-Clause "Simplified" License | 6 votes |
protected Rectangle2D getBounds(int start, int end) { PathElement[] shape = getShape(start, end); double minX = 0, minY = 0, maxX = 0, maxY = 0; for (PathElement pathElement : shape) { if (pathElement instanceof MoveTo) { MoveTo moveTo = (MoveTo) pathElement; minX = maxX = moveTo.getX(); minY = maxY = moveTo.getY(); } else if (pathElement instanceof LineTo) { LineTo lineTo = (LineTo) pathElement; double x = lineTo.getX(); double y = lineTo.getY(); minX = Math.min(minX, x); minY = Math.min(minY, y); maxX = Math.max(maxX, x); maxY = Math.max(maxY, y); } } return new Rectangle2D(minX, minY, maxX - minX, maxY - minY); }
Example #5
Source File: ObjectReferenceEdgeViewer.java From JetUML with GNU General Public License v3.0 | 6 votes |
private Path getSShape(Line pConnectionPoints) { final int x1 = pConnectionPoints.getX1() + ENDSIZE; final int y1 = pConnectionPoints.getY1(); final int x2 = pConnectionPoints.getX2() - ENDSIZE; final int y2 = pConnectionPoints.getY2(); final int xmid = (pConnectionPoints.getX1() + pConnectionPoints.getX2()) / 2; final int ymid = (pConnectionPoints.getY1() + pConnectionPoints.getY2()) / 2; MoveTo moveTo = new MoveTo(pConnectionPoints.getX1(), y1); LineTo lineTo1 = new LineTo(x1, y1); QuadCurveTo quadTo1 = new QuadCurveTo((x1 + xmid) / 2, y1, xmid, ymid); QuadCurveTo quadTo2 = new QuadCurveTo((x2 + xmid) / 2, y2, x2, y2); LineTo lineTo2 = new LineTo(pConnectionPoints.getX2(), y2); Path path = new Path(); path.getElements().addAll(moveTo, lineTo1, quadTo1, quadTo2, lineTo2); return path; }
Example #6
Source File: ViewTriangle.java From latexdraw with GNU General Public License v3.0 | 6 votes |
private final void setupPath(final Path path) { final MoveTo moveTo = pathProducer.createMoveTo(0d, 0d); moveTo.xProperty().bind(Bindings.createDoubleBinding(() -> model.getPtAt(0).getX() + model.getWidth() / 2d, model.getPtAt(0).xProperty(), model.getPtAt(1).xProperty())); moveTo.yProperty().bind(model.getPtAt(0).yProperty()); path.getElements().add(moveTo); LineTo lineTo = pathProducer.createLineTo(0d, 0d); lineTo.xProperty().bind(model.getPtAt(2).xProperty()); lineTo.yProperty().bind(model.getPtAt(2).yProperty()); path.getElements().add(lineTo); lineTo = pathProducer.createLineTo(0d, 0d); lineTo.xProperty().bind(model.getPtAt(3).xProperty()); lineTo.yProperty().bind(model.getPtAt(3).yProperty()); path.getElements().add(lineTo); path.getElements().add(pathProducer.createClosePath()); }
Example #7
Source File: GaugeSparkLineTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
private void smooth(final List<Double> DATA_LIST) { Task<Point[]> smoothTask = new Task<Point[]>() { @Override protected Point[] call() { return Helper.smoothSparkLine(DATA_LIST, minValue, maxValue, graphBounds, noOfDatapoints); } }; smoothTask.setOnSucceeded(t -> { Point[] smoothedPoints = smoothTask.getValue(); int lengthMinusOne = smoothedPoints.length - 1; sparkLine.getElements().clear(); sparkLine.getElements().add(new MoveTo(smoothedPoints[0].getX(), smoothedPoints[0].getY())); for (int i = 1 ; i < lengthMinusOne ; i++) { sparkLine.getElements().add(new LineTo(smoothedPoints[i].getX(), smoothedPoints[i].getY())); } dot.setCenterX(smoothedPoints[lengthMinusOne].getX()); dot.setCenterY(smoothedPoints[lengthMinusOne].getY()); }); Thread smoothThread = new Thread(smoothTask); smoothThread.setDaemon(true); smoothThread.start(); }
Example #8
Source File: SparkLineTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
private void smooth(final List<Double> DATA_LIST) { Task<Point[]> smoothTask = new Task<Point[]>() { @Override protected Point[] call() { return Helper.smoothSparkLine(DATA_LIST, minValue, maxValue, graphBounds, noOfDatapoints); } }; smoothTask.setOnSucceeded(t -> { Point[] smoothedPoints = smoothTask.getValue(); int lengthMinusOne = smoothedPoints.length - 1; sparkLine.getElements().clear(); sparkLine.getElements().add(new MoveTo(smoothedPoints[0].getX(), smoothedPoints[0].getY())); for (int i = 1 ; i < lengthMinusOne ; i++) { sparkLine.getElements().add(new LineTo(smoothedPoints[i].getX(), smoothedPoints[i].getY())); } dot.setCenterX(smoothedPoints[lengthMinusOne].getX()); dot.setCenterY(smoothedPoints[lengthMinusOne].getY()); }); Thread smoothThread = new Thread(smoothTask); smoothThread.setDaemon(true); smoothThread.start(); }
Example #9
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 #10
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 #11
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 #12
Source File: TextFlowExt.java From RichTextFX with BSD 2-Clause "Simplified" License | 6 votes |
/** * @param from The index of the first character. * @param to The index of the last character. * @return An array with the PathElement objects which define an * underline from the first to the last character. */ PathElement[] getUnderlineShape(int from, int to) { // get a Path for the text underline PathElement[] shape = textLayout().getRange(from, to, TextLayout.TYPE_UNDERLINE, 0, 0); // The shape is returned as a closed Path (a thin rectangle). // If we use the Path as it is, this causes rendering issues. // Hence we only use the MoveTo and the succeeding LineTo elements for the result // so that simple line segments instead of rectangles are returned. List<PathElement> result = new ArrayList<>(); boolean collect = false; for (PathElement elem : shape) { if (elem instanceof MoveTo) { // There seems to be no API to get the type of the PathElement result.add(elem); collect = true; } else if (elem instanceof LineTo) { if (collect) { result.add(elem); collect = false; } } } return result.toArray(new PathElement[0]); }
Example #13
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 #14
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 #15
Source File: StockTileSkin.java From OEE-Designer with MIT License | 6 votes |
@Override protected void handleEvents(final String EVENT_TYPE) { super.handleEvents(EVENT_TYPE); if ("VISIBILITY".equals(EVENT_TYPE)) { Helper.enableNode(titleText, !tile.getTitle().isEmpty()); Helper.enableNode(valueText, tile.isValueVisible()); Helper.enableNode(timeSpanText, !tile.isTextVisible()); redraw(); } else if ("VALUE".equals(EVENT_TYPE)) { if(tile.isAnimated()) { tile.setAnimated(false); } if (!tile.isAveragingEnabled()) { tile.setAveragingEnabled(true); } double value = clamp(minValue, maxValue, tile.getValue()); addData(value); handleCurrentValue(value); } else if ("AVERAGING".equals(EVENT_TYPE)) { noOfDatapoints = tile.getAveragingPeriod(); // To get smooth lines in the chart we need at least 4 values if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3."); for (int i = 0; i < noOfDatapoints; i++) { dataList.add(minValue); } pathElements.clear(); pathElements.add(0, new MoveTo()); for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); } sparkLine.getElements().setAll(pathElements); redraw(); } }
Example #16
Source File: Bubble.java From ChatRoom-JavaFX with Apache License 2.0 | 5 votes |
private void drawRectBubbleRightBaselineIndicator() { getElements().addAll(new MoveTo(3.0f, 1.0f), new HLineTo(0f), new VLineTo(4f), new HLineTo(3.0f), new LineTo(2.8f, 3.8f), new VLineTo(1f) ); }
Example #17
Source File: Bubble.java From ChatRoom-JavaFX with Apache License 2.0 | 5 votes |
private void drawRectBubbleToplineIndicator() { getElements().addAll(new MoveTo(1.0f, 1.2f), new HLineTo(2.5f), new LineTo(2.7f, 1.0f), new LineTo(2.9f, 1.2f), new HLineTo(4.4f), new VLineTo(4f), new HLineTo(1.0f), new VLineTo(1.2f) ); }
Example #18
Source File: InfoRegion.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.23809524, 0)); path.getElements().add(new LineTo(size, 0)); path.getElements().add(new LineTo(0, size)); path.getElements().add(new LineTo(0, size * 0.23809524)); path.getElements().add(new QuadCurveTo(0, 0, size * 0.23809524, 0)); path.getElements().add(new ClosePath()); } else { path.getElements().add(new MoveTo(0, 0)); path.getElements().add(new LineTo(size, 0)); path.getElements().add(new LineTo(0, size)); path.getElements().add(new ClosePath()); } icon.getElements().clear(); icon.getElements().add(new MoveTo(size * 0.185714285714286, size * 0.119047619047619)); icon.getElements().add(new LineTo(size * 0.254761904761905, size * 0.185714285714286)); icon.getElements().add(new LineTo(size * 0.185714285714286, size * 0.254761904761905)); icon.getElements().add(new LineTo(size * 0.119047619047619, size * 0.185714285714286)); icon.getElements().add(new ClosePath()); icon.getElements().add(new MoveTo(size * 0.304761904761905, size * 0.238095238095238)); icon.getElements().add(new LineTo(size * 0.466666666666667, size * 0.4)); icon.getElements().add(new LineTo(size * 0.4, size * 0.466666666666667)); icon.getElements().add(new LineTo(size * 0.238095238095238, size * 0.304761904761905)); icon.getElements().add(new ClosePath()); redraw(); } }
Example #19
Source File: SunburstChart.java From tilesfx with Apache License 2.0 | 5 votes |
private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Color FILL, final Color STROKE, final TreeNode<ChartData> NODE) { double startAngleRad = Math.toRadians(START_ANGLE + 90); double endAngleRad = Math.toRadians(END_ANGLE + 90); boolean largeAngle = Math.abs(END_ANGLE - START_ANGLE) > 180.0; double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad); double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad); double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad); double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad); double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad); double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad); double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad); double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad); MoveTo moveTo1 = new MoveTo(x1, y1); LineTo lineTo2 = new LineTo(x2, y2); ArcTo arcTo3 = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true); LineTo lineTo4 = new LineTo(x4, y4); ArcTo arcTo1 = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false); Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1); path.setFill(FILL); path.setStroke(STROKE); String tooltipText = new StringBuilder(NODE.getItem().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getItem().getValue())).toString(); Tooltip.install(path, new Tooltip(tooltipText)); path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED)))); return path; }
Example #20
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 #21
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 #22
Source File: Bubble.java From JavaFX-Chat with GNU General Public License v3.0 | 5 votes |
private void drawRectBubbleLeftCenterIndicator() { getElements().addAll(new MoveTo(1.0f, 2.5f), new LineTo(1.2f, 2.4f), new VLineTo(1f), new HLineTo(2.9f), new VLineTo(4f), new HLineTo(1.2f), new VLineTo(2.7f), new LineTo(1.0f, 2.5f) ); }
Example #23
Source File: ReturnEdgeViewer.java From JetUML with GNU General Public License v3.0 | 5 votes |
@Override public Canvas createIcon(Edge pEdge) { final float scale = 0.6f; final int offset = 25; Canvas canvas = new Canvas(BUTTON_SIZE, BUTTON_SIZE); GraphicsContext graphics = canvas.getGraphicsContext2D(); canvas.getGraphicsContext2D().scale(scale, scale); Path path = new Path(); path.getElements().addAll(new MoveTo(1, offset), new LineTo(BUTTON_SIZE*(1/scale)-1, offset)); ToolGraphics.strokeSharpPath(graphics, path, LineStyle.DOTTED); ArrowHead.V.view().draw(graphics, new Point((int)(BUTTON_SIZE*(1/scale)-1), offset), new Point(1, offset)); return canvas; }
Example #24
Source File: ViewRhombus.java From latexdraw with GNU General Public License v3.0 | 5 votes |
private final void setupPath(final Path path) { final MoveTo moveTo = pathProducer.createMoveTo(0d, 0d); moveTo.xProperty().bind(Bindings.createDoubleBinding(() -> model.getPtAt(0).getX() + model.getWidth() / 2d, model.getPtAt(0).xProperty(), model.getPtAt(1).xProperty())); moveTo.yProperty().bind(model.getPtAt(0).yProperty()); path.getElements().add(moveTo); LineTo lineTo = pathProducer.createLineTo(0d, 0d); lineTo.xProperty().bind(model.getPtAt(2).xProperty()); lineTo.yProperty().bind(Bindings.createDoubleBinding(() -> model.getPtAt(1).getY() + model.getHeight() / 2d, model.getPtAt(1).yProperty(), model.getPtAt(2).yProperty())); path.getElements().add(lineTo); lineTo = pathProducer.createLineTo(0d, 0d); lineTo.xProperty().bind(Bindings.createDoubleBinding(() -> model.getPtAt(0).getX() + model.getWidth() / 2d, model.getPtAt(0).xProperty(), model.getPtAt(1).xProperty())); lineTo.yProperty().bind(model.getPtAt(2).yProperty()); path.getElements().add(lineTo); lineTo = pathProducer.createLineTo(0d, 0d); lineTo.xProperty().bind(model.getPtAt(0).xProperty()); lineTo.yProperty().bind(Bindings.createDoubleBinding(() -> model.getPtAt(0).getY() + model.getHeight() / 2d, model.getPtAt(0).yProperty(), model.getPtAt(2).yProperty())); path.getElements().add(lineTo); path.getElements().add(pathProducer.createClosePath()); }
Example #25
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 #26
Source File: SmoothAreaChartTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
private double[] getXYFromPathElement(final PathElement ELEMENT) { if (ELEMENT instanceof MoveTo) { return new double[]{ ((MoveTo) ELEMENT).getX(), ((MoveTo) ELEMENT).getY() }; } else { return new double[] { ((LineTo) ELEMENT).getX(), ((LineTo) ELEMENT).getY() }; } }
Example #27
Source File: SegmentedEdgeViewer.java From JetUML with GNU General Public License v3.0 | 5 votes |
private Path getSegmentPath(Edge pEdge) { Point2D[] points = getPoints(pEdge); Path path = new Path(); Point2D p = points[points.length - 1]; MoveTo moveTo = new MoveTo((float) p.getX(), (float) p.getY()); path.getElements().add(moveTo); for(int i = points.length - 2; i >= 0; i--) { p = points[i]; LineTo lineTo = new LineTo((float) p.getX(), (float) p.getY()); path.getElements().add(lineTo); } return path; }
Example #28
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 #29
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 #30
Source File: SmoothedChart.java From tilesfx with Apache License 2.0 | 5 votes |
private void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements, final double HEIGHT) { if (fillElements.isEmpty()) return; // as we do not have direct access to the data, first recreate the list of all the data points we have final Point[] dataPoints = new Point[strokeElements.size()]; for (int i = 0; i < strokeElements.size(); i++) { final PathElement element = strokeElements.get(i); if (element instanceof MoveTo) { final MoveTo move = (MoveTo) element; dataPoints[i] = new Point(move.getX(), move.getY()); } else if (element instanceof LineTo) { final LineTo line = (LineTo) element; final double x = line.getX(), y = line.getY(); dataPoints[i] = new Point(x, y); } } double firstX = dataPoints[0].getX(); double lastX = dataPoints[dataPoints.length - 1].getX(); Point[] points = Helper.subdividePoints(dataPoints, getSubDivisions()); fillElements.clear(); fillElements.add(new MoveTo(firstX, HEIGHT)); strokeElements.clear(); strokeElements.add(new MoveTo(points[0].getX(), points[0].getY())); for (Point p : points) { if (Double.compare(p.getX(), firstX) >= 0) { fillElements.add(new LineTo(p.getX(), p.getY())); strokeElements.add(new LineTo(p.getX(), p.getY())); } } fillElements.add(new LineTo(lastX, HEIGHT)); fillElements.add(new LineTo(0, HEIGHT)); fillElements.add(new ClosePath()); }