Java 类javafx.beans.property.StringPropertyBase 实例源码

项目:MoodFX    文件:Btn.java   
public Btn(final String TEXT) {
    getStyleClass().setAll("btn");
    rounded     = new BooleanPropertyBase(false) {
        @Override public Object getBean() { return Btn.this; }
        @Override public String getName() { return "rounded"; }
    };
    buttonColor = new ObjectPropertyBase<Color>(Color.WHITE) {
        @Override public Object getBean() { return Btn.this; }
        @Override public String getName() { return "buttonColor"; }
    };
    thumbColor  = new ObjectPropertyBase<Color>(Color.WHITE) {
        @Override public Object getBean() { return Btn.this; }
        @Override public String getName() { return "thumbColor"; }
    };
    textColor   = new ObjectPropertyBase<Color>(Color.WHITE) {
        @Override public Object getBean() { return Btn.this; }
        @Override public String getName() { return "textColor"; }
    };
    text        = new StringPropertyBase(TEXT) {
        @Override public Object getBean() { return Btn.this; }
        @Override public String getName() { return "textOn"; }
    };

    disabledProperty().addListener(o -> setOpacity(isDisabled() ? 0.4 : 1.0));
}
项目:cardnav    文件:Card.java   
public Card(final String TITLE) {
    getStylesheets().add(Card.class.getResource("card.css").toExternalForm());
    cardColor  = new StyleableObjectProperty<Color>(Color.web("#dae18f")) {
        @Override protected void invalidated() { container.setBackground(new Background(new BackgroundFill(get(), CornerRadii.EMPTY, Insets.EMPTY))); }
        @Override public Object getBean() { return Card.this; }
        @Override public String getName() { return "cardColor"; }
        @Override public CssMetaData<? extends Styleable, Color> getCssMetaData() { return CARD_COLOR; }
    };
    titleColor = new StyleableObjectProperty<Color>(Color.BLACK) {
        @Override protected void invalidated() { titleText.setTextFill(get()); }
        @Override public Object getBean() { return Card.this; }
        @Override public String getName() { return "titleColor"; }
        @Override public CssMetaData<? extends Styleable, Color> getCssMetaData() { return TITLE_COLOR; }
    };
    title      = new StringPropertyBase(TITLE) {
        @Override protected void invalidated() { titleText.setText(get()); }
        @Override public Object getBean() { return Card.this; }
        @Override public String getName() { return "title"; }
    };
    init();
    initGraphics();
    registerListeners();
}
项目:MoodFX    文件:Switch.java   
public Switch() {
    getStyleClass().setAll("switch");
    rounded               = new BooleanPropertyBase(false) {
        @Override public Object getBean() { return Switch.this; }
        @Override public String getName() { return "rounded"; }
    };
    selected              = new BooleanPropertyBase(false) {
        @Override protected void invalidated() {
            if (null != getToggleGroup()) {
                if (get()) {
                    getToggleGroup().selectToggle(Switch.this);
                } else if (getToggleGroup().getSelectedToggle() == Switch.this) {
                    getToggleGroup().selectToggle(null);
                }
            }
            fireEvent(new SwitchEvent(Switch.this, null, selected.get() ? SwitchEvent.ON : SwitchEvent.OFF));
        }
        @Override public Object getBean() { return null; }
        @Override public String getName() { return null; }
    };
    toggleGroup           = new ObjectPropertyBase<ToggleGroup>(null) {
        private ToggleGroup oldToggleGroup;
        @Override protected void invalidated() {
            final ToggleGroup toggleGroup = get();
            if (null != toggleGroup && !toggleGroup.getToggles().contains(Switch.this)) {
                if (oldToggleGroup != null) { oldToggleGroup.getToggles().remove(Switch.this); }
                toggleGroup.getToggles().add(Switch.this);
            } else if (null == toggleGroup) {
                oldToggleGroup.getToggles().remove(Switch.this);
            }
            oldToggleGroup = toggleGroup;
        }
        @Override public Object getBean() { return Switch.this; }
        @Override public String getName() { return "toggleGroup"; }
    };
    switchColor           = new ObjectPropertyBase<Color>(Color.WHITE) {
        @Override public Object getBean() { return Switch.this; }
        @Override public String getName() { return "switchColor"; }
    };
    text                  = new StringPropertyBase("OFF") {
        @Override public Object getBean() { return Switch.this; }
        @Override public String getName() { return "text"; }
    };
    selectedText          = new StringPropertyBase("ON") {
        @Override public Object getBean() { return Switch.this; }
        @Override public String getName() { return "selectedText"; }
    };
    textColor             = new ObjectPropertyBase<Color>(Color.WHITE) {
        @Override public Object getBean() { return Switch.this; }
        @Override public String getName() { return "switchColorOff"; }
    };
    selectedTextColor     = new ObjectPropertyBase<Color>(Color.WHITE) {
        @Override public Object getBean() { return Switch.this; }
        @Override public String getName() { return "selectedTextColor"; }
    };
    handlerMap            = new ConcurrentHashMap<>(2);

    disabledProperty().addListener(o -> setOpacity(isDisabled() ? 0.4 : 1.0));
}