Search in sources :

Example 1 with Value

use of org.graphstream.ui.graphicGraph.stylesheet.Value in project gs-ui-javafx by graphstream.

the class FxTextBox method apply.

// public abstract double getAscentDescent();
/**
 * Factory companion object for text boxes.
 */
// static FontRenderContext defaultFontRenderContext = new FontRenderContext(new AffineTransform(), true, true);
public static TextBox apply(DefaultCamera2D camera, Style style) {
    String fontName = style.getTextFont();
    TextStyle fontStyle = style.getTextStyle();
    Value fontSize = style.getTextSize();
    Color textColor = ColorManager.getTextColor(style, 0);
    Color bgColor = null;
    boolean rounded = false;
    switch(style.getTextBackgroundMode()) {
        case NONE:
            break;
        case PLAIN:
            rounded = false;
            bgColor = ColorManager.getTextBackgroundColor(style, 0);
            break;
        case ROUNDEDBOX:
            rounded = true;
            bgColor = ColorManager.getTextBackgroundColor(style, 0);
            break;
        default:
            break;
    }
    Values padding = style.getTextPadding();
    double padx = camera.getMetrics().lengthToPx(padding, 0);
    double pady = padx;
    if (padding.size() > 1)
        camera.getMetrics().lengthToPx(padding, 1);
    return TextBox.apply(fontName, fontStyle, (int) fontSize.value, textColor, bgColor, rounded, padx, pady);
}
Also used : TextStyle(org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.TextStyle) Color(javafx.scene.paint.Color) Value(org.graphstream.ui.graphicGraph.stylesheet.Value) Values(org.graphstream.ui.graphicGraph.stylesheet.Values)

Aggregations

Color (javafx.scene.paint.Color)1 TextStyle (org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.TextStyle)1 Value (org.graphstream.ui.graphicGraph.stylesheet.Value)1 Values (org.graphstream.ui.graphicGraph.stylesheet.Values)1