下面列出了javafx.scene.shape.Arc#getRadiusX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Converts the given JavaFX {@link Arc} to a
* {@link org.eclipse.gef.geometry.planar.Arc}.
*
* @param arc
* The JavaFX {@link Arc} to convert.
* @return The newly created {@link org.eclipse.gef.geometry.planar.Arc}
* that describes the given {@link Arc}.
*/
public static org.eclipse.gef.geometry.planar.Arc toArc(Arc arc) {
return new org.eclipse.gef.geometry.planar.Arc(
arc.getCenterX() - arc.getRadiusX(),
arc.getCenterY() - arc.getRadiusY(),
arc.getRadiusX() + arc.getRadiusX(),
arc.getRadiusY() + arc.getRadiusY(),
Angle.fromDeg(arc.getStartAngle()),
Angle.fromDeg(arc.getLength()));
}
public static String convertArc(final Arc ARC) {
StringBuilder fxPath = new StringBuilder();
double centerX = ARC.getCenterX();
double centerY = ARC.getCenterY();
double radiusX = ARC.getRadiusX();
double radiusY = ARC.getRadiusY();
double startAngle = Math.toRadians(-ARC.getStartAngle());
double endAngle = Math.toRadians(-ARC.getStartAngle() - ARC.getLength());
double length = ARC.getLength();
double startX = radiusX * Math.cos(startAngle);
double startY = radiusY * Math.sin(startAngle);
double endX = centerX + radiusX * Math.cos(endAngle);
double endY = centerY + radiusY * Math.sin(endAngle);
int xAxisRot = 0;
int largeArc = (length > 180) ? 1 : 0;
int sweep = (length < 0) ? 1 : 0;
fxPath.append("M ").append(centerX).append(" ").append(centerY).append(" ");
if (ArcType.ROUND == ARC.getType()) {
fxPath.append("l ").append(startX).append(" ").append(startY).append(" ");
}
fxPath.append("A ").append(radiusX).append(" ").append(radiusY).append(" ")
.append(xAxisRot).append(" ").append(largeArc).append(" ").append(sweep).append(" ")
.append(endX).append(" ").append(endY).append(" ");
if (ArcType.CHORD == ARC.getType() || ArcType.ROUND == ARC.getType()) {
fxPath.append("Z");
}
return fxPath.toString();
}
@Override
protected void clipPath(final Arc arc) {
if(!model.getArcStyle().supportArrow()) {
arc.setClip(null);
return;
}
final double width = Math.max(arc.getRadiusX() * 2d, 1d);
double sAngle = model.getAngleStart();
double eAngle = model.getAngleEnd();
Arrow arr = model.getArrowAt(1);
final double gap = Math.atan(arr.getArrowShapeLength() / width);
if(arr.getArrowStyle().isReducingShape()) {
if(eAngle > sAngle) {
eAngle -= gap;
}else {
eAngle += gap;
}
}
arr = model.getArrowAt(0);
if(arr.getArrowStyle().isReducingShape()) {
if(eAngle > sAngle) {
sAngle += gap;
}else {
sAngle -= gap;
}
}
sAngle = Math.toDegrees(sAngle % (2d * Math.PI));
eAngle = Math.toDegrees(eAngle % (2d * Math.PI));
if(MathUtils.INST.equalsDouble(sAngle, eAngle)) {
eAngle += 0.1;
}
final Arc clip = new Arc(arc.getCenterX(), arc.getCenterY(), arc.getRadiusX(), arc.getRadiusY(), sAngle, eAngle - sAngle);
clip.setType(arc.getType());
clip.setStrokeWidth(arc.getStrokeWidth());
arc.setClip(clip);
}
private Arc cloneArc(final Arc arc) {
final Arc clone = new Arc(arc.getCenterX(), arc.getCenterY(), arc.getRadiusX(), arc.getRadiusY(), arc.getStartAngle(), arc.getLength());
clone.setType(arc.getType());
return clone;
}