Example usage for javafx.scene.control Label layoutYProperty

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

Introduction

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

Prototype

public final DoubleProperty layoutYProperty() 

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;//from www  .  j  a va2s.  c  o  m
    }

    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);
}

From source file:view.FXApplicationController.java

public void showLabelsForEpoch() {

    overlay.getChildren().clear();//from   w w w  . j a v a  2  s  .c om

    double offsetSize = 1. / (activeChannels.size() + 1);

    for (int i = 0; i < activeChannels.size(); i++) {

        double realOffset = (i + 1.) * offsetSize;

        Label label = new Label(channelNames[activeChannels.get(i)]);
        label.setTextFill(Color.GRAY);
        label.setStyle("-fx-font-family: sans-serif;");
        label.setLayoutX(1);

        label.layoutYProperty().bind(yAxis.heightProperty().multiply(realOffset).add(yAxis.layoutYProperty()));

        overlay.getChildren().add(label);

    }

}