All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fxmisc.richtext.demo.lineindicator.ArrowFactory Maven / Gradle / Ivy

There is a newer version: 1.11
Show newest version

package org.fxmisc.richtext.demo.lineindicator;

import javafx.beans.value.ObservableValue;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;

import org.reactfx.value.Val;

import java.util.function.IntFunction;

/**
 * 

Name: ArrowFactory

*

Description: Given the line number, return a node (graphic) to display to the left of a line. *

*

Comment: ... *

*

Copyright: Copyright (c) 2016-2019

*

Company: >StA-Soft<

* @author StA * @version 1.0 */ public class ArrowFactory implements IntFunction { /** * Zeile. */ private final ObservableValue myShownLine; /** * Constructor. * @param pShownLine Zeile */ ArrowFactory(ObservableValue pShownLine) { myShownLine = pShownLine; } @Override public Node apply(int lineNumber) { Polygon triangle = new Polygon(0.0, 0.0, 10.0, 5.0, 0.0, 10.0); triangle.setFill(Color.GREEN); ObservableValue visible = Val.map(myShownLine, sl -> sl == lineNumber); triangle.visibleProperty().bind(Val.flatMap(triangle.sceneProperty(), scene -> scene != null ? visible : Val.constant(false))); return triangle; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy