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

The following examples show how to use javafx.scene.shape.Ellipse#setStroke() . 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: 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 4
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 5
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 6
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 7
Source File: LevelSkin.java    From Medusa with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    tube = new Path();
    tube.setFillRule(FillRule.EVEN_ODD);
    tube.setStroke(null);
    Tooltip.install(tube, barTooltip);

    tubeTop = new Ellipse();
    tubeTop.setStroke(Color.rgb(255, 255, 255, 0.5));
    tubeTop.setStrokeType(StrokeType.INSIDE);
    tubeTop.setStrokeWidth(1);

    tubeBottom = new Ellipse();
    tubeBottom.setStroke(null);

    fluidUpperLeft   = new CubicCurveTo(0.21794871794871795 * PREFERRED_WIDTH, 0.24444444444444444 * PREFERRED_HEIGHT,
                                        0.0, 0.18888888888888888 * PREFERRED_HEIGHT,
                                        0.0, 0.12222222222222222 * PREFERRED_HEIGHT);
    fluidUpperCenter = new CubicCurveTo(PREFERRED_WIDTH, 0.18888888888888888 * PREFERRED_HEIGHT,
                                        0.782051282051282 * PREFERRED_WIDTH, 0.24444444444444444 * PREFERRED_HEIGHT,
                                        0.5 * PREFERRED_WIDTH, 0.24444444444444444 * PREFERRED_HEIGHT);
    fluidUpperRight  = new CubicCurveTo(PREFERRED_WIDTH, 0.7111111111111111 * PREFERRED_HEIGHT,
                                        PREFERRED_WIDTH, 0.12222222222222222 * PREFERRED_HEIGHT,
                                        PREFERRED_WIDTH, 0.12222222222222222 * PREFERRED_HEIGHT);

    fluidBody = new Path();
    fluidBody.getElements().add(new MoveTo(0.0, 0.7111111111111111 * PREFERRED_HEIGHT));
    fluidBody.getElements().add(new CubicCurveTo(0.0, 0.7777777777777778 * PREFERRED_HEIGHT,
                                                 0.21794871794871795 * PREFERRED_WIDTH, 0.8333333333333334 * PREFERRED_HEIGHT,
                                                 0.5 * PREFERRED_WIDTH, 0.8333333333333334 * PREFERRED_HEIGHT));
    fluidBody.getElements().add(new CubicCurveTo(0.782051282051282 * PREFERRED_WIDTH, 0.8333333333333334 * PREFERRED_HEIGHT,
                                                 PREFERRED_WIDTH, 0.7777777777777778 * PREFERRED_HEIGHT,
                                                 PREFERRED_WIDTH, 0.7111111111111111 * PREFERRED_HEIGHT));
    fluidBody.getElements().add(fluidUpperRight);
    fluidBody.getElements().add(fluidUpperCenter);
    fluidBody.getElements().add(fluidUpperLeft);
    fluidBody.getElements().add(new CubicCurveTo(0.0, 0.12222222222222222 * PREFERRED_HEIGHT,
                                                 0.0, 0.7111111111111111 * PREFERRED_HEIGHT,
                                                 0.0, 0.7111111111111111 * PREFERRED_HEIGHT));
    fluidBody.getElements().add(new ClosePath());
    fluidBody.setFillRule(FillRule.EVEN_ODD);
    fluidBody.setStroke(null);

    fluidTop = new Ellipse();
    fluidTop.setStroke(null);

    valueText = new Text(String.format(locale, formatString, gauge.getCurrentValue()));
    valueText.setMouseTransparent(true);
    Helper.enableNode(valueText, gauge.isValueVisible());

    titleText = new Text(gauge.getTitle());

    // Add all nodes
    pane = new Pane(tubeBottom, fluidBody, fluidTop, tube, tubeTop, valueText, titleText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 8
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
}