Created
January 18, 2013 23:21
-
-
Save TabsPH/4569535 to your computer and use it in GitHub Desktop.
JavaFX 2.2 Animator class
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
import javafx.animation.*; | |
import javafx.scene.*; | |
import javafx.util.*; | |
public class Animator { | |
protected void doInSequential(Animation... an) { | |
SequentialTransition st = SequentialTransitionBuilder.create() | |
.children(an) | |
.cycleCount(1) | |
.build(); | |
st.play(); | |
} | |
protected void doInParallel(Animation... an) { | |
ParallelTransition pt = ParallelTransitionBuilder.create() | |
.children(an) | |
.cycleCount(1) | |
.build(); | |
pt.play(); | |
} | |
protected ParallelTransition getParallelAnimation(Animation... an) { | |
ParallelTransition pt = ParallelTransitionBuilder.create() | |
.children(an) | |
.cycleCount(1) | |
.build(); | |
return pt; | |
} | |
protected SequentialTransition getSequentialAnimation(Animation... an) { | |
SequentialTransition st = SequentialTransitionBuilder.create() | |
.children(an) | |
.cycleCount(1) | |
.build(); | |
return st; | |
} | |
protected TranslateTransition doTranslate(Node node, double frmVal, double toVal, double dur) { | |
TranslateTransition tt = TranslateTransitionBuilder.create() | |
.node(node) | |
.duration(Duration.seconds(dur)) | |
.fromX(frmVal) | |
.toX(toVal) | |
.build(); | |
return tt; | |
} | |
protected FadeTransition doFade(Node node, double fromVal, double toVal, double dur) { | |
FadeTransition ft = FadeTransitionBuilder.create() | |
.duration(Duration.seconds(dur)) | |
.node(node) | |
.fromValue(fromVal) | |
.toValue(toVal) | |
.build(); | |
return ft; | |
} | |
protected ScaleTransition doScale(Node node, double fromX, double fromY, double toX, double toY, double dur) { | |
ScaleTransition scale = ScaleTransitionBuilder.create() | |
.node(node) | |
.duration(Duration.seconds(dur)) | |
.fromX(fromX) | |
.fromY(fromY) | |
.toX(toX) | |
.toY(toY) | |
.build(); | |
return scale; | |
} | |
protected RotateTransition doRotate(Node node, double angle, double dur) { | |
RotateTransition rt = RotateTransitionBuilder.create() | |
.duration(Duration.seconds(dur)) | |
.node(node) | |
.byAngle(angle) | |
.build(); | |
return rt; | |
} | |
protected PauseTransition doPause(double dur) { | |
PauseTransition p = PauseTransitionBuilder.create() | |
.duration(Duration.seconds(dur)) | |
.build(); | |
return p; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment