public static Node createIconContent() { Path path = new Path(); path.getElements().addAll( new MoveTo(25, 25), new HLineTo(45), new ArcTo(20, 20, 0, 80, 25, true, true) ); path.setStroke(Color.web("#b9c0c5")); path.setStrokeWidth(5); path.getStrokeDashArray().addAll(15d,15d); path.setFill(null); javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow(); effect.setOffsetX(1); effect.setOffsetY(1); effect.setRadius(3); effect.setColor(Color.rgb(0,0,0,0.6)); path.setEffect(effect); return path; }
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; }
/** * Constructs a new {@link Edge}, ending at the provided {@link AbstractNode}. * @param dst This edge's destination node. */ public Edge(AbstractNode dst) { // Set start point of the Path. MoveTo m = new MoveTo(); m.xProperty().bindBidirectional(dst.translateXProperty()); m.yProperty().bindBidirectional(dst.translateYProperty()); getElements().add(m); // Add the horizontal line, starting at the path's start point. HLineTo hline = new HLineTo(); getElements().add(hline); // Add the vertical line, starting at the horizontal line's end point. VLineTo vline = new VLineTo(); getElements().add(vline); }
protected void unbindChildren(RuleNode<?> first, RuleNode<?> second) { if (second != null) { second.layoutXProperty().unbind(); } if (first != null) { Path path = getPath(first, 0); if (path == null) { return; } MoveTo move = (MoveTo) path.getElements().get(0); move.xProperty().unbind(); move.yProperty().unbind(); HLineTo line = (HLineTo) path.getElements().get(1); line.xProperty().unbind(); removePath(path, first); } }
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 }
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) ); }
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) ); }
private void drawRectBubbleLeftBaselineIndicator() { getElements().addAll(new MoveTo(1.2f, 1.0f), new HLineTo(3f), new VLineTo(4f), new HLineTo(1.0f), new LineTo(1.2f, 3.8f), new VLineTo(1f) ); }
private void drawRectBubbleRightCenterIndicator() { getElements().addAll(new MoveTo(3.0f, 2.5f), new LineTo(2.8f, 2.4f), new VLineTo(1f), new HLineTo(0f), new VLineTo(4f), new HLineTo(2.8f), new VLineTo(2.7f), new LineTo(3.0f, 2.5f) ); }
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) ); }
/** * Create a transition * * @param sourceElements * the source elements * @param targetElements * the target elements * @param duation * the duration * @param pathNode * the path not the morph is done on */ public PathMorphTransition(List<PathElement> sourceElements, List<PathElement> targetElements, Duration duation, Path pathNode) { this.pathNode = pathNode; setCycleDuration(duation); if (sourceElements.size() != targetElements.size()) { throw new IllegalArgumentException("Only equal paths are allowed"); //$NON-NLS-1$ } for (int i = 0; i < sourceElements.size(); i++) { PathElement sourceElement = sourceElements.get(i); PathElement targetElement = targetElements.get(i); if (sourceElement.getClass() != targetElement.getClass()) { throw new IllegalArgumentException("Only equal paths are allowed"); //$NON-NLS-1$ } if (sourceElement instanceof ArcTo) { this.interpolateList.add(new ArcToInterpolatable((ArcTo) sourceElement)); } else if (sourceElement instanceof CubicCurveTo) { this.interpolateList.add(new CubicCurveToInterpolatable((CubicCurveTo) sourceElement)); } else if (sourceElement instanceof HLineTo) { this.interpolateList.add(new HLineToInterpolatable((HLineTo) sourceElement)); } else if (sourceElement instanceof LineTo) { this.interpolateList.add(new LineToInterpolatable((LineTo) sourceElement)); } else if (sourceElement instanceof MoveTo) { this.interpolateList.add(new MoveToInterpolatable((MoveTo) sourceElement)); } else if (sourceElement instanceof QuadCurveTo) { this.interpolateList.add(new QuadCurveToInterpolatable((QuadCurveTo) sourceElement)); } else if (sourceElement instanceof VLineTo) { this.interpolateList.add(new VLineToInterpolatable((VLineTo) sourceElement)); } } this.sourceElements = sourceElements; this.targetElements = targetElements; }
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; }
private void buildHpath() { vpth.clear(); int max = (int) (this.getHeight() / sgap); double more = (int) this.getHeight() % sgap; double hgap = more / 2; for (int i = 0; i <= max; i++) { vpth.add(new MoveTo(more / 2, hgap)); vpth.add(new HLineTo(this.getWidth())); hgap += sgap; } }
private NumberExpression createSteps(Step<?> step, int depth, int currentStateIndex, int selectedStateIndex, int firstStateIndex, int lastStateIndex, List<Path> accumulator, Object[] stepTargets) { final int stepStartingIndex = traceExtractor.getStateIndex(step.getStartingState()); final boolean endedStep = step.getEndingState() != null; final int startingIndex = stepStartingIndex - currentStateIndex; final int endingIndex = (endedStep ? traceExtractor.getStateIndex(step.getEndingState()) : nbStates.intValue()) - currentStateIndex; final Path path = new Path(); path.setStrokeWidth(2); final double x1 = startingIndex * UNIT + UNIT / 2; final double x4 = endingIndex * UNIT + UNIT / 2; final double x2 = x1 + UNIT / 4; final double x3 = x4 - UNIT / 4; final double baseLineY = DIAMETER / 2 + V_MARGIN; final MoveTo moveTo = new MoveTo(x1, baseLineY); final LineTo lineTo = new LineTo(x2, baseLineY); final HLineTo hLineTo = new HLineTo(x3); path.getElements().addAll(moveTo, lineTo, hLineTo); if (endedStep) { final LineTo lastLineTo = new LineTo(x4, baseLineY); path.getElements().add(lastLineTo); } accumulator.add(path); final List<? extends Step<?>> subSteps = traceExtractor.getSubSteps(step); NumberExpression yOffset = new SimpleDoubleProperty(0); if (subSteps != null && !subSteps.isEmpty()) { for (Step<?> subStep : subSteps) { if (subStep.getStartingState() != subStep.getEndingState() // && ((traceExtractor.getStateIndex(subStep.getEndingState()) < firstStateIndex) || traceExtractor.getStateIndex(subStep.getStartingState()) > lastStateIndex) ) { yOffset = Bindings.max(yOffset, createSteps(subStep, depth + 1, currentStateIndex, selectedStateIndex, firstStateIndex, lastStateIndex, accumulator, stepTargets)); } } } lineTo.yProperty().bind(yOffset.add(DIAMETER / 2 + V_MARGIN)); if (stepTargets[CURRENT_FORWARD_STEP] == step) { path.setStroke(Color.DARKORANGE); } else if (stepTargets[CURRENT_BACKWARD_STEP] == step) { path.setStroke(Color.DARKGREEN); } else if (stepTargets[CURRENT_BIGSTEP] == step) { path.setStroke(Color.DARKRED); } else { path.setStroke(Color.DARKBLUE); if (!traceExplorer.getCallStack().contains(step) && (stepStartingIndex > selectedStateIndex || (stepStartingIndex == selectedStateIndex && endedStep))) { path.getStrokeDashArray().addAll(5., 5.); path.setStrokeLineCap(StrokeLineCap.ROUND); } } return lineTo.yProperty(); }
@Override public HLineTo interpolate(HLineTo endValue, double t) { HLineTo rv = new HLineTo(this.source.getX() + (endValue.getX() - this.source.getX()) * t); rv.setAbsolute(this.source.isAbsolute()); return rv; }
public static String convertPath(final Path PATH) { final StringBuilder fxPath = new StringBuilder(); for (PathElement element : PATH.getElements()) { if (MoveTo.class.equals(element.getClass())) { fxPath.append("M ") .append(((MoveTo) element).getX()).append(" ") .append(((MoveTo) element).getY()).append(" "); } else if (LineTo.class.equals(element.getClass())) { fxPath.append("L ") .append(((LineTo) element).getX()).append(" ") .append(((LineTo) element).getY()).append(" "); } else if (CubicCurveTo.class.equals(element.getClass())) { fxPath.append("C ") .append(((CubicCurveTo) element).getControlX1()).append(" ") .append(((CubicCurveTo) element).getControlY1()).append(" ") .append(((CubicCurveTo) element).getControlX2()).append(" ") .append(((CubicCurveTo) element).getControlY2()).append(" ") .append(((CubicCurveTo) element).getX()).append(" ") .append(((CubicCurveTo) element).getY()).append(" "); } else if (QuadCurveTo.class.equals(element.getClass())) { fxPath.append("Q ") .append(((QuadCurveTo) element).getControlX()).append(" ") .append(((QuadCurveTo) element).getControlY()).append(" ") .append(((QuadCurveTo) element).getX()).append(" ") .append(((QuadCurveTo) element).getY()).append(" "); } else if (ArcTo.class.equals(element.getClass())) { fxPath.append("A ") .append(((ArcTo) element).getX()).append(" ") .append(((ArcTo) element).getY()).append(" ") .append(((ArcTo) element).getRadiusX()).append(" ") .append(((ArcTo) element).getRadiusY()).append(" "); } else if (HLineTo.class.equals(element.getClass())) { fxPath.append("H ") .append(((HLineTo) element).getX()).append(" "); } else if (VLineTo.class.equals(element.getClass())) { fxPath.append("V ") .append(((VLineTo) element).getY()).append(" "); } else if (ClosePath.class.equals(element.getClass())) { fxPath.append("Z"); } } return fxPath.toString(); }
public static String convertPath(final Path PATH) { final StringBuilder fxPath = new StringBuilder(); for (PathElement element : PATH.getElements()) { if (MoveTo.class.equals(element.getClass())) { fxPath .append("M ") .append(((MoveTo) element).getX()) .append(" ") .append(((MoveTo) element).getY()) .append(" "); } else if (LineTo.class.equals(element.getClass())) { fxPath .append("L ") .append(((LineTo) element).getX()) .append(" ") .append(((LineTo) element).getY()) .append(" "); } else if (CubicCurveTo.class.equals(element.getClass())) { fxPath .append("C ") .append(((CubicCurveTo) element).getControlX1()) .append(" ") .append(((CubicCurveTo) element).getControlY1()) .append(" ") .append(((CubicCurveTo) element).getControlX2()) .append(" ") .append(((CubicCurveTo) element).getControlY2()) .append(" ") .append(((CubicCurveTo) element).getX()) .append(" ") .append(((CubicCurveTo) element).getY()) .append(" "); } else if (QuadCurveTo.class.equals(element.getClass())) { fxPath .append("Q ") .append(((QuadCurveTo) element).getControlX()) .append(" ") .append(((QuadCurveTo) element).getControlY()) .append(" ") .append(((QuadCurveTo) element).getX()) .append(" ") .append(((QuadCurveTo) element).getY()) .append(" "); } else if (ArcTo.class.equals(element.getClass())) { fxPath .append("A ") .append(((ArcTo) element).getX()) .append(" ") .append(((ArcTo) element).getY()) .append(" ") .append(((ArcTo) element).getRadiusX()) .append(" ") .append(((ArcTo) element).getRadiusY()) .append(" "); } else if (HLineTo.class.equals(element.getClass())) { fxPath.append("H ").append(((HLineTo) element).getX()).append(" "); } else if (VLineTo.class.equals(element.getClass())) { fxPath.append("V ").append(((VLineTo) element).getY()).append(" "); } else if (ClosePath.class.equals(element.getClass())) { fxPath.append("Z"); } } return fxPath.toString(); }
@Override protected void unbindChild(RuleNode<?> node) { maxWidth.removeExpression(node.widthProperty()); Path path1 = getPath(node, 0); MoveTo moveLeft = (MoveTo) path1.getElements().get(0); moveLeft.yProperty().unbind(); ArcTo arcSourceLeft = (ArcTo) path1.getElements().get(1); arcSourceLeft.radiusXProperty().unbind(); arcSourceLeft.radiusYProperty().unbind(); arcSourceLeft.xProperty().unbind(); arcSourceLeft.yProperty().unbind(); arcSourceLeft.sweepFlagProperty().unbind(); VLineTo leftVertical = (VLineTo) path1.getElements().get(2); leftVertical.yProperty().unbind(); ArcTo arcDestinationLeft = (ArcTo) path1.getElements().get(3); arcDestinationLeft.radiusXProperty().unbind(); arcDestinationLeft.radiusYProperty().unbind(); arcDestinationLeft.xProperty().unbind(); arcDestinationLeft.yProperty().unbind(); arcDestinationLeft.sweepFlagProperty().unbind(); HLineTo leftHorizontal = (HLineTo) path1.getElements().get(4); leftHorizontal.xProperty().unbind(); removePath(path1, node); Path path2 = getPath(node, 1); MoveTo moveRight = (MoveTo) path1.getElements().get(0); moveRight.xProperty().unbind(); moveRight.yProperty().unbind(); HLineTo rightHorizontal = (HLineTo) path1.getElements().get(1); rightHorizontal.xProperty().unbind(); ArcTo arcSourceRight = (ArcTo) path1.getElements().get(2); arcSourceRight.radiusXProperty().unbind(); arcSourceRight.radiusYProperty().unbind(); arcSourceRight.xProperty().unbind(); arcSourceRight.yProperty().unbind(); arcSourceRight.sweepFlagProperty().unbind(); VLineTo rightVertical = (VLineTo) path1.getElements().get(3); rightVertical.yProperty().unbind(); ArcTo arcDestinationRight = (ArcTo) path1.getElements().get(4); arcDestinationRight.radiusXProperty().unbind(); arcDestinationRight.radiusYProperty().unbind(); arcDestinationRight.xProperty().unbind(); arcDestinationRight.yProperty().unbind(); arcDestinationRight.sweepFlagProperty().unbind(); removePath(path2, node); }
/** * Adds a horizontal line to the path, to the given position. * * @param x the final x position of the line */ protected void addHLineTo(final double x) { pathElements.add(new HLineTo(GeometryUtils.moveOffPixel(x))); }
public HLineToInterpolatable(HLineTo source) { this.source = source; }