Example usage for javafx.scene.shape Line setFill

List of usage examples for javafx.scene.shape Line setFill

Introduction

In this page you can find the example usage for javafx.scene.shape Line setFill.

Prototype

public final void setFill(Paint value) 

Source Link

Usage

From source file:edu.kit.trufflehog.view.jung.visualization.FXVisualizationViewer.java

public FXVisualizationViewer(INetworkViewPort port) {

    this.port = port;
    // create canvas
    this.setStyle("-fx-background-color: #213245");

    for (double divide = .25; divide < 1; divide += .25) {
        final Line line = new Line(0, 200, this.getWidth(), this.getHeight());
        line.setFill(null);
        line.setStroke(Color.web("0x385172"));
        line.setStrokeWidth(1.3);//from   w w  w .  jav  a 2  s  .c  o m
        line.getStrokeDashArray().addAll(5d, 10d);

        line.startYProperty().bind(this.heightProperty().multiply(divide));

        line.endXProperty().bind(this.widthProperty());
        line.endYProperty().bind(this.heightProperty().multiply(divide));

        this.getChildren().add(line);
    }

    for (double divide = .25; divide < 1; divide += .25) {
        final Line line = new Line(0, 0, this.getWidth(), this.getHeight());
        line.setFill(null);
        line.setStroke(Color.web("0x385172"));
        line.setStrokeWidth(1.3);
        line.getStrokeDashArray().addAll(5d, 10d);

        line.startXProperty().bind(this.widthProperty().multiply(divide));

        line.endXProperty().bind(this.widthProperty().multiply(divide));
        line.endYProperty().bind(this.heightProperty());

        this.getChildren().add(line);
    }

    //StackPane spane = new StackPane();
    //spane.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null)));

    Pane ghost = new Pane();
    canvas = new PannableCanvas(ghost);

    Pane parent = new Pane();
    parent.getChildren().add(ghost);
    parent.getChildren().add(canvas);

    SceneGestures sceneGestures = new SceneGestures(parent, canvas);

    addEventFilter(MouseEvent.MOUSE_PRESSED, sceneGestures.getOnMousePressedEventHandler());
    addEventFilter(MouseEvent.MOUSE_DRAGGED, sceneGestures.getOnMouseDraggedEventHandler());
    addEventFilter(ScrollEvent.ANY, sceneGestures.getOnScrollEventHandler());

    new RubberBandSelection(this);

    // TODO make canvas transparent
    //canvas.setStyle("-fx-background-color: #1d1d1d");

    // we don't want the canvas on the top/left in this example => just
    // translate it a bit
    //canvas.setTranslateX(100);
    //canvas.setTranslateY(100);

    // create sample nodes which can be dragged
    nodeGestures = new NodeGestures();
    //this.getChildren().add(spane);
    this.getChildren().add(parent);

    this.layout = port.getDelegate();

    //this.layout.getGraph().getVertices().forEach(v -> Platform.runLater(() -> this.initVertex(v)));
    //this.layout.getGraph().getEdges().forEach(e -> Platform.runLater(() -> this.initEdge(e)));

    this.layout.getObservableGraph().addGraphEventListener(e -> {

        //Platform.runLater(() -> {

        switch (e.getType()) {
        case VERTEX_ADDED:
            final INode node = ((GraphEvent.Vertex<INode, IConnection>) e).getVertex();
            Platform.runLater(() -> initVertex(node));
            break;

        case EDGE_ADDED:
            final IConnection edge = ((GraphEvent.Edge<INode, IConnection>) e).getEdge();
            Platform.runLater(() -> initEdge(edge));
            break;

        case VERTEX_CHANGED:
            break;

        case EDGE_CHANGED:
            final IConnection changedEdge = ((GraphEvent.Edge<INode, IConnection>) e).getEdge();
            Platform.runLater(() -> changedEdge.getComponent(ViewComponent.class).getRenderer().animate());
            break;
        }
        //});
    });

}