org.fxmisc.richtext.skin.TextExt 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
Rich-text area for JavaFX
package org.fxmisc.richtext.skin;
import java.util.ArrayList;
import java.util.List;
import javafx.beans.property.ObjectProperty;
import javafx.css.CssMetaData;
import javafx.css.StyleConverter;
import javafx.css.Styleable;
import javafx.css.StyleableObjectProperty;
import javafx.css.StyleableProperty;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.text.Text;
public class TextExt extends Text {
private final StyleableObjectProperty backgroundFill = new StyleableObjectProperty(null) {
@Override
public Object getBean() {
return TextExt.this;
}
@Override
public String getName() {
return "backgroundFill";
}
@Override
public CssMetaData getCssMetaData() {
return StyleableProperties.BACKGROUND_FILL;
}
};
TextExt(String text) {
super(text);
}
@Override
public List> getCssMetaData() {
// Get list value and make it modifiable
List> styleables = new ArrayList<>(super.getCssMetaData());
// Add new properties
styleables.add(StyleableProperties.BACKGROUND_FILL);
// Return list value
return styleables;
}
public Paint getBackgroundFill() {
return backgroundFill.get();
}
public void setBackgroundFill(Paint fill) {
backgroundFill.set(fill);
}
public ObjectProperty backgroundFillProperty() {
return backgroundFill;
}
private static class StyleableProperties {
private static final CssMetaData BACKGROUND_FILL = new CssMetaData(
"-fx-background-fill",
StyleConverter.getPaintConverter(),
Color.TRANSPARENT) {
@Override
public boolean isSettable(TextExt node) {
return !node.backgroundFill.isBound();
}
@Override
public StyleableProperty getStyleableProperty(TextExt node) {
return node.backgroundFill;
}
};
}
}