本文整理汇总了Java中javafx.scene.shape.ClosePath类的典型用法代码示例。如果您正苦于以下问题:Java ClosePath类的具体用法?Java ClosePath怎么用?Java ClosePath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClosePath类属于javafx.scene.shape包,在下文中一共展示了ClosePath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearSmallPolygons
import javafx.scene.shape.ClosePath; //导入依赖的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: drawingAreaMouseClicked
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
@FXML
private void drawingAreaMouseClicked(MouseEvent e)
{
polyline.getPoints().addAll(e.getX(), e.getY());
polygon.getPoints().addAll(e.getX(), e.getY());
// if path is empty, move to first click position and close path
if (path.getElements().isEmpty())
{
path.getElements().add(new MoveTo(e.getX(), e.getY()));
path.getElements().add(new ClosePath());
}
else // insert a new path segment before the ClosePath element
{
// create an arc segment and insert it in the path
ArcTo arcTo = new ArcTo();
arcTo.setX(e.getX());
arcTo.setY(e.getY());
arcTo.setRadiusX(100.0);
arcTo.setRadiusY(100.0);
arcTo.setSweepFlag(sweepFlag);
sweepFlag = !sweepFlag;
path.getElements().add(path.getElements().size() - 1, arcTo);
}
}
示例3: drawChart
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
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()); }
}
示例4: pathsToSVGPath
import javafx.scene.shape.ClosePath; //导入依赖的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();
}
示例5: createNeedle
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
private void createNeedle() {
double needleWidth = size * 0.04;
double needleHeight = size * 0.4675;
needle.getElements().clear();
needle.getElements().add(new MoveTo(0.3125 * needleWidth, 0.015957446808510637 * needleHeight));
needle.getElements().add(new CubicCurveTo(0.3125 * needleWidth, 0.005319148936170213 * needleHeight,
0.4375 * needleWidth, 0.0,
0.5 * needleWidth, 0.0));
needle.getElements().add(new CubicCurveTo(0.5625 * needleWidth, 0.0,
0.6875 * needleWidth, 0.005319148936170213 * needleHeight,
0.6875 * needleWidth, 0.015957446808510637 * needleHeight));
needle.getElements().add(new CubicCurveTo(0.6875 * needleWidth, 0.015957446808510637 * needleHeight,
needleWidth, 0.9946808510638298 * needleHeight,
needleWidth, 0.9946808510638298 * needleHeight));
needle.getElements().add(new LineTo(0.0, 0.9946808510638298 * needleHeight));
needle.getElements().add(new CubicCurveTo(0.0, 0.9946808510638298 * needleHeight,
0.3125 * needleWidth, 0.015957446808510637 * needleHeight,
0.3125 * needleWidth, 0.015957446808510637 * needleHeight));
needle.getElements().add(new ClosePath());
needle.setFill(new LinearGradient(needle.getLayoutBounds().getMinX(), 0,
needle.getLayoutBounds().getMaxX(), 0,
false, CycleMethod.NO_CYCLE,
new Stop(0.0, gauge.getNeedleColor().darker()),
new Stop(0.5, gauge.getNeedleColor()),
new Stop(1.0, gauge.getNeedleColor().darker())));
}
示例6: drawAverage
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
private void drawAverage() {
double scaledWidth = width * 1.106;
double centerX = width * 0.5;
double centerY = height * 0.77;
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());
}
示例7: initGraphics
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
private void initGraphics() {
moveTo = new MoveTo();
upperLeft = new LineTo();
upperRight = new LineTo();
lowerRight = new LineTo();
lowerLeft = new LineTo();
path = new Path();
path.getElements().add(moveTo);
path.getElements().add(upperLeft);
path.getElements().add(upperRight);
path.getElements().add(lowerRight);
path.getElements().add(lowerLeft);
path.getElements().add(new ClosePath());
path.getStyleClass().add("segment");
pane = new Pane(path);
pane.getStyleClass().add("segment");
getChildren().setAll(pane);
}
示例8: draw
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
/**
* Draws the arrow-head for its current size and position values.
*/
public void draw() {
getElements().clear();
getElements().add(new MoveTo(x, y + length / 2));
getElements().add(new LineTo(x + width / 2, y - length / 2));
if (radius > 0) {
final ArcTo arcTo = new ArcTo();
arcTo.setX(x - width / 2);
arcTo.setY(y - length / 2);
arcTo.setRadiusX(radius);
arcTo.setRadiusY(radius);
arcTo.setSweepFlag(true);
getElements().add(arcTo);
} else {
getElements().add(new LineTo(x - width / 2, y - length / 2));
}
getElements().add(new ClosePath());
}
示例9: start
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
Path shape = new Path(new MoveTo(450, 450),
new LineTo(-SIZE, -SIZE),
new LineTo(0, -2 * SIZE),
new LineTo(SIZE, -SIZE),
new LineTo(450, 450),
new ClosePath());
shape.setFill(Color.BLUE);
shape.setStroke(Color.RED);
shape.setStrokeWidth(2.0);
shape.getStrokeDashArray().addAll(10.0, 5.0);
Pane root = new Pane();
root.getChildren().add(shape);
stage.setScene(new Scene(root, 900, 900));
stage.show();
}
示例10: processPath
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
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;
}
示例11: PathSample
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
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
}
示例12: smooth
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
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 Point2D[] dataPoints = new Point2D[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 Point2D(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 Point2D(x, y);
}
}
double firstX = dataPoints[0].getX();
double lastX = dataPoints[dataPoints.length - 1].getX();
Point2D[] 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 (Point2D 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());
}
示例13: drawTriangle
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
private void drawTriangle() {
MoveTo moveTo = new MoveTo(0, 0.028 * size);
LineTo lineTo1 = new LineTo(0.022 * size, 0);
LineTo lineTo2 = new LineTo(0.044 * size, 0.028 * size);
LineTo lineTo3 = new LineTo(0, 0.028 * size);
ClosePath closePath = new ClosePath();
triangle.getElements().setAll(moveTo, lineTo1, lineTo2, lineTo3, closePath);
}
示例14: drawTriangle
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
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);
}
示例15: drawTriangle
import javafx.scene.shape.ClosePath; //导入依赖的package包/类
private void drawTriangle() {
MoveTo moveTo = new MoveTo(0.056 * size * 0.5, 0.032 * size * 0.5);
CubicCurveTo cubicCurveTo1 = new CubicCurveTo(0.060 * size * 0.5, 0.028 * size * 0.5, 0.064 * size * 0.5, 0.028 * size * 0.5, 0.068 * size * 0.5, 0.032 * size * 0.5);
CubicCurveTo cubicCurveTo2 = new CubicCurveTo(0.068 * size * 0.5, 0.032 * size * 0.5, 0.120 * size * 0.5, 0.080 * size * 0.5, 0.12 * size * 0.5, 0.080 * size * 0.5);
CubicCurveTo cubicCurveTo3 = new CubicCurveTo(0.128 * size * 0.5, 0.088 * size * 0.5, 0.124 * size * 0.5, 0.096 * size * 0.5, 0.112 * size * 0.5, 0.096 * size * 0.5);
CubicCurveTo cubicCurveTo4 = new CubicCurveTo(0.112 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5);
CubicCurveTo cubicCurveTo5 = new CubicCurveTo(0.0, 0.096 * size * 0.5, -0.004 * size * 0.5, 0.088 * size * 0.5, 0.004 * size * 0.5, 0.080 * size * 0.5);
CubicCurveTo cubicCurveTo6 = new CubicCurveTo(0.004 * size * 0.5, 0.080 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5);
ClosePath closePath = new ClosePath();
triangle.getElements().setAll(moveTo, cubicCurveTo1, cubicCurveTo2, cubicCurveTo3, cubicCurveTo4, cubicCurveTo5, cubicCurveTo6, closePath);
}