com.jfoenix.transitions.JFXDrawerKeyValue Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.jfoenix.transitions;
import javafx.animation.Interpolator;
import javafx.beans.value.WritableValue;
import java.util.function.Supplier;
/**
* Wrapper for JFXDrawer animation key value
*
* @author Shadi Shaheen
* @version 1.0
* @since 2018-05-03
*/
public class JFXDrawerKeyValue {
private WritableValue target;
private Supplier closeValueSupplier;
private Supplier openValueSupplier;
private Interpolator interpolator;
private Supplier animateCondition = () -> true;
public WritableValue getTarget() {
return target;
}
public Supplier getCloseValueSupplier() {
return closeValueSupplier;
}
public Supplier getOpenValueSupplier() {
return openValueSupplier;
}
public Interpolator getInterpolator() {
return interpolator;
}
public boolean isValid() {
return animateCondition == null ? true : animateCondition.get();
}
public static JFXDrawerKeyValueBuilder builder() {
return new JFXDrawerKeyValueBuilder();
}
public void applyOpenValues() {
target.setValue(getOpenValueSupplier().get());
}
public void applyCloseValues(){
target.setValue(getCloseValueSupplier().get());
}
public static final class JFXDrawerKeyValueBuilder {
private WritableValue target;
private Interpolator interpolator = Interpolator.EASE_BOTH;
private Supplier animateCondition = () -> true;
private Supplier closeValueSupplier;
private Supplier openValueSupplier;
private JFXDrawerKeyValueBuilder() {
}
public static JFXDrawerKeyValueBuilder aJFXDrawerKeyValue() {
return new JFXDrawerKeyValueBuilder();
}
public JFXDrawerKeyValueBuilder setTarget(WritableValue target) {
this.target = target;
return this;
}
public JFXDrawerKeyValueBuilder setInterpolator(Interpolator interpolator) {
this.interpolator = interpolator;
return this;
}
public JFXDrawerKeyValueBuilder setAnimateCondition(Supplier animateCondition) {
this.animateCondition = animateCondition;
return this;
}
public JFXDrawerKeyValueBuilder setCloseValue(T closeValue) {
this.closeValueSupplier = () -> closeValue;
return this;
}
public JFXDrawerKeyValueBuilder setCloseValueSupplier(Supplier closeValueSupplier) {
this.closeValueSupplier = closeValueSupplier;
return this;
}
public JFXDrawerKeyValueBuilder setOpenValueSupplier(Supplier openValueSupplier) {
this.openValueSupplier = openValueSupplier;
return this;
}
public JFXDrawerKeyValueBuilder setOpenValue(T openValue) {
this.openValueSupplier = () -> openValue;
return this;
}
public JFXDrawerKeyValue build() {
JFXDrawerKeyValue jFXDrawerKeyValue = new JFXDrawerKeyValue();
jFXDrawerKeyValue.openValueSupplier = this.openValueSupplier;
jFXDrawerKeyValue.closeValueSupplier = this.closeValueSupplier;
jFXDrawerKeyValue.target = this.target;
jFXDrawerKeyValue.interpolator = this.interpolator;
jFXDrawerKeyValue.animateCondition = this.animateCondition;
return jFXDrawerKeyValue;
}
}
}