本文整理汇总了Java中javafx.beans.value.WritableValue类的典型用法代码示例。如果您正苦于以下问题:Java WritableValue类的具体用法?Java WritableValue怎么用?Java WritableValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WritableValue类属于javafx.beans.value包,在下文中一共展示了WritableValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: animateValue
import javafx.beans.value.WritableValue; //导入依赖的package包/类
private void animateValue(double from,
double to,
Duration duration,
Interpolator interpolator, DoubleConsumer consumer,
EventHandler<ActionEvent> l) {
timeline.stop();
timeline.getKeyFrames().clear();
KeyValue keyValue = new KeyValue(new WritableValue<Double>() {
@Override
public Double getValue() {
return from;
}
@Override
public void setValue(Double value) {
consumer.accept(value);
}
}, to, interpolator == null ? Interpolator.LINEAR : interpolator);
timeline.getKeyFrames().add(new KeyFrame(duration, keyValue));
timeline.setOnFinished(l);
timeline.play();
}
示例2: setIfUpdate
import javafx.beans.value.WritableValue; //导入依赖的package包/类
private static <T> T setIfUpdate(ObservableMap<? extends String, ? extends Object> map,
String key, WritableValue<T>... props) {
T newValue = (T) map.get(key);
if (newValue != null) {
boolean stringEmpty = false;
if (newValue instanceof String) {
String newStr = (String) newValue;
stringEmpty = newStr.isEmpty();
}
for (WritableValue<T> prop : props) {
if (stringEmpty) {
if (prop.getValue() == null) {
prop.setValue(newValue);
}
} else {
prop.setValue(newValue);
}
}
}
return newValue;
}
示例3: enumToString
import javafx.beans.value.WritableValue; //导入依赖的package包/类
protected <T extends Enum<T>> Supplier<WritableValue<String>> enumToString(Class<T> enumClass, ObjectProperty<T> property) {
return () -> {
val stringProperty = new SimpleStringProperty();
stringProperty.bindBidirectional(property, new StringConverter<T>() {
@Override
public String toString(T object) {
if (object == null) {
return "null";
}
return object.name();
}
@Override
public T fromString(String string) {
if ("null".equals(string)) {
return null;
}
try {
return Enum.valueOf(enumClass, string);
} catch (IllegalArgumentException e) {
try {
val number = (int) Double.parseDouble(string);
return enumClass.cast(EnumSet.allOf(enumClass).toArray()[number]);
} catch (Exception ex) {
throw new HotaruRuntimeException("No constant " + string
+ " for type " + enumClass.getSimpleName());
}
}
}
});
return stringProperty;
};
}
示例4: propertyCopy
import javafx.beans.value.WritableValue; //导入依赖的package包/类
public void propertyCopy(Node from, Node to) throws Exception {
Method[] fromMethods = from.getClass().getMethods();
Class<? extends Node> class1 = to.getClass();
for (Method fromMethod : fromMethods) {
String methodName = fromMethod.getName();
if (methodName.endsWith("Property")) {
Method targetMethod = class1.getMethod(methodName);
targetMethod.setAccessible(true);
if (targetMethod != null) {
Object fromPropertValue = fromMethod.invoke(from);
Object toPropertValue = targetMethod.invoke(from);
if (Property.class.isAssignableFrom(fromPropertValue.getClass())) {
if (WritableValue.class.isAssignableFrom(fromPropertValue.getClass())) {
// System.out.println("Writable : " +
// fromPropertValue);
// if
// (StyleConverter.class.isAssignableFrom(fromPropertValue.getClass()))
// {
Property fromProp = (Property) fromPropertValue;
Property toProp = (Property) toPropertValue;
Object value = fromProp.getValue();
if (value == null)
continue;
System.out.println("set value : " + fromProp.getValue());
toProp.setValue(fromProp.getValue());
}
// }
}
}
}
}
}
示例5: setIfEmptyThenGet
import javafx.beans.value.WritableValue; //导入依赖的package包/类
public PropertyTimeline<T> setIfEmptyThenGet(Supplier<WritableValue<T>> supplier) {
return setIfEmpty(wrap(supplier)).get();
}
示例6: wrap
import javafx.beans.value.WritableValue; //导入依赖的package包/类
private Supplier<PropertyTimeline<T>> wrap(Supplier<WritableValue<T>> supplier) {
return () -> new PropertyTimeline<>(supplier.get());
}
示例7: PropertyTimeline
import javafx.beans.value.WritableValue; //导入依赖的package包/类
public PropertyTimeline(WritableValue<T> property) {
this.property = property;
keyFrames = new TreeMap<>();
}
示例8: unmarshal
import javafx.beans.value.WritableValue; //导入依赖的package包/类
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
WritableValue<T> property = createProperty();
final T value = (T) context.convertAnother(null, readType(reader));
property.setValue(value);
return property;
}
示例9: createProperty
import javafx.beans.value.WritableValue; //导入依赖的package包/类
@Override
protected WritableValue<Boolean> createProperty() {
return new SimpleBooleanProperty();
}
示例10: createProperty
import javafx.beans.value.WritableValue; //导入依赖的package包/类
@Override
protected WritableValue<String> createProperty() {
return new SimpleStringProperty();
}
示例11: createProperty
import javafx.beans.value.WritableValue; //导入依赖的package包/类
@Override
protected WritableValue<Number> createProperty() {
return new SimpleLongProperty();
}
示例12: createProperty
import javafx.beans.value.WritableValue; //导入依赖的package包/类
@Override
protected WritableValue<Number> createProperty() {
return new SimpleIntegerProperty();
}
示例13: createProperty
import javafx.beans.value.WritableValue; //导入依赖的package包/类
@Override
protected WritableValue<Object> createProperty() {
return new SimpleObjectProperty();
}
示例14: createProperty
import javafx.beans.value.WritableValue; //导入依赖的package包/类
@Override
protected WritableValue<Number> createProperty() {
return new SimpleDoubleProperty();
}
示例15: setProperty
import javafx.beans.value.WritableValue; //导入依赖的package包/类
public void setProperty(Node node, String name, Object value) {
try {
if (value == null)
return;
Method method = node.getClass().getMethod(name + "Property");
if (method == null)
return;
method.setAccessible(true);
Object fromPropertValue = method.invoke(node);
if (Property.class.isAssignableFrom(fromPropertValue.getClass())) {
if (WritableValue.class.isAssignableFrom(fromPropertValue.getClass())) {
Method setMethod = null;
if (fromPropertValue instanceof BooleanProperty || fromPropertValue instanceof DoubleProperty) {
setMethod = fromPropertValue.getClass().getMethod("setValue", Object.class);
} else {
setMethod = fromPropertValue.getClass().getMethod("set", Object.class);
}
if (setMethod != null) {
setMethod.setAccessible(true);
if (value.getClass().isPrimitive()) {
setMethod.invoke(fromPropertValue, value.getClass());
} else {
setMethod.invoke(fromPropertValue, value);
}
}
}
else
{
}
}
else
{
System.out.println(fromPropertValue);
}
} catch (Exception e) {
System.out.println("error prop name : " + name + " value : " + value + " value type : " + value.getClass());
// e.printStackTrace();
}
}