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

The following examples show how to use javafx.scene.shape.Polyline#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: PolylineSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    Polyline polyline = new Polyline(new double[]{
        45, 10,
        10, 80,
        80, 80,
    });
    polyline.setStroke(Color.web("#b9c0c5"));
    polyline.setStrokeWidth(5);
    polyline.getStrokeDashArray().addAll(15d,15d);
    polyline.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));
    polyline.setEffect(effect);
    return polyline;
}
 
Example 2
Source File: PolylineSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    Polyline polyline = new Polyline(new double[]{
        45, 10,
        10, 80,
        80, 80,
    });
    polyline.setStroke(Color.web("#b9c0c5"));
    polyline.setStrokeWidth(5);
    polyline.getStrokeDashArray().addAll(15d,15d);
    polyline.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));
    polyline.setEffect(effect);
    return polyline;
}
 
Example 3
Source File: PolylineSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public PolylineSample() {
    super(180,90);
    // Red stroked not closed triangle
    Polyline polyline1 = new Polyline(new double[]{
        45, 10,
        10, 80,
        80, 80,
    });
    polyline1.setFill(Color.TRANSPARENT);
    polyline1.setStroke(Color.RED);

    // Blue stroked closed triangle
    Polyline polyline2 = new Polyline(new double[]{
        135, 10,
        100, 80,
        170, 80,
        135, 10,
    });
    polyline2.setStroke(Color.DODGERBLUE);
    polyline2.setStrokeWidth(2);
    polyline2.setFill(null);

    
    // Create a group to show all the polylines);
    getChildren().add(new Group(polyline1, polyline2));
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Polyline 1 Fill", polyline1.fillProperty()),
            new SimplePropertySheet.PropDesc("Polyline 1 Stroke", polyline1.strokeProperty()),
            new SimplePropertySheet.PropDesc("Polyline 2 Stroke", polyline2.strokeProperty())
    );
    // END REMOVE ME
}
 
Example 4
Source File: PolylineSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public PolylineSample() {
    super(180,90);
    // Red stroked not closed triangle
    Polyline polyline1 = new Polyline(new double[]{
        45, 10,
        10, 80,
        80, 80,
    });
    polyline1.setFill(Color.TRANSPARENT);
    polyline1.setStroke(Color.RED);

    // Blue stroked closed triangle
    Polyline polyline2 = new Polyline(new double[]{
        135, 10,
        100, 80,
        170, 80,
        135, 10,
    });
    polyline2.setStroke(Color.DODGERBLUE);
    polyline2.setStrokeWidth(2);
    polyline2.setFill(null);

    
    // Create a group to show all the polylines);
    getChildren().add(new Group(polyline1, polyline2));
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Polyline 1 Fill", polyline1.fillProperty()),
            new SimplePropertySheet.PropDesc("Polyline 1 Stroke", polyline1.strokeProperty()),
            new SimplePropertySheet.PropDesc("Polyline 2 Stroke", polyline2.strokeProperty())
    );
    // END REMOVE ME
}
 
Example 5
Source File: Exercise_15_09.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a pane 
	Pane pane = new Pane();

	// Create a polyline
	Polyline polyline = new Polyline(new Double(100.0), new Double(100.0));
	polyline.setFill(Color.WHITE);
	polyline.setStroke(Color.BLACK);
	pane.getChildren().add(polyline);
	ObservableList<Double> list = polyline.getPoints();

	// Create and register handler
	pane.setOnKeyPressed(e -> {
		double x = 0, y = 0;
		double length = 10;
		switch (e.getCode()) {
			case DOWN: x = list.get(list.size() - 2);
						  y = list.get(list.size() - 1) + length; break;
			case UP: x = list.get(list.size() - 2);
						y = list.get(list.size() - 1) - length; break;
			case RIGHT: x = list.get(list.size() - 2) + length;
						  y = list.get(list.size() - 1); break;
			case LEFT: x = list.get(list.size() - 2) - length;
						  y = list.get(list.size() - 1); break;

		}
		list.add(x);
		list.add(y); 
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 200, 200);
	primaryStage.setTitle("Exercise_15_09"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage

	pane.requestFocus(); // Pane is focused to receive key input 
}