Skip to content

Instantly share code, notes, and snippets.

@shemnon
Created September 13, 2012 03:49
Show Gist options
  • Save shemnon/3711714 to your computer and use it in GitHub Desktop.
Save shemnon/3711714 to your computer and use it in GitHub Desktop.
JavaFX CSS Styling Plumbing
public final void setBackScale(double value) {
backScaleProperty().set(value);
}
public final double getBackScale() {
return backScale == null ? 0.7 : backScale.get();
}
public final DoubleProperty backScaleProperty() {
if (backScale == null) {
backScale = new StyleableDoubleProperty(0.7) {
@Override
protected void invalidated() {
styleablePropertyInvalidated();
}
@Override
public StyleableProperty getStyleableProperty() {
return BACK_SCALE;
}
@Override
public Object getBean() {
return ShelfDeckSkin.this;
}
@Override
public String getName() {
return "backScale";
}
};
}
return backScale;
}
private static final StyleableProperty<ShelfDeckSkin,Number> BACK_SCALE =
new StyleableProperty<ShelfDeckSkin,Number>("-x-back-scale",
SizeConverter.getInstance(), 0.7) {
@Override
public boolean isSettable(ShelfDeckSkin deck) {
return deck.backScale == null || !deck.backScale.isBound();
}
@Override
public WritableValue<Number> getWritableValue(ShelfDeckSkin deck) {
return deck.backScaleProperty();
}
};
private static List<StyleableProperty> STYLEABLES;
@Override
@Deprecated
public List<StyleableProperty> impl_getStyleableProperties() {
if (STYLEABLES == null) {
final List<StyleableProperty> styleables = new ArrayList<StyleableProperty>(super.impl_getStyleableProperties());
Collections.addAll(styleables,
BACK_ANGLE,
BACK_OFFSET,
BACK_SCALE,
BACK_SPACING);
STYLEABLES = Collections.unmodifiableList(styleables);
}
return STYLEABLES; //To change body of overridden methods use File | Settings | File Templates.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment