Java Code Examples for javafx.scene.shape.Ellipse#setFill()

The following examples show how to use javafx.scene.shape.Ellipse#setFill() . 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: 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 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: 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 4
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 5
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 6
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 7
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 8
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 9
Source File: StopWatch.java    From netbeans 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 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: DisplayShot.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
public DisplayShot(ShotColor color, double x, double y, long timestamp, int frame, int markerRadius) {
	super(color, x, y, timestamp, frame);
	marker = new Ellipse(x, y, markerRadius, markerRadius);
	marker.setFill(colorMap.get(color));
}
 
Example 14
Source File: DisplayShot.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
public DisplayShot(ShotColor color, double x, double y, long timestamp, int markerRadius) {
	super(color, x, y, timestamp);
	marker = new Ellipse(x, y, markerRadius, markerRadius);
	marker.setFill(colorMap.get(color));
}
 
Example 15
Source File: Exercise_14_10.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@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
}