本文整理汇总了Java中javafx.scene.shape.Path.getElements方法的典型用法代码示例。如果您正苦于以下问题:Java Path.getElements方法的具体用法?Java Path.getElements怎么用?Java Path.getElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Path
的用法示例。
在下文中一共展示了Path.getElements方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearSmallPolygons
import javafx.scene.shape.Path; //导入方法依赖的package包/类
private void clearSmallPolygons(Path... paths){
validPaths = new ArrayList<>();
Point2D p0 = Point2D.ZERO;
for (Path path : paths) {
for (PathElement elem : path.getElements()) {
if (elem instanceof MoveTo) {
elements = new ArrayList<>();
elements.add(elem);
listPoints = new ArrayList<>();
p0 = new Point2D(((MoveTo)elem).getX(), ((MoveTo)elem).getY());
listPoints.add(p0);
} else if (elem instanceof CubicCurveTo) {
elements.add(elem);
Point2D ini = listPoints.size() > 0 ? listPoints.get(listPoints.size() - 1) : p0;
listPoints.addAll(evalCubicCurve((CubicCurveTo) elem, ini, POINTS_CURVE));
} else if (elem instanceof ClosePath) {
elements.add(elem);
listPoints.add(p0);
if (Math.abs(calculateArea()) > MINIMUM_AREA) {
validPaths.add(new Path(elements));
}
}
}
}
}
示例2: generateOutline
import javafx.scene.shape.Path; //导入方法依赖的package包/类
/**
* Once we have drawn the path, we call this method to generate two paths
* (outer and inner paths) and get a SVGPath with them that can be exported
* @param drawPath The original path
* @param svg
* @return the content string of the SVGPath with two paths
*/
public boolean generateOutline(Path drawPath, SVGPath svg) {
Pane pane = (Pane) drawPath.getParent();
final double width = pane.getWidth() * WIDTH_FACTOR;
Path outterPath = new Path(drawPath.getElements());
outterPath.setStroke(drawPath.getStroke());
outterPath.setStrokeLineJoin(drawPath.getStrokeLineJoin());
outterPath.setStrokeLineCap(drawPath.getStrokeLineCap());
outterPath.setStrokeWidth(width);
Path s1 = (Path) Shape.subtract(outterPath, new Rectangle(0, 0));
Path innerPath = new Path(drawPath.getElements());
innerPath.setStrokeWidth(0);
innerPath.setStroke(drawPath.getStroke());
innerPath.setStrokeLineJoin(drawPath.getStrokeLineJoin());
innerPath.setStrokeLineCap(drawPath.getStrokeLineCap());
Path s2 = (Path) Shape.subtract(innerPath, new Rectangle(0, 0));
Path result = (Path) Shape.subtract(s1, s2);
clearSmallPolygons(result);
svg.setContent(pathsToSVGPath());
return validPaths.size() == 2;
}
示例3: pathsToSVGPath
import javafx.scene.shape.Path; //导入方法依赖的package包/类
private String pathsToSVGPath() {
final StringBuilder sb = new StringBuilder();
for (Path path : validPaths) {
for (PathElement element : path.getElements()) {
if (element instanceof MoveTo) {
sb.append("M ").append(((MoveTo) element).getX()).append(" ")
.append(((MoveTo) element).getY());
} else if (element instanceof CubicCurveTo) {
CubicCurveTo curve = (CubicCurveTo) element;
sb.append(" C ")
.append(curve.getControlX1()).append(" ").append(curve.getControlY1()).append(" ")
.append(curve.getControlX2()).append(" ").append(curve.getControlY2()).append(" ")
.append(curve.getX()).append(" ").append(curve.getY());
} else if (element instanceof ClosePath) {
sb.append(" Z ");
}
}
}
return sb.toString();
}
示例4: createTicks
import javafx.scene.shape.Path; //导入方法依赖的package包/类
private Node createTicks() {
Path tickMarks = new Path();
ObservableList<PathElement> pathChildren = tickMarks.getElements();
for(int i = 0; i < 360; i += TICK_DEGREE) {
pathChildren.add(new MoveTo(this.size, this.size));
pathChildren.add(new LineTo(this.size * Math.cos(Math.toRadians(i)) + this.size, this.size * Math.sin(Math.toRadians(i)) + this.size));
}
return tickMarks;
}
示例5: convertPath
import javafx.scene.shape.Path; //导入方法依赖的package包/类
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();
}
示例6: convertPath
import javafx.scene.shape.Path; //导入方法依赖的package包/类
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();
}