|
Spec-Zone .ru
спецификации, руководства, описания, API
|
S - Тип StyleableV - Тип, в который преобразовывается проанализированное значение.public abstract class CssMetaData<S extends Styleable,V> extends java.lang.Object
CssMetaData является мостом между значением, которое может быть представлено синтаксически в.css файле, и a StyleableProperty. Есть взаимно-однозначное соответствие между CssMetaData и StyleableProperty. Как правило, CssMetaData желания включают CssMetaData его предков. Во время обработки CSS механизм CSS выполняет итерации по CssMetaData Узла, ищет проанализированное значение каждого, преобразовывает проанализированное значение, и устанавливает значение на StyleableProperty.
Метод Node.getCssMetaData() вызывается, чтобы получить Список <CssMetaData>. Этот метод часто вызывают, и благоразумно возвратить статический список вместо того, чтобы создать список на каждом вызове. Условно, классы узла, у которых есть CssMetaData, реализуют статический метод getClassCssMetaData() и это общепринято, чтобы иметь getCssMetaData() просто возвратитесь getClassCssMetaData(). Цель getClassCssMetaData() должен позволить подклассам легко включать CssMetaData некоторого предка.
Этим примером является типичная реализация.
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.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. Use is subject to .