org.fxmisc.richtext.demo.lineindicator.ArrowFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of richtextfx Show documentation
Show all versions of richtextfx Show documentation
FX-Text-Area for formatted text and other special effects.
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