Search in sources :

Example 1 with JFXDrawerKeyValue

use of com.jfoenix.transitions.JFXDrawerKeyValue in project JFoenix by jfoenixadmin.

the class JFXDrawer method addAnimatedKeyValue.

public void addAnimatedKeyValue(Node node, List<JFXDrawerKeyValue<?>> values) {
    Collection<JFXKeyValue<?>> modifiedValues = new ArrayList<>();
    for (JFXDrawerKeyValue value : values) {
        JFXKeyValue modifiedValue = JFXKeyValue.builder().setEndValueSupplier(() -> currentValue.get(value.getTarget()).get()).setAnimateCondition(() -> node.getScene() != null && value.isValid()).setTargetSupplier(() -> value.getTarget()).setInterpolator(value.getInterpolator()).build();
        modifiedValues.add(modifiedValue);
        currentValue.put(value.getTarget(), isClosed() ? value.getCloseValueSupplier() : value.getOpenValueSupplier());
        initValues.put(value.getTarget(), value);
    }
    animatedValues.addAll(modifiedValues);
    final JFXKeyFrame keyFrame = new JFXKeyFrame(duration, modifiedValues.toArray(new JFXKeyValue[0]));
    try {
        translateTimer.addKeyFrame(keyFrame);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : JFXDrawerKeyValue(com.jfoenix.transitions.JFXDrawerKeyValue) JFXKeyFrame(com.jfoenix.transitions.JFXKeyFrame) JFXKeyValue(com.jfoenix.transitions.JFXKeyValue) ArrayList(java.util.ArrayList)

Example 2 with JFXDrawerKeyValue

use of com.jfoenix.transitions.JFXDrawerKeyValue in project JFoenix by jfoenixadmin.

the class JFXDrawer method close.

/**
 * Starts the animation to transition this drawer to closed.
 */
public void close() {
    translateTimer.setOnFinished(() -> {
        overlayPane.setMouseTransparent(true);
        fireEvent(new JFXDrawerEvent(JFXDrawerEvent.CLOSED));
    });
    if (hasMiniSize()) {
        if (resizeTo != getMiniDrawerSize()) {
            resizeTo = getMiniDrawerSize();
            for (Map.Entry<WritableValue<?>, JFXDrawerKeyValue<?>> entry : initValues.entrySet()) {
                currentValue.put(entry.getKey(), entry.getValue().getCloseValueSupplier());
            }
        }
    } else {
        updateTempDrawerSize();
        if (translateTo != initTranslate.get()) {
            translateTo = initTranslate.get();
            for (Map.Entry<WritableValue<?>, JFXDrawerKeyValue<?>> entry : initValues.entrySet()) {
                currentValue.put(entry.getKey(), entry.getValue().getCloseValueSupplier());
            }
        }
    }
    getCachePolicy().cache(contentHolder);
    translateTimer.reverseAndContinue();
}
Also used : JFXDrawerKeyValue(com.jfoenix.transitions.JFXDrawerKeyValue) JFXDrawerEvent(com.jfoenix.controls.events.JFXDrawerEvent) HashMap(java.util.HashMap) Map(java.util.Map) WritableValue(javafx.beans.value.WritableValue)

Example 3 with JFXDrawerKeyValue

use of com.jfoenix.transitions.JFXDrawerKeyValue in project JFoenix by jfoenixadmin.

the class JFXDrawer method partialClose.

private void partialClose() {
    for (Map.Entry<WritableValue<?>, JFXDrawerKeyValue<?>> entry : initValues.entrySet()) {
        currentValue.put(entry.getKey(), entry.getValue().getCloseValueSupplier());
    }
    translateTo = initTranslate.get();
    resizeTo = getMiniDrawerSize();
    translateTimer.setOnFinished(() -> {
        overlayPane.setMouseTransparent(true);
        fireEvent(new JFXDrawerEvent(JFXDrawerEvent.CLOSED));
    });
    getCachePolicy().cache(contentHolder);
    translateTimer.start();
}
Also used : JFXDrawerKeyValue(com.jfoenix.transitions.JFXDrawerKeyValue) HashMap(java.util.HashMap) Map(java.util.Map) WritableValue(javafx.beans.value.WritableValue) JFXDrawerEvent(com.jfoenix.controls.events.JFXDrawerEvent)

Aggregations

JFXDrawerKeyValue (com.jfoenix.transitions.JFXDrawerKeyValue)3 JFXDrawerEvent (com.jfoenix.controls.events.JFXDrawerEvent)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 WritableValue (javafx.beans.value.WritableValue)2 JFXKeyFrame (com.jfoenix.transitions.JFXKeyFrame)1 JFXKeyValue (com.jfoenix.transitions.JFXKeyValue)1 ArrayList (java.util.ArrayList)1