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

org.fxmisc.richtext.CustomCssMetaData Maven / Gradle / Ivy

There is a newer version: 0.11.3
Show newest version
package org.fxmisc.richtext;

import javafx.css.CssMetaData;
import javafx.css.StyleConverter;
import javafx.css.Styleable;
import javafx.css.StyleableObjectProperty;
import javafx.css.StyleableProperty;

import java.util.function.Function;

/**
 * Reduces boilerplate when creating a custom {@link CssMetaData} object
 */
public class CustomCssMetaData extends CssMetaData {

    private final Function> property;

    CustomCssMetaData(String property, StyleConverter converter, V initialValue,
                      Function> getStyleableProperty) {
        super(property, converter, initialValue);
        this.property = getStyleableProperty;
    }

    @Override
    public boolean isSettable(S styleable) {
        return !property.apply(styleable).isBound();
    }

    @Override
    public StyleableProperty getStyleableProperty(S styleable) {
        return property.apply(styleable);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy