本文整理汇总了Java中javafx.scene.shape.ArcTo类的典型用法代码示例。如果您正苦于以下问题:Java ArcTo类的具体用法?Java ArcTo怎么用?Java ArcTo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArcTo类属于javafx.scene.shape包,在下文中一共展示了ArcTo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createIconContent
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
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;
}
示例2: drawingAreaMouseClicked
import javafx.scene.shape.ArcTo; //导入依赖的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: initializeHalfCircle
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
private Path initializeHalfCircle() {
final Path halfCircle = new Path();
halfCircle.setStroke(Color.BLACK);
MoveTo p1 = new MoveTo();
ArcTo p2 = new ArcTo();
p1.xProperty().bind(xProperty().add(CIRCLE_RADIUS));
p1.yProperty().bind(yProperty());
p2.xProperty().bind(xProperty().subtract(CIRCLE_RADIUS));
p2.yProperty().bind(yProperty());
p2.setRadiusX(CIRCLE_RADIUS);
p2.setRadiusY(CIRCLE_RADIUS);
halfCircle.getElements().add(p1);
halfCircle.getElements().add(p2);
return halfCircle;
}
示例4: initializeLargeCircle
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
private Path initializeLargeCircle() {
final Path largeCircle = new Path();
largeCircle.setStroke(Color.BLACK);
MoveTo p1 = new MoveTo();
ArcTo p2 = new ArcTo();
p1.xProperty().bind(xProperty().add(LARGE_CIRCLE_RADIUS));
p1.yProperty().bind(yProperty());
p2.xProperty().bind(xProperty().subtract(LARGE_CIRCLE_RADIUS));
p2.yProperty().bind(yProperty());
p2.setRadiusX(LARGE_CIRCLE_RADIUS);
p2.setRadiusY(LARGE_CIRCLE_RADIUS);
largeCircle.getElements().add(p1);
largeCircle.getElements().add(p2);
return largeCircle;
}
示例5: initializeMediumCircle
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
private Path initializeMediumCircle() {
final Path mediumCircle = new Path();
mediumCircle.setStroke(Color.BLACK);
MoveTo p1 = new MoveTo();
ArcTo p2 = new ArcTo();
p1.xProperty().bind(xProperty().add(MEDIUM_CIRCLE_RADIUS));
p1.yProperty().bind(yProperty());
p2.xProperty().bind(xProperty().subtract(MEDIUM_CIRCLE_RADIUS));
p2.yProperty().bind(yProperty());
p2.setRadiusX(MEDIUM_CIRCLE_RADIUS);
p2.setRadiusY(MEDIUM_CIRCLE_RADIUS);
mediumCircle.getElements().add(p1);
mediumCircle.getElements().add(p2);
return mediumCircle;
}
示例6: initializeSmallCircle
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
private Path initializeSmallCircle() {
final Path smallCircle = new Path();
smallCircle.setStroke(Color.BLACK);
MoveTo p1 = new MoveTo();
ArcTo p2 = new ArcTo();
p1.xProperty().bind(xProperty().add(SMALL_CIRCLE_RADIUS));
p1.yProperty().bind(yProperty());
p2.xProperty().bind(xProperty().subtract(SMALL_CIRCLE_RADIUS));
p2.yProperty().bind(yProperty());
p2.setRadiusX(SMALL_CIRCLE_RADIUS);
p2.setRadiusY(SMALL_CIRCLE_RADIUS);
smallCircle.getElements().add(p1);
smallCircle.getElements().add(p2);
return smallCircle;
}
示例7: draw
import javafx.scene.shape.ArcTo; //导入依赖的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());
}
示例8: processPath
import javafx.scene.shape.ArcTo; //导入依赖的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;
}
示例9: createSegment
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Color FILL, final Color STROKE, final TreeNode NODE) {
double startAngleRad = Math.toRadians(START_ANGLE + 90);
double endAngleRad = Math.toRadians(END_ANGLE + 90);
boolean largeAngle = Math.abs(END_ANGLE - START_ANGLE) > 180.0;
double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad);
double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad);
double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad);
double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad);
double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad);
double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad);
double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad);
double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad);
MoveTo moveTo1 = new MoveTo(x1, y1);
LineTo lineTo2 = new LineTo(x2, y2);
ArcTo arcTo3 = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true);
LineTo lineTo4 = new LineTo(x4, y4);
ArcTo arcTo1 = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false);
Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1);
path.setFill(FILL);
path.setStroke(STROKE);
String tooltipText = new StringBuilder(NODE.getData().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getData().getValue())).toString();
Tooltip.install(path, new Tooltip(tooltipText));
path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED))));
return path;
}
示例10: PathSample
import javafx.scene.shape.ArcTo; //导入依赖的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
}
示例11: createSegment
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Paint FILL, final Color STROKE, final TreeNode NODE) {
double startAngleRad = Math.toRadians(START_ANGLE + 90);
double endAngleRad = Math.toRadians(END_ANGLE + 90);
boolean largeAngle = Math.abs(END_ANGLE - START_ANGLE) > 180.0;
double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad);
double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad);
double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad);
double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad);
double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad);
double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad);
double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad);
double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad);
MoveTo moveTo1 = new MoveTo(x1, y1);
LineTo lineTo2 = new LineTo(x2, y2);
ArcTo arcTo3 = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true);
LineTo lineTo4 = new LineTo(x4, y4);
ArcTo arcTo1 = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false);
Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1);
path.setFill(FILL);
path.setStroke(STROKE);
String tooltipText = new StringBuilder(NODE.getItem().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getItem().getValue())).toString();
Tooltip.install(path, new Tooltip(tooltipText));
path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED))));
return path;
}
示例12: arcRel
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
/** arc from current position, using the specified center coordinates, radius, and angle */
public void arcRel(double xc, double yc, double radius, double angle)
{
// arcTo seems to fail if sweep angle is greater than 360
if(angle >= FX.TWO_PI)
{
angle = FX.TWO_PI - 0.0000001;
}
else if(angle <= -FX.TWO_PI)
{
angle = - FX.TWO_PI + 0.0000001;
}
Point2D p = currentPos();
double a = Math.atan2(yc + yorigin - p.getY(), p.getX() - xc - xorigin);
double b = a - angle;
double xe = xorigin + xc + radius * Math.cos(b);
double ye = yorigin - yc - radius * Math.sin(b);
// arcTo sweep is explained here:
// https://docs.oracle.com/javase/8/javafx/api/javafx/scene/shape/ArcTo.html
boolean large = (angle >= Math.PI);
boolean sweep = (angle > 0);
add(new ArcTo(radius, radius, 0, xe, ye, large, sweep));
}
示例13: PathMorphTransition
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
/**
* 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;
}
示例14: interpolate
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
@Override public ArcTo interpolate(ArcTo endValue, double t) {
ArcTo rv = new ArcTo(this.source.getRadiusX() + (endValue.getRadiusX() - this.source.getRadiusX()) * t,
this.source.getRadiusY() + (endValue.getRadiusY() - this.source.getRadiusY()) * t,
this.source.getXAxisRotation() + (endValue.getXAxisRotation() - this.source.getXAxisRotation()) * t,
this.source.getX() + (endValue.getX() - this.source.getX()) * t,
this.source.getY() + (endValue.getY() - this.source.getY()) * t,
this.source.isLargeArcFlag(), this.source.isSweepFlag());
rv.setAbsolute(this.source.isAbsolute());
return rv;
}
示例15: addArcTo
import javafx.scene.shape.ArcTo; //导入依赖的package包/类
/**
* Adds a circular detour arc to the path, to the given position.
*
* @param x the final x position of the arc
* @param y the final y position of the arc
*/
private void addArcTo(final double x, final double y) {
final ArcTo arcTo = new ArcTo();
arcTo.setRadiusX(DETOUR_RADIUS);
arcTo.setRadiusY(DETOUR_RADIUS);
arcTo.setSweepFlag(sign > 0);
arcTo.setX(GeometryUtils.moveOffPixel(x));
arcTo.setY(GeometryUtils.moveOffPixel(y));
getPathElements().add(arcTo);
}