當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。