Example usage for javafx.scene.shape StrokeLineCap BUTT

List of usage examples for javafx.scene.shape StrokeLineCap BUTT

Introduction

In this page you can find the example usage for javafx.scene.shape StrokeLineCap BUTT.

Prototype

StrokeLineCap BUTT

To view the source code for javafx.scene.shape StrokeLineCap BUTT.

Click Source Link

Document

Ends unclosed subpaths and dash segments with no added decoration.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);/* w w w . ja  v  a  2s . c o m*/

    Rectangle rect = new Rectangle(100, 100);
    rect.setLayoutX(50);
    rect.setLayoutY(50);
    rect.setStrokeLineCap(StrokeLineCap.BUTT);
    ((Group) scene.getRoot()).getChildren().add(rect);

    stage.show();

}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Drawing Lines");

    Group root = new Group();
    Scene scene = new Scene(root, 300, 150, Color.GRAY);

    Line redLine = new Line(10, 10, 200, 10);

    redLine.setStroke(Color.RED);
    redLine.setStrokeWidth(10);//w ww.  j  a  v a  2s  .  c  o  m
    redLine.setStrokeLineCap(StrokeLineCap.BUTT);

    redLine.getStrokeDashArray().addAll(15d, 5d, 15d, 15d, 20d);
    redLine.setStrokeDashOffset(10);

    root.getChildren().add(redLine);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {

    Group root = new Group();

    Scene scene = new Scene(root, 300, 150, Color.GRAY);

    Line redLine = new Line(10, 10, 200, 10);

    redLine.setStroke(Color.RED);
    redLine.setStrokeWidth(10);/*from  w w w . ja v a2s .c  o  m*/
    redLine.setStrokeLineCap(StrokeLineCap.BUTT);

    redLine.getStrokeDashArray().addAll(10d, 5d, 15d, 5d, 20d);
    redLine.setStrokeDashOffset(0);

    root.getChildren().add(redLine);

    Text offsetText = new Text("Stroke Dash Offset: 0.0");
    offsetText.setX(10);
    offsetText.setY(80);
    offsetText.setStroke(Color.WHITE);

    root.getChildren().add(offsetText);

    Slider slider = new Slider(0, 100, 0);
    slider.setLayoutX(10);
    slider.setLayoutY(95);

    redLine.strokeDashOffsetProperty().bind(slider.valueProperty());

    slider.valueProperty().addListener(
            (ov, curVal, newVal) -> offsetText.setText("Stroke Dash Offset: " + slider.getValue()));

    root.getChildren().add(slider);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 260);

    Rectangle roundRect = new Rectangle(50, 50, 400, 130);

    roundRect.setArcWidth(30);/*from  www .j a  va  2s .  c o m*/
    roundRect.setArcHeight(60);

    roundRect.setFill(null);
    roundRect.setStroke(Color.DARKORANGE);
    roundRect.setStrokeWidth(2);
    roundRect.setStrokeLineCap(StrokeLineCap.BUTT);

    root.getChildren().add(roundRect);

    Slider slider = new Slider(30, 150, 30);
    slider.setLayoutX(250 - slider.getWidth() / 2);
    slider.setLayoutY(115 - slider.getHeight() / 2);

    slider.widthProperty().addListener((ov, curVal, newVal) -> {
        slider.setLayoutX(250 - slider.getWidth() / 2);
    });

    slider.heightProperty()
            .addListener((ov, curVal, newVal) -> slider.setLayoutY(115 - slider.getHeight() / 2));

    roundRect.arcWidthProperty().bind(slider.valueProperty());

    root.getChildren().add(slider);

    Slider slider2 = new Slider(10, 120, 50);
    slider2.setLayoutX(50);
    slider2.setLayoutY(230);

    slider2.widthProperty().addListener((ov, curVal, newVal) -> {
        slider2.setLayoutX(250 - slider2.getWidth() / 2);
    });

    roundRect.yProperty().bind(slider2.valueProperty());
    root.getChildren().add(slider2);

    slider2.valueProperty().addListener((ov, curVal, newVal) -> slider
            .setLayoutY(slider.getLayoutY() + newVal.doubleValue() - curVal.doubleValue()));
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

private Line connect(Circle c1, Circle c2) {
    Line line = new Line();

    line.startXProperty().bind(c1.centerXProperty());
    line.startYProperty().bind(c1.centerYProperty());

    line.endXProperty().bind(c2.centerXProperty());
    line.endYProperty().bind(c2.centerYProperty());

    line.setStrokeWidth(1);/*from  w w  w  .  j  ava 2s.co m*/
    line.setStrokeLineCap(StrokeLineCap.BUTT);
    line.getStrokeDashArray().setAll(1.0, 4.0);

    return line;
}