Example usage for javafx.scene.control Label textFillProperty

List of usage examples for javafx.scene.control Label textFillProperty

Introduction

In this page you can find the example usage for javafx.scene.control Label textFillProperty.

Prototype

public final ObjectProperty<Paint> textFillProperty() 

Source Link

Usage

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

synchronized private void initVertex(INode vertex) {

    if (vertex.getAddress().isMulticast()) {
        return;/*  w  w  w .j a  va2 s.com*/
    }

    final IRenderer renderer = vertex.getComponent(ViewComponent.class).getRenderer();
    final Shape nodeShape = renderer.getShape();
    //nodeShape.addEventFilter( MouseEvent.MOUSE_PRESSED, nodeGestures.getOnMousePressedEventHandler());
    //nodeShape.addEventFilter( MouseEvent.MOUSE_DRAGGED, nodeGestures.getOnMouseDraggedEventHandler());

    //nodeShape.setCache(false);
    //nodeShape.setCacheHint(CacheHint.);

    final NodeStatisticsComponent nsc = vertex.getComponent(NodeStatisticsComponent.class);

    final DoubleBinding nodeSize = MyBindings
            .divideIntToDouble(nsc.getCommunicationCountProperty(), port.getMaxThroughputProperty()).add(1);

    nodeShape.scaleXProperty().bind(nodeSize);
    nodeShape.scaleYProperty().bind(nodeSize);

    nodeShape.setLayoutX(layout.transform(vertex).getX());
    nodeShape.setLayoutY(layout.transform(vertex).getY());

    ///////////
    // LABEL //
    ///////////

    Label nodeLabel = new Label();

    // cast the shapes to circles (because right now i know they are circles) //TODO make this for arbitrary shapes
    final Circle nodeCircle = (Circle) nodeShape;

    /*        final DoubleProperty labelX = new SimpleDoubleProperty();
            final DoubleProperty labelY = new SimpleDoubleProperty();*/

    //labelX.bind(nodeShape.layoutXProperty().add(nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty())));
    //labelY.bind(nodeShape.layoutYProperty().add(nodeCircle.radiusProperty().multiply(nodeShape.scaleYProperty())));

    //nodeLabel.layoutXProperty().bindBidirectionalWithOffset(labelX);
    //nodeLabel.layoutYProperty().bindBidirectionalWithOffset(labelY);

    //nodeLabel.layoutXProperty().bind(nodeShape.layoutXProperty().add(nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty())));

    nodeLabel.textFillProperty().bind(new SimpleObjectProperty<>(Color.WHITE));

    //MyBindings.bindBidirectionalWithOffset(nodeLabel.layoutXProperty(), nodeShape.layoutXProperty(), nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty()));
    //MyBindings.bindBidirectionalWithOffset(nodeLabel.layoutYProperty(), nodeShape.layoutYProperty(), nodeCircle.radiusProperty().multiply(nodeShape.scaleYProperty()));

    nodeLabel.layoutXProperty().bind(nodeShape.layoutXProperty().add(nodeShape.translateXProperty())
            .add(nodeCircle.radiusProperty().multiply(nodeShape.scaleXProperty())));
    nodeLabel.layoutYProperty().bind(nodeShape.layoutYProperty().add(nodeShape.translateYProperty())
            .add(nodeCircle.radiusProperty().multiply(nodeShape.scaleYProperty())));

    NodeInfoComponent nic = vertex.getComponent(NodeInfoComponent.class);
    if (nic != null) {
        nodeLabel.textProperty().bind(nic.toStringBinding());
    }

    nodeLabel.scaleXProperty().bind(Bindings.divide(1, canvas.scaleXProperty()));
    nodeLabel.scaleYProperty().bind(Bindings.divide(1, canvas.scaleYProperty()));

    nodeLabel.addEventFilter(MouseEvent.MOUSE_PRESSED, nodeGestures.getOnMousePressedEventHandler(vertex));
    nodeLabel.addEventFilter(MouseEvent.MOUSE_DRAGGED, nodeGestures.getOnMouseDraggedEventHandler(vertex));
    nodeLabel.addEventFilter(MouseEvent.MOUSE_RELEASED, nodeGestures.getOnMouseReleasedEventHandler(vertex));

    nodeShape.addEventFilter(MouseEvent.MOUSE_PRESSED, nodeGestures.getOnMousePressedEventHandler(vertex));
    nodeShape.addEventFilter(MouseEvent.MOUSE_DRAGGED, nodeGestures.getOnMouseDraggedEventHandler(vertex));
    nodeShape.addEventFilter(MouseEvent.MOUSE_RELEASED, nodeGestures.getOnMouseReleasedEventHandler(vertex));
    nodeShape.addEventFilter(MouseEvent.MOUSE_CLICKED, nodeGestures.getOnMouseClickedEventHandler(vertex));

    canvas.getChildren().addAll(nodeLabel, nodeShape);
}