Java Code Examples for javafx.scene.shape.Arc#getRadiusX()

The following examples show how to use javafx.scene.shape.Arc#getRadiusX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Shape2Geometry.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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()));
}
 
Example 2
Source File: ShapeConverter.java    From Enzo with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 3
Source File: ViewArrowableTraitArc.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@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);
}
 
Example 4
Source File: TestViewCircleArc.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
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;
}