javafx.scene.shape.Ellipse#getCenterY ( )源码实例Demo

下面列出了javafx.scene.shape.Ellipse#getCenterY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Enzo   文件: ShapeConverter.java
public static String convertEllipse(final Ellipse ELLIPSE) {
    final StringBuilder fxPath = new StringBuilder();
    final double CENTER_X           = ELLIPSE.getCenterX() == 0 ? ELLIPSE.getRadiusX() : ELLIPSE.getCenterX();
    final double CENTER_Y           = ELLIPSE.getCenterY() == 0 ? ELLIPSE.getRadiusY() : ELLIPSE.getCenterY();
    final double RADIUS_X           = ELLIPSE.getRadiusX();
    final double RADIUS_Y           = ELLIPSE.getRadiusY();
    final double CONTROL_DISTANCE_X = RADIUS_X * KAPPA;
    final double CONTROL_DISTANCE_Y = RADIUS_Y * KAPPA;
    // Move to first point
    fxPath.append("M ").append(CENTER_X).append(" ").append(CENTER_Y - RADIUS_Y).append(" ");
    // 1. quadrant
    fxPath.append("C ").append(CENTER_X + CONTROL_DISTANCE_X).append(" ").append(CENTER_Y - RADIUS_Y).append(" ")
          .append(CENTER_X + RADIUS_X).append(" ").append(CENTER_Y - CONTROL_DISTANCE_Y).append(" ")
          .append(CENTER_X + RADIUS_X).append(" ").append(CENTER_Y).append(" ");
    // 2. quadrant
    fxPath.append("C ").append(CENTER_X + RADIUS_X).append(" ").append(CENTER_Y + CONTROL_DISTANCE_Y).append(" ")
          .append(CENTER_X + CONTROL_DISTANCE_X).append(" ").append(CENTER_Y + RADIUS_Y).append(" ")
          .append(CENTER_X).append(" ").append(CENTER_Y + RADIUS_Y).append(" ");
    // 3. quadrant
    fxPath.append("C ").append(CENTER_X - CONTROL_DISTANCE_X).append(" ").append(CENTER_Y + RADIUS_Y).append(" ")
          .append(CENTER_X - RADIUS_X).append(" ").append(CENTER_Y + CONTROL_DISTANCE_Y).append(" ")
          .append(CENTER_X - RADIUS_X).append(" ").append(CENTER_Y).append(" ");
    // 4. quadrant
    fxPath.append("C ").append(CENTER_X - RADIUS_X).append(" ").append(CENTER_Y - CONTROL_DISTANCE_Y).append(" ")
          .append(CENTER_X - CONTROL_DISTANCE_X).append(" ").append(CENTER_Y - RADIUS_Y).append(" ")
          .append(CENTER_X).append(" ").append(CENTER_Y - RADIUS_Y).append(" ");
    // Close path
    fxPath.append("Z");
    return fxPath.toString();
}
 
@Override // Override the start method in the Applicaton class
public void start(Stage primaryStage) {
	// Create a pane
	Pane pane = new Pane();

	// Create an ellipse and set its properties
	Ellipse ellipse = new Ellipse(75, 40, 50, 20);
	ellipse.setStroke(Color.BLACK);
	ellipse.setFill(Color.WHITE);

	// Create two Arcs and set their properties
	Arc arc1 = new Arc(ellipse.getCenterX(), 150, ellipse.getRadiusX(), 
		ellipse.getRadiusY(), 0, -180);
	arc1.setType(ArcType.OPEN);
	arc1.setFill(Color.WHITE);
	arc1.setStroke(Color.BLACK);

	Arc arc2 = new Arc(ellipse.getCenterX(), arc1.getCenterY(), 
		ellipse.getRadiusX(), ellipse.getRadiusY(), 0, 180);
	arc2.setType(ArcType.OPEN);
	arc2.setFill(Color.WHITE);
	arc2.setStroke(Color.BLACK);
	arc2.getStrokeDashArray().addAll(6.0, 21.0);

	// Create two lines and set thier properties
	Line line1 = new Line(ellipse.getCenterX() - ellipse.getRadiusX(), 
		ellipse.getCenterY(), ellipse.getCenterX() - ellipse.getRadiusX(),
		arc1.getCenterY());
	Line line2 = new Line((ellipse.getCenterX() - ellipse.getRadiusX()) + 
		ellipse.getRadiusX() * 2, ellipse.getCenterY(), 
		(ellipse.getCenterX() - ellipse.getRadiusX()) 
		+ ellipse.getRadiusX() * 2, arc1.getCenterY());

	// Place nodes in pane
	pane.getChildren().addAll(ellipse, arc1, arc2, line1, line2);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 150, 200);
	primaryStage.setTitle("Exercise_14_10"); // Set the stage title
	primaryStage.setScene(scene); // Place the scenen in the stage
	primaryStage.show(); // Display the stage
}
 
/** Return a circle of specified properties */
private Circle getCircle(Ellipse e) {
	Circle c = new Circle(e.getCenterX(), e.getCenterY(), 
		e.getRadiusY() - (e.getRadiusX() - e.getRadiusY()));
	return c;
}
 
源代码4 项目: latexdraw   文件: JFXToSVG.java
public SVGEllipseElement ellipseToSVGEllipse(final Ellipse ell, final SVGDocument doc) {
	final SVGEllipseElement elt = new SVGEllipseElement(ell.getCenterX(), ell.getCenterY(), ell.getRadiusX(), ell.getRadiusY(), doc);
	copyPropertiesToSVG(elt, ell);
	return elt;
}
 
源代码5 项目: latexdraw   文件: TestViewDot.java
@BeforeEach
void setUp() {
	pathBefore = duplicatePath(getPathView().getElements());
	final Ellipse dotView = getDotView();
	dotBefore = new Ellipse(dotView.getCenterX(), dotView.getCenterY(), dotView.getRadiusX(), dotView.getRadiusY());
}
 
源代码6 项目: gef   文件: Shape2Geometry.java
/**
 * Converts the given JavaFX {@link Ellipse} to a
 * {@link org.eclipse.gef.geometry.planar.Ellipse}.
 *
 * @param ellipse
 *            The JavaFX {@link Ellipse} to convert.
 * @return The newly created
 *         {@link org.eclipse.gef.geometry.planar.Ellipse} that describes
 *         the given {@link Ellipse}.
 */
public static org.eclipse.gef.geometry.planar.Ellipse toEllipse(
		Ellipse ellipse) {
	return new org.eclipse.gef.geometry.planar.Ellipse(
			ellipse.getCenterX() - ellipse.getRadiusX(),
			ellipse.getCenterY() - ellipse.getRadiusY(),
			ellipse.getRadiusX() + ellipse.getRadiusX(),
			ellipse.getRadiusY() + ellipse.getRadiusY());
}