当前位置: 首页>>代码示例>>Java>>正文


Java Path.getElements方法代码示例

本文整理汇总了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));
                }
            } 
        }
    }
}
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:26,代码来源:BadgeOutline.java

示例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;
}
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:31,代码来源:BadgeOutline.java

示例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();
}
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:21,代码来源:BadgeOutline.java

示例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;
}
 
开发者ID:sanke69,项目名称:fr.xs.jtk,代码行数:10,代码来源:GaugeBarModernSkin.java

示例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();
}
 
开发者ID:Simego,项目名称:FXImgurUploader,代码行数:44,代码来源:ShapeConverter.java

示例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();
}
 
开发者ID:stefaneidelloth,项目名称:JavaFxNodeToSvg,代码行数:65,代码来源:ShapeConverter.java


注:本文中的javafx.scene.shape.Path.getElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。