Java 类javafx.beans.value.WritableValue 实例源码

项目:GestureFX    文件:GesturePane.java   
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();
}
项目:fx-player    文件:MediaInfo.java   
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;
}
项目:HotaruFX    文件:ObjectNode.java   
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;
    };
}
项目:Gargoyle    文件:PropertyChangeExam.java   
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());
                    }

                    // }
                }
            }

        }
    }

}
项目:HotaruFX    文件:PropertyTimelineHolder.java   
public PropertyTimeline<T> setIfEmptyThenGet(Supplier<WritableValue<T>> supplier) {
    return setIfEmpty(wrap(supplier)).get();
}
项目:HotaruFX    文件:PropertyTimelineHolder.java   
private Supplier<PropertyTimeline<T>> wrap(Supplier<WritableValue<T>> supplier) {
    return () -> new PropertyTimeline<>(supplier.get());
}
项目:HotaruFX    文件:PropertyTimeline.java   
public PropertyTimeline(WritableValue<T> property) {
    this.property = property;
    keyFrames = new TreeMap<>();
}
项目:GameAuthoringEnvironment    文件:AbstractPropertyConverter.java   
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;
}
项目:GameAuthoringEnvironment    文件:BooleanPropertyConverter.java   
@Override
protected WritableValue<Boolean> createProperty() {
    return new SimpleBooleanProperty();
}
项目:GameAuthoringEnvironment    文件:StringPropertyConverter.java   
@Override
protected WritableValue<String> createProperty() {
    return new SimpleStringProperty();
}
项目:GameAuthoringEnvironment    文件:LongPropertyConverter.java   
@Override
protected WritableValue<Number> createProperty() {
    return new SimpleLongProperty();
}
项目:GameAuthoringEnvironment    文件:IntegerPropertyConverter.java   
@Override
protected WritableValue<Number> createProperty() {
    return new SimpleIntegerProperty();
}
项目:GameAuthoringEnvironment    文件:ObjectPropertyConverter.java   
@Override
protected WritableValue<Object> createProperty() {
    return new SimpleObjectProperty();
}
项目:GameAuthoringEnvironment    文件:DoublePropertyConverter.java   
@Override
protected WritableValue<Number> createProperty() {
    return new SimpleDoubleProperty();
}
项目:Gargoyle    文件:PropertyChangeExam.java   
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();
    }

}
项目:Gargoyle    文件:CPagenationSkin.java   
@Override
public StyleableProperty<Boolean> getStyleableProperty(Pagination n) {
    final CPagenationSkin skin = (CPagenationSkin) n.getSkin();
    return (StyleableProperty<Boolean>) (WritableValue<Boolean>) skin.arrowsVisibleProperty();
}
项目:Gargoyle    文件:CPagenationSkin.java   
@Override
public StyleableProperty<Boolean> getStyleableProperty(Pagination n) {
    final CPagenationSkin skin = (CPagenationSkin) n.getSkin();
    return (StyleableProperty<Boolean>) (WritableValue<Boolean>) skin.pageInformationVisibleProperty();
}
项目:Gargoyle    文件:CPagenationSkin.java   
@Override
public StyleableProperty<Side> getStyleableProperty(Pagination n) {
    final CPagenationSkin skin = (CPagenationSkin) n.getSkin();
    return (StyleableProperty<Side>) (WritableValue<Side>) skin.pageInformationAlignmentProperty();
}
项目:Gargoyle    文件:CPagenationSkin.java   
@Override
public StyleableProperty<Boolean> getStyleableProperty(Pagination n) {
    final CPagenationSkin skin = (CPagenationSkin) n.getSkin();
    return (StyleableProperty<Boolean>) (WritableValue<Boolean>) skin.tooltipVisibleProperty();
}
项目:Gargoyle    文件:CPagenationSkin.java   
@Override
public StyleableProperty<Number> getStyleableProperty(Pagination n) {
    final CPagenationSkin skin = (CPagenationSkin) n.getSkin();
    return (StyleableProperty<Number>) (WritableValue<Number>) skin.arrowButtonGapProperty();
}
项目:tornadofx-controls    文件:DirtyState.java   
public void undo() {
    initialValues.forEach(WritableValue::setValue);
    setValue(false);
}
项目:minecraft-jfx-skin    文件:SkinTransition.java   
public SkinTransition(Duration duration, Function<Double, Double> expression, WritableValue<Number>... observables) {
    setCycleDuration(duration);
    this.expression = expression;
    this.observables = Arrays.asList(observables);
}
项目:j.commons    文件:RadialMenuItem.java   
@SuppressWarnings("RedundantCast")
@Override
public StyleableProperty<Number> getStyleableProperty(RadialMenuItem rmi) {
    return (StyleableProperty<Number>) (WritableValue<Number>) rmi.sizeProperty();
}
项目:FPT-1516    文件:AbstractPropertyValueHandler.java   
public Object toDataStoreValue(ValueMapping vm, Object val, JDBCStore store) {
    if (val instanceof String) {
        return val;
    }
    return (val == null) ? null : ((WritableValue<?>) val).getValue();
}
项目:FPT-1516    文件:AbstractPropertyValueHandler.java   
public Object toDataStoreValue(ValueMapping vm, Object val, JDBCStore store) {
    if (val instanceof String) {
        return val;
    }
    return (val == null) ? null : ((WritableValue<?>) val).getValue();
}
项目:FPT-1516    文件:AbstractPropertyValueHandler.java   
public Object toDataStoreValue(ValueMapping vm, Object val, JDBCStore store) {
    if (val instanceof String) {
        return val;
    }
    return (val == null) ? null : ((WritableValue<?>) val).getValue();
}
项目:JFoenix    文件:JFXKeyValue.java   
public WritableValue<?> getTarget() {
    return target == null ? targetSupplier.get() : target;
}
项目:JFoenix    文件:JFXKeyValue.java   
public JFXKeyValueBuilder setTarget(WritableValue<?> target) {
    this.target = target;
    return this;
}
项目:JFoenix    文件:JFXKeyValue.java   
public JFXKeyValueBuilder setTargetSupplier(Supplier<WritableValue<?>> targetSupplier) {
    this.targetSupplier = targetSupplier;
    return this;
}
项目:dolphin-platform    文件:DefaultJavaFXBinder.java   
public DefaultJavaFXBinder(final WritableValue<S> javaFxValue) {
    this.javaFxValue = Assert.requireNonNull(javaFxValue, "javaFxValue");
}
项目:epubfx    文件:EditingTreeCellSkin.java   
@Override public StyleableProperty<Number> getStyleableProperty(TreeCell<?> n) {
    final EditingTreeCellSkin<?> skin = (EditingTreeCellSkin<?>) n.getSkin();
    return (StyleableProperty<Number>)(WritableValue<Number>)skin.indentProperty();
}
项目:FX3DAndroid    文件:Optimizer.java   
private void cleanUpRepeatingFramesAndValues() {
        ObservableList<KeyFrame> timelineKeyFrames = timeline.getKeyFrames().sorted(new KeyFrameComparator());
//        Timeline timeline;
        int kfTotal = timelineKeyFrames.size(), kfRemoved = 0;
        int kvTotal = 0, kvRemoved = 0;
        Map<Duration, KeyFrame> kfUnique = new HashMap<>();
        Map<WritableValue, KeyValue> kvUnique = new HashMap<>();
        MapOfLists<KeyFrame, KeyFrame> duplicates = new MapOfLists<>();
        Iterator<KeyFrame> iterator = timelineKeyFrames.iterator();
        while (iterator.hasNext()) {
            KeyFrame duplicate = iterator.next();
            KeyFrame original = kfUnique.put(duplicate.getTime(), duplicate);
            if (original != null) {
                kfRemoved++;
                iterator.remove(); // removing duplicate keyFrame
                duplicates.add(original, duplicate);

                kfUnique.put(duplicate.getTime(), original);
            }
            kvUnique.clear();
            for (KeyValue kvDup : duplicate.getValues()) {
                kvTotal++;
                KeyValue kvOrig = kvUnique.put(kvDup.getTarget(), kvDup);
                if (kvOrig != null) {
                    kvRemoved++;
                    if (!kvOrig.getEndValue().equals(kvDup.getEndValue()) && kvOrig.getTarget() == kvDup.getTarget()) {
                        System.err.println("KeyValues set different values for KeyFrame " + duplicate.getTime() + ":"
                                + "\n kvOrig = " + kvOrig + ", \nkvDup = " + kvDup);
                    }
                }
            }
        }
        for (KeyFrame orig : duplicates.keySet()) {
            List<KeyValue> keyValues = new ArrayList<>();
            for (KeyFrame dup : duplicates.get(orig)) {
                keyValues.addAll(dup.getValues());
            }
            timelineKeyFrames.set(timelineKeyFrames.indexOf(orig),
                    new KeyFrame(orig.getTime(), keyValues.toArray(new KeyValue[keyValues.size()])));
        }
        System.out.printf("Removed %d (%.2f%%) duplicate KeyFrames out of total %d.\n",
                kfRemoved, 100d * kfRemoved / kfTotal, kfTotal);
        System.out.printf("Identified %d (%.2f%%) duplicate KeyValues out of total %d.\n",
                kvRemoved, 100d * kvRemoved / kvTotal, kvTotal);
    }
项目:candy    文件:CategoryDateAxis.java   
@Override
public WritableValue<Number> getWritableValue(CategoryDateAxis n) {
    return n.startMarginProperty();
}
项目:candy    文件:CategoryDateAxis.java   
@Override
public WritableValue<Number> getWritableValue(CategoryDateAxis n) {
    return n.endMarginProperty();
}
项目:candy    文件:CategoryDateAxis.java   
@Override
public WritableValue<Boolean> getWritableValue(CategoryDateAxis n) {
    return n.gapStartAndEndProperty();
}
项目:Cryogen    文件:EasyAnimation.java   
public void push(WritableValue p, long time, Object value) {
    KeyValue kv = new KeyValue(p, value);
    KeyFrame kf = new KeyFrame(Duration.millis(time), kv);
    timeline.getKeyFrames().add(kf);
}
项目:obdq    文件:DoubleSlider.java   
@Override
public WritableValue<Number> getWritableValue(DoubleSlider n) {
    return n.blockIncrementProperty();
}
项目:obdq    文件:DoubleSlider.java   
@Override
public WritableValue<Boolean> getWritableValue(DoubleSlider n) {
    return n.showTickLabelsProperty();
}
项目:obdq    文件:DoubleSlider.java   
@Override
public WritableValue<Boolean> getWritableValue(DoubleSlider n) {
    return n.showTickMarksProperty();
}
项目:obdq    文件:DoubleSlider.java   
@Override
public WritableValue<Boolean> getWritableValue(DoubleSlider n) {
    return n.snapToTicksProperty();
}