forked from eclipse-efx/efxclipse-rt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...e.fx.ui.animation/src/main/java/org/eclipse/fx/ui/animation/DoublePropertyTransition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 BestSolution.at and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Tom Schindl<[email protected]> - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.fx.ui.animation; | ||
|
||
import javafx.animation.Transition; | ||
import javafx.beans.property.DoubleProperty; | ||
import javafx.util.Duration; | ||
|
||
/** | ||
* Transition updating a double property | ||
*/ | ||
public class DoublePropertyTransition extends Transition { | ||
private final DoubleProperty p; | ||
private double from; | ||
private double delta; | ||
|
||
/** | ||
* Create a new transition | ||
* | ||
* @param p | ||
* the double property to update | ||
* @param duration | ||
* the duration | ||
* @param from | ||
* the start value | ||
* @param to | ||
* the end value | ||
*/ | ||
public DoublePropertyTransition(DoubleProperty p, Duration duration, double from, double to) { | ||
this.p = p; | ||
setCycleDuration(duration); | ||
this.delta = to - from; | ||
} | ||
|
||
@Override | ||
protected void interpolate(double frac) { | ||
this.p.set(this.from + this.delta * frac); | ||
} | ||
|
||
} |