Spec-Zone .ru
спецификации, руководства, описания, API
|
S
- The type of StyleableV
- The type into which the parsed value is converted.public abstract class CssMetaData<S extends Styleable,V> extends java.lang.Object
CssMetaData is the bridge between a value that can be represented
syntactically in a .css file, and a StyleableProperty
. There is
a one-to-one correspondence between a CssMetaData and a StyleableProperty.
Typically, the CssMetaData of a will include the CssMetaData of its ancestors.
During CSS processing, the CSS engine iterates over the Node's CssMetaData,
looks up the parsed value of each, converts the parsed value, and
sets the value on the StyleableProperty.
The method Node.getCssMetaData()
is called to obtain the
List<CssMetaData>. This method is called frequently and it is prudent
to return a static list rather than creating the list on each call. By
convention, node classes that have CssMetaData will implement a
static method getClassCssMetaData()
and it is customary to have
getCssMetaData()
simply return getClassCssMetaData()
. The
purpose of getClassCssMetaData()
is to allow sub-classes to easily
include the CssMetaData of some ancestor.
This example is a typical implementation.
private DoubleProperty gapProperty = new StyleableDoubleProperty(0) {
@Override
public CssMetaData <MyWidget,Number > getCssMetaData() {
return GAP_META_DATA;
}
@Override
public Object getBean() {
return MyWidget.this;
}
@Override
public String getName() {
return "gap";
}
};
private static final CssMetaData GAP_META_DATA =
new CssMetaData <MyWidget,Number >("-my-gap", StyleConverter.getSizeConverter(), 0d) {
@Override
public boolean isSettable(MyWidget node) {
return node.gapProperty == null || !node.gapProperty.isBound();
}
@Override
public StyleableProperty <Number > getStyleableProperty(MyWidget node) {
return (StyleableProperty <Number >)node.gapProperty;
}
};
private static final List <CssMetaData <? extends Node, ? > > cssMetaDataList;
static {
List <CssMetaData <? extends Node, ? > > temp =
new ArrayList <CssMetaData <? extends Node, ? > >(Control.getClassCssMetaData());
temp.add(GAP_META_DATA);
cssMetaDataList = Collections.unmodifiableList(temp);
}
public static List <CssMetaData <? extends Node, ? > > getClassCssMetaData() {
return cssMetaDataList;
}
@Override
public List <CssMetaData <? extends Node, ? > > getCssMetaData() {
return getClassCssMetaData();
}
Modifier | Constructor and Description |
---|---|
protected |
CssMetaData(java.lang.String property,
StyleConverter<?,V> converter)
Construct a CssMetaData with the given parameters, initialValue is
null, inherit is set to false, and no sub-properties.
|
protected |
CssMetaData(java.lang.String property,
StyleConverter<?,V> converter,
V initialValue)
Construct a CssMetaData with the given parameters, inherit set to
false and no sub-properties.
|
protected |
CssMetaData(java.lang.String property,
StyleConverter<?,V> converter,
V initialValue,
boolean inherits)
Construct a CssMetaData with the given parameters and no sub-properties.
|
protected |
CssMetaData(java.lang.String property,
StyleConverter<?,V> converter,
V initialValue,
boolean inherits,
java.util.List<CssMetaData<? extends Styleable,?>> subProperties)
Construct a CssMetaData with the given parameters and no sub-properties.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
StyleConverter<?,V> |
getConverter() |
V |
getInitialValue(S styleable)
The initial value of a CssMetaData corresponds to the default
value of the StyleableProperty in code.
|
java.lang.String |
getProperty() |
abstract StyleableProperty<V> |
getStyleableProperty(S styleable)
Return the corresponding
StyleableProperty for the given Node. |
java.util.List<CssMetaData<? extends Styleable,?>> |
getSubProperties()
The sub-properties refers to the constituent properties of this property,
if any.
|
int |
hashCode() |
boolean |
isInherits()
If true, the value of this property is the same as
the parent's computed value of this property.
|
abstract boolean |
isSettable(S styleable)
Check to see if the corresponding property on the given Node is
settable.
|
void |
set(S styleable,
V value,
StyleOrigin origin)
Deprecated.
This method is no longer called from CSS code.
Use
StyleableProperty.applyStyle(javafx.css.StyleOrigin, java.lang.Object) |
java.lang.String |
toString() |
protected CssMetaData(java.lang.String property, StyleConverter<?,V> converter, V initialValue, boolean inherits, java.util.List<CssMetaData<? extends Styleable,?>> subProperties)
property
- the CSS propertyconverter
- the StyleConverter used to convert the CSS parsed value to a Java object.initalValue
- the CSS stringinherits
- true if this property uses CSS inheritancesubProperties
- the sub-properties of this property. For example,
the -fx-font property has the sub-properties -fx-font-family,
-fx-font-size, -fx-font-weight, and -fx-font-style.protected CssMetaData(java.lang.String property, StyleConverter<?,V> converter, V initialValue, boolean inherits)
property
- the CSS propertyconverter
- the StyleConverter used to convert the CSS parsed value to a Java object.initalValue
- the CSS stringinherits
- true if this property uses CSS inheritanceprotected CssMetaData(java.lang.String property, StyleConverter<?,V> converter, V initialValue)
property
- the CSS propertyconverter
- the StyleConverter used to convert the CSS parsed value to a Java object.initalValue
- the CSS stringprotected CssMetaData(java.lang.String property, StyleConverter<?,V> converter)
property
- the CSS propertyconverter
- the StyleConverter used to convert the CSS parsed value to a Java object.initalValue
- the CSS string@Deprecated public void set(S styleable, V value, StyleOrigin origin)
StyleableProperty.applyStyle(javafx.css.StyleOrigin, java.lang.Object)
styleable
- The Styleable on which the property value is being setvalue
- The value to which the property is setpublic abstract boolean isSettable(S styleable)
styleable
- The Styleable on which the property value is being setpublic abstract StyleableProperty<V> getStyleableProperty(S styleable)
StyleableProperty
for the given Node.
Note that calling this method will cause the property to be expanded.styleable
- The Styleable for which the property is returnedpublic final java.lang.String getProperty()
public final StyleConverter<?,V> getConverter()
public V getInitialValue(S styleable)
There may be exceptions to this, however. The initialValue may depend on the state of the Node. A ScrollBar has a default orientation of horizontal. If the ScrollBar is vertical, however, this method should return Orientation.VERTICAL. Otherwise, a vertical ScrollBar would be incorrectly set to a horizontal ScrollBar when the initial value is applied.
public final java.util.List<CssMetaData<? extends Styleable,?>> getSubProperties()
public final boolean isInherits()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. Use is subject to