javafx.scene.shape.Ellipse Java Examples

The following examples show how to use javafx.scene.shape.Ellipse. 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: Main.java    From JavaFX with MIT License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws IOException {
	Group root = new Group();
	// describes the window itself: name, size
	primaryStage.setTitle(" Aufgabe 10 by John Malc ");
	primaryStage.setScene(new Scene(root));
	// say: center on screen, user can resize, and it will in general exists
	primaryStage.centerOnScreen();
	primaryStage.setResizable(true);
	primaryStage.show();

	// Ellipse alone
	Ellipse a = new Ellipse();
	a.setFill(Color.RED);
	a.setCenterX(205);
	a.setCenterY(150);
	a.setRadiusX(80);
	a.setRadiusY(30);

	// shows Ellipse and it will add it to the group
	root.getChildren().add(new Group(a));
}
 
Example #2
Source File: EllipseSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public EllipseSample() {
    super(180,90);
    // Simple red filled ellipse
    Ellipse ellipse1 = new Ellipse(45,45,30,45);
    ellipse1.setFill(Color.RED);
    // Blue stroked ellipse
    Ellipse ellipse2 = new Ellipse(135,45,30,45);
    ellipse2.setStroke(Color.DODGERBLUE);
    ellipse2.setFill(null);
    // Create a group to show all the ellipses);
    getChildren().add(new Group(ellipse1,ellipse2));
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Ellipse 1 Fill", ellipse1.fillProperty()),
            new SimplePropertySheet.PropDesc("Ellipse 1 Width", ellipse1.radiusXProperty(), 10d, 40d),
            new SimplePropertySheet.PropDesc("Ellipse 1 Height", ellipse1.radiusYProperty(), 10d, 45d),
            new SimplePropertySheet.PropDesc("Ellipse 2 Stroke", ellipse2.strokeProperty()),
            new SimplePropertySheet.PropDesc("Ellipse 2 Stroke Width", ellipse2.strokeWidthProperty(), 1d, 5d),
            new SimplePropertySheet.PropDesc("Ellipse 2 Width", ellipse2.radiusXProperty(), 10d, 40d),
            new SimplePropertySheet.PropDesc("Ellipse 2 Height", ellipse2.radiusYProperty(), 10d, 45d)
    );
    // END REMOVE ME
}
 
Example #3
Source File: EllipseSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public EllipseSample() {
    super(180,90);
    // Simple red filled ellipse
    Ellipse ellipse1 = new Ellipse(45,45,30,45);
    ellipse1.setFill(Color.RED);
    // Blue stroked ellipse
    Ellipse ellipse2 = new Ellipse(135,45,30,45);
    ellipse2.setStroke(Color.DODGERBLUE);
    ellipse2.setFill(null);
    // Create a group to show all the ellipses);
    getChildren().add(new Group(ellipse1,ellipse2));
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Ellipse 1 Fill", ellipse1.fillProperty()),
            new SimplePropertySheet.PropDesc("Ellipse 1 Width", ellipse1.radiusXProperty(), 10d, 40d),
            new SimplePropertySheet.PropDesc("Ellipse 1 Height", ellipse1.radiusYProperty(), 10d, 45d),
            new SimplePropertySheet.PropDesc("Ellipse 2 Stroke", ellipse2.strokeProperty()),
            new SimplePropertySheet.PropDesc("Ellipse 2 Stroke Width", ellipse2.strokeWidthProperty(), 1d, 5d),
            new SimplePropertySheet.PropDesc("Ellipse 2 Width", ellipse2.radiusXProperty(), 10d, 40d),
            new SimplePropertySheet.PropDesc("Ellipse 2 Height", ellipse2.radiusYProperty(), 10d, 45d)
    );
    // END REMOVE ME
}
 
Example #4
Source File: Level19.java    From FXGLGames with MIT License 6 votes vote down vote up
@Override
public void init() {
    double t = 0;

    for (int y = 0; y < ENEMY_ROWS; y++) {
        for (int x = 0; x < ENEMIES_PER_ROW; x++) {
            Entity enemy = spawnEnemy(random(0, getAppWidth() - 100), random(0, getAppHeight() / 2.0));

            var a = animationBuilder()
                    .repeatInfinitely()
                    .autoReverse(true)
                    .delay(Duration.seconds(t))
                    .duration(Duration.seconds(1.6))
                    .translate(enemy)
                    .alongPath(new Ellipse(getAppWidth() / 2, getAppHeight() / 2 - 200, 200, 150))
                    .build();

            animations.add(a);
            a.start();

            t += 0.3;
        }
    }
}
 
Example #5
Source File: Level19.java    From FXGLGames with MIT License 6 votes vote down vote up
@Override
public void init() {
    double t = 0;

    for (int y = 0; y < ENEMY_ROWS; y++) {
        for (int x = 0; x < ENEMIES_PER_ROW; x++) {
            Entity enemy = spawnEnemy(random(0, getAppWidth() - 100), random(0, getAppHeight() / 2.0));

            var a = animationBuilder()
                    .repeatInfinitely()
                    .autoReverse(true)
                    .delay(Duration.seconds(t))
                    .duration(Duration.seconds(1.6))
                    .translate(enemy)
                    .alongPath(new Ellipse(getAppWidth() / 2, getAppHeight() / 2 - 200, 200, 150))
                    .build();

            animations.add(a);
            a.start();

            t += 0.3;
        }
    }
}
 
Example #6
Source File: DisplayShot.java    From ShootOFF with GNU General Public License v3.0 6 votes vote down vote up
public void setDisplayVals(int displayWidth, int displayHeight, int feedWidth, int feedHeight) {

		final double scaleX = (double) displayWidth / (double) feedWidth;
		final double scaleY = (double) displayHeight / (double) feedHeight;

		double scaledX, scaledY;
		if (displayX.isPresent()) {
			scaledX = displayX.get() * scaleX;
			scaledY = displayY.get() * scaleY;
		}
		else {
			scaledX = super.getX() * scaleX;
			scaledY = super.getY() * scaleY;
		}

		if (logger.isTraceEnabled()) {
			logger.trace("setTranslation {} {} - {} {} to {} {}", scaleX, scaleY, super.getX(), super.getY(), scaledX, scaledY);
		}

		marker = new Ellipse(scaledX, scaledY, marker.radiusXProperty().get(), marker.radiusYProperty().get());
		marker.setFill(colorMap.get(color));

		displayX = Optional.of(scaledX);
		displayY = Optional.of(scaledY);
		
	}
 
Example #7
Source File: ViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 6 votes vote down vote up
private void unbindShowPoints() {
	showPoint.getChildren().stream().filter(node -> node instanceof Ellipse).map(node -> (Ellipse) node).forEach(ell -> {
		ell.fillProperty().unbind();
		ell.centerXProperty().unbind();
		ell.centerYProperty().unbind();
		ell.radiusXProperty().unbind();
		ell.radiusYProperty().unbind();
		ell.visibleProperty().unbind();
	});

	showPoint.getChildren().stream().filter(node -> node instanceof Line).map(node -> (Line) node).forEach(line -> {
		line.startXProperty().unbind();
		line.startYProperty().unbind();
		line.endXProperty().unbind();
		line.endYProperty().unbind();
		line.strokeWidthProperty().unbind();
		line.strokeProperty().unbind();
	});
}
 
Example #8
Source File: ViewDot.java    From latexdraw with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the view.
 * @param sh The model.
 */
ViewDot(final Dot sh, final PathElementProducer pathProducer) {
	super(sh);
	this.pathProducer = pathProducer;
	path = new Path();
	dot = new Ellipse();
	getChildren().addAll(dot, path);

	model.styleProperty().addListener(updateDot);
	model.getPosition().xProperty().addListener(updateDot);
	model.getPosition().yProperty().addListener(updateDot);
	model.diametreProperty().addListener(updateDot);
	model.fillingColProperty().addListener(updateDot);
	model.lineColourProperty().addListener(updateStrokeFill);
	rotateProperty().bind(Bindings.createDoubleBinding(() -> Math.toDegrees(model.getRotationAngle()), model.rotationAngleProperty()));
	updateDot();
}
 
Example #9
Source File: HeroIcon.java    From clarity-analyzer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public HeroIcon(ObservableEntity oe) {
    super(oe);

    shape = new Ellipse(140, 140);
    shape.fillProperty().bind(getPlayerColor());
    shape.translateXProperty().bind(getMapX());
    shape.translateYProperty().bind(getMapY());
}
 
Example #10
Source File: DisplayShot.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
public DisplayShot(Shot shot, int markerRadius) {
	super(shot);
	if (shot instanceof DisplayShot)
	{
		this.displayX = ((DisplayShot) shot).displayX;
		this.displayY = ((DisplayShot) shot).displayY;
	}
	marker = new Ellipse(getX(), getY(), markerRadius, markerRadius);
	marker.setFill(colorMap.get(color));
}
 
Example #11
Source File: Piece.java    From FXTutorials with MIT License 5 votes vote down vote up
public Piece(PieceType type, int x, int y) {
    this.type = type;

    move(x, y);

    Ellipse bg = new Ellipse(TILE_SIZE * 0.3125, TILE_SIZE * 0.26);
    bg.setFill(Color.BLACK);

    bg.setStroke(Color.BLACK);
    bg.setStrokeWidth(TILE_SIZE * 0.03);

    bg.setTranslateX((TILE_SIZE - TILE_SIZE * 0.3125 * 2) / 2);
    bg.setTranslateY((TILE_SIZE - TILE_SIZE * 0.26 * 2) / 2 + TILE_SIZE * 0.07);

    Ellipse ellipse = new Ellipse(TILE_SIZE * 0.3125, TILE_SIZE * 0.26);
    ellipse.setFill(type == PieceType.RED
            ? Color.valueOf("#c40003") : Color.valueOf("#fff9f4"));

    ellipse.setStroke(Color.BLACK);
    ellipse.setStrokeWidth(TILE_SIZE * 0.03);

    ellipse.setTranslateX((TILE_SIZE - TILE_SIZE * 0.3125 * 2) / 2);
    ellipse.setTranslateY((TILE_SIZE - TILE_SIZE * 0.26 * 2) / 2);

    getChildren().addAll(bg, ellipse);

    setOnMousePressed(e -> {
        mouseX = e.getSceneX();
        mouseY = e.getSceneY();
    });

    setOnMouseDragged(e -> {
        relocate(e.getSceneX() - mouseX + oldX, e.getSceneY() - mouseY + oldY);
    });
}
 
Example #12
Source File: Exercise_14_11.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
/** Return an Ellipse of specified properties */
private Ellipse getEllipse(Circle c) {
	Ellipse e = new Ellipse();
	e.setCenterY(c.getRadius() - c.getRadius() / 3);
	e.setRadiusX(c.getRadius() / 4);
	e.setRadiusY(c.getRadius() / 3 - 20);
	e.setStroke(Color.BLACK);
	e.setFill(Color.WHITE);
	return e; 
}
 
Example #13
Source File: ShapeConverter.java    From Enzo with Apache License 2.0 5 votes vote down vote up
public static String shapeToSvgString(final Shape SHAPE) {
    final StringBuilder fxPath = new StringBuilder();
    if (Line.class.equals(SHAPE.getClass())) {
        fxPath.append(convertLine((Line) SHAPE));
    } else if (Arc.class.equals(SHAPE.getClass())) {
        fxPath.append(convertArc((Arc) SHAPE));
    } else if (QuadCurve.class.equals(SHAPE.getClass())) {
        fxPath.append(convertQuadCurve((QuadCurve) SHAPE));
    } else if (CubicCurve.class.equals(SHAPE.getClass())) {
        fxPath.append(convertCubicCurve((CubicCurve) SHAPE));
    } else if (Rectangle.class.equals(SHAPE.getClass())) {
        fxPath.append(convertRectangle((Rectangle) SHAPE));
    } else if (Circle.class.equals(SHAPE.getClass())) {
        fxPath.append(convertCircle((Circle) SHAPE));
    } else if (Ellipse.class.equals(SHAPE.getClass())) {
        fxPath.append(convertEllipse((Ellipse) SHAPE));
    } else if (Text.class.equals(SHAPE.getClass())) {
        Path path = (Path)(Shape.subtract(SHAPE, new Rectangle(0, 0)));
        fxPath.append(convertPath(path));
    } else if (Path.class.equals(SHAPE.getClass())) {
        fxPath.append(convertPath((Path) SHAPE));
    } else if (Polygon.class.equals(SHAPE.getClass())) {
        fxPath.append(convertPolygon((Polygon) SHAPE));
    } else if (Polyline.class.equals(SHAPE.getClass())) {
        fxPath.append(convertPolyline((Polyline) SHAPE));
    } else if (SVGPath.class.equals(SHAPE.getClass())) {
        fxPath.append(((SVGPath) SHAPE).getContent());
    }
    return fxPath.toString();
}
 
Example #14
Source File: ShapeConverter.java    From Enzo with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #15
Source File: ViewArrow.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the view.
 * @param model The arrow. Cannot be null.
 * @throws NullPointerException if the given arrow is null.
 */
ViewArrow(final Arrow model) {
	super();
	setId(ID);
	arrow = Objects.requireNonNull(model);
	path = new Path();
	ellipse = new Ellipse();
	arc = new Arc();
	getChildren().add(path);
	getChildren().add(ellipse);
	getChildren().add(arc);
	enableShape(false, false, false);
}
 
Example #16
Source File: ViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sub routine that creates and binds show points.
 */
private final void bindShowPoints() {
	showPoint.getChildren().addAll(Stream.concat(Stream.concat(model.getPoints().stream(), model.getFirstCtrlPts().stream()),
		model.getSecondCtrlPts().stream()).map(pt -> {
			final Ellipse dot = new Ellipse();
			dot.fillProperty().bind(Bindings.createObjectBinding(() -> model.getLineColour().toJFX(), model.lineColourProperty()));
			dot.centerXProperty().bind(pt.xProperty());
			dot.centerYProperty().bind(pt.yProperty());
			dot.radiusXProperty().bind(Bindings.createDoubleBinding(() -> (model.getArrowAt(0).getDotSizeDim() +
				model.getArrowAt(0).getDotSizeNum() * model.getFullThickness()) / 2d, model.thicknessProperty(), model.dbleBordProperty(),
				model.dbleBordSepProperty(), model.getArrowAt(0).dotSizeDimProperty(), model.getArrowAt(0).dotSizeNumProperty()));
			dot.radiusYProperty().bind(dot.radiusXProperty());
			return dot;
		}).collect(Collectors.toList()));

	showPoint.getChildren().addAll(IntStream.range(0, model.getFirstCtrlPts().size()).
		mapToObj(i -> createLine(model.getFirstCtrlPtAt(i), model.getSecondCtrlPtAt(i))).collect(Collectors.toList()));

	showPoint.getChildren().addAll(IntStream.range(1, model.getFirstCtrlPts().size() - 1).
		mapToObj(i -> createLine(model.getSecondCtrlPtAt(i), model.getFirstCtrlPtAt(i + 1))).collect(Collectors.toList()));

	showPoint.getChildren().addAll(createLine(model.getFirstCtrlPtAt(0), model.getFirstCtrlPtAt(1)));

	// Hiding points on arrows
	showPoint.getChildren().stream().filter(node -> node instanceof Ellipse &&
		MathUtils.INST.equalsDouble(((Ellipse) node).getCenterX(), model.getPtAt(0).getX(), 0.00001) &&
		MathUtils.INST.equalsDouble(((Ellipse) node).getCenterY(), model.getPtAt(0).getY(), 0.00001)).findAny().
		ifPresent(ell -> ell.visibleProperty().bind(model.getArrowAt(0).styleProperty().isEqualTo(ArrowStyle.NONE)));

	showPoint.getChildren().stream().filter(node -> node instanceof Ellipse &&
		MathUtils.INST.equalsDouble(((Ellipse) node).getCenterX(), model.getPtAt(-1).getX(), 0.00001) &&
		MathUtils.INST.equalsDouble(((Ellipse) node).getCenterY(), model.getPtAt(-1).getY(), 0.00001)).findAny().
		ifPresent(ell -> ell.visibleProperty().bind(model.getArrowAt(-1).styleProperty().isEqualTo(ArrowStyle.NONE)));
}
 
Example #17
Source File: StopWatchSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private void configureBackground() {
    ImageView imageView = new ImageView();
    Image image = loadImage();
    imageView.setImage(image);

    Circle circle1 = new Circle();
    circle1.setCenterX(140);
    circle1.setCenterY(140);
    circle1.setRadius(120);
    circle1.setFill(Color.TRANSPARENT);
    circle1.setStroke(Color.web("#0A0A0A"));
    circle1.setStrokeWidth(0.3);

    Circle circle2 = new Circle();
    circle2.setCenterX(140);
    circle2.setCenterY(140);
    circle2.setRadius(118);
    circle2.setFill(Color.TRANSPARENT);
    circle2.setStroke(Color.web("#0A0A0A"));
    circle2.setStrokeWidth(0.3);

    Circle circle3 = new Circle();
    circle3.setCenterX(140);
    circle3.setCenterY(140);
    circle3.setRadius(140);
    circle3.setFill(Color.TRANSPARENT);
    circle3.setStroke(Color.web("#818a89"));
    circle3.setStrokeWidth(1);

    Ellipse ellipse = new Ellipse(140, 95, 180, 95);
    Circle ellipseClip = new Circle(140, 140, 140);
    ellipse.setFill(Color.web("#535450"));
    ellipse.setStrokeWidth(0);
    GaussianBlur ellipseEffect = new GaussianBlur();
    ellipseEffect.setRadius(10);
    ellipse.setEffect(ellipseEffect);
    ellipse.setOpacity(0.1);
    ellipse.setClip(ellipseClip);
    background.getChildren().addAll(imageView, circle1, circle2, circle3, ellipse);
}
 
Example #18
Source File: ViewEllipseBased.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
private static void unbindEll(final Ellipse sh) {
	if(sh != null) {
		sh.centerXProperty().unbind();
		sh.centerYProperty().unbind();
		sh.radiusXProperty().unbind();
		sh.radiusYProperty().unbind();
	}
}
 
Example #19
Source File: JFXToSVG.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
public SVGElement shapeToElement(final Shape shape, final SVGDocument doc) {
	if(shape instanceof Path) {
		return pathToSVGPath((Path) shape, doc);
	}
	if(shape instanceof Ellipse) {
		return ellipseToSVGEllipse((Ellipse) shape, doc);
	}
	return null;
}
 
Example #20
Source File: EllipseSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    Ellipse ellipse = new Ellipse(57,57, 20,40);
    ellipse.setStroke(Color.web("#b9c0c5"));
    ellipse.setStrokeWidth(5);
    ellipse.getStrokeDashArray().addAll(15d,15d);
    ellipse.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));
    ellipse.setEffect(effect);
    return ellipse;
}
 
Example #21
Source File: TestViewPlot.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
void testOnChangeDotDiametre() {
	model.setPlotStyle(PlotStyle.DOTS);
	WaitForAsyncUtils.waitForFxEvents();
	final double before = ((Ellipse) ((ViewDot) view.getChildren().get(0)).getChildren().get(0)).getRadiusX();
	model.setDiametre(model.getDiametre() * 1.577);
	WaitForAsyncUtils.waitForFxEvents();
	assertNotEquals(before, ((Ellipse) ((ViewDot) view.getChildren().get(0)).getChildren().get(0)).getRadiusX());
}
 
Example #22
Source File: TestViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
void testShowPtsDotsOkColor() {
	model.setShowPts(true);
	model.setLineColour(ShapeFactory.INST.createColorFX(Color.RED));
	WaitForAsyncUtils.waitForFxEvents();
	assertThat(view.showPoint.getChildren())
		.filteredOn(n -> n instanceof Ellipse)
		.allMatch(elt -> Color.RED.equals(((Shape) elt).getFill()));
}
 
Example #23
Source File: TestViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
void testShowPtsMainDotsOkPosition() {
	model.setShowPts(true);
	WaitForAsyncUtils.waitForFxEvents();
	final List<Point> centers = view.showPoint.getChildren().stream().filter(n -> n instanceof Ellipse).
		map(ell -> ShapeFactory.INST.createPoint(((Ellipse) ell).getCenterX(), ((Ellipse) ell).getCenterY())).collect(Collectors.toList());
	assertThat(model.getPoints())
		.allMatch(pt -> centers.contains(pt));
}
 
Example #24
Source File: TestViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
void testShowPtsCtrl1DotsOkPosition() {
	model.setShowPts(true);
	WaitForAsyncUtils.waitForFxEvents();
	final List<Point> centers = view.showPoint.getChildren().stream().filter(n -> n instanceof Ellipse).
		map(ell -> ShapeFactory.INST.createPoint(((Ellipse) ell).getCenterX(), ((Ellipse) ell).getCenterY())).collect(Collectors.toList());

	assertThat(model.getFirstCtrlPts())
		.allMatch(pt -> centers.contains(pt));
}
 
Example #25
Source File: TestViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
void testShowPtsCtrl2DotsOkPosition() {
	model.setShowPts(true);
	WaitForAsyncUtils.waitForFxEvents();
	final List<Point> centers = view.showPoint.getChildren().stream().filter(n -> n instanceof Ellipse).
		map(ell -> ShapeFactory.INST.createPoint(((Ellipse) ell).getCenterX(), ((Ellipse) ell).getCenterY())).collect(Collectors.toList());

	assertThat(model.getSecondCtrlPts())
		.allMatch(pt -> centers.contains(pt));
}
 
Example #26
Source File: TestViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
void testShowPtsCtrlEllSize() {
	model.setShowPts(true);
	model.setThickness(10d);
	model.setHasDbleBord(true);
	model.setDbleBordSep(12d);
	WaitForAsyncUtils.waitForFxEvents();

	assertThat(view.showPoint.getChildren())
		.filteredOn(n -> n instanceof Ellipse)
		.allMatch(elt -> MathUtils.INST.equalsDouble(
			((Ellipse) elt).getRadiusX(),
			(model.getArrowAt(0).getDotSizeDim() + model.getArrowAt(0).getDotSizeNum() * model.getFullThickness()) / 2d));
}
 
Example #27
Source File: TestViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
void testShowPtsCtrlEllSizeDotParams() {
	model.setShowPts(true);
	model.getArrowAt(0).setDotSizeDim(1.1);
	model.getArrowAt(0).setDotSizeNum(3.3);
	WaitForAsyncUtils.waitForFxEvents();

	assertThat(view.showPoint.getChildren())
		.filteredOn(n -> n instanceof Ellipse)
		.allMatch(elt -> MathUtils.INST.equalsDouble(
			((Ellipse) elt).getRadiusX(),
			(model.getArrowAt(0).getDotSizeDim() + model.getArrowAt(0).getDotSizeNum() * model.getThickness()) / 2d));
}
 
Example #28
Source File: TestViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Test
void testShowPtsCtrlEllNoStroke() {
	model.setShowPts(true);
	WaitForAsyncUtils.waitForFxEvents();
	assertThat(view.showPoint.getChildren())
		.filteredOn(n -> n instanceof Ellipse)
		.extracting(n -> ((Shape) n).getStroke())
		.containsOnlyNulls();
}
 
Example #29
Source File: Piece.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Shape createPieceTab(double eclipseCenterX, double eclipseCenterY, double eclipseRadiusX, double eclipseRadiusY,
        double rectangleX, double rectangleY, double rectangleWidth, double rectangleHeight,
        double circle1CenterX, double circle1CenterY, double circle1Radius,
        double circle2CenterX, double circle2CenterY, double circle2Radius) {
    Ellipse e = new Ellipse(eclipseCenterX, eclipseCenterY, eclipseRadiusX, eclipseRadiusY);
    Rectangle r = new Rectangle(rectangleX, rectangleY, rectangleWidth, rectangleHeight);
    Shape tab = Shape.union(e, r);
    Circle c1 = new Circle(circle1CenterX, circle1CenterY, circle1Radius);
    tab = Shape.subtract(tab, c1);
    Circle c2 = new Circle(circle2CenterX, circle2CenterY, circle2Radius);
    tab = Shape.subtract(tab, c2);
    return tab;
}
 
Example #30
Source File: BaseLEDRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public int[] getBorderRadii()
{
    if (led instanceof Ellipse)
        return new int[]
        {
            model_widget.propWidth().getValue()/2,
            model_widget.propHeight().getValue()/2,
        };
    return super.getBorderRadii();
}