1 /*
2 * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
35 * {@code Transition} based animations, such as {@link PathTransition} and
36 * {@link RotateTransition}.
37 * <p>
38 * This class offers a simple framework to define animation. It provides all the
39 * basic functionality defined in {@link Animation}. {@code Transition} requires
40 * the implementation of a method {@link #interpolate(double)} which is the
41 * called in each frame, while the {@code Transition} is running.
42 * <p>
43 * In addition an extending class needs to set the duration of a single cycle
44 * with {@link Animation#setCycleDuration(javafx.util.Duration)}. This duration
45 * is usually set by the user via a duration property (as in
46 * {@link FadeTransition#durationProperty() duration}) for example. But it can also be calculated
47 * by the extending class as is done in {@link ParallelTransition} and
48 * {@link FadeTransition}.
49 * <p>
50 * Below is a simple example. It creates a small animation that updates the
51 * {@code text} property of a {@link javafx.scene.text.Text} node. It starts
52 * with an empty {@code String} and adds gradually letter by letter until the
53 * full {@code String} was set when the animation finishes.
54 *
55 * <pre>
56 * {@code
57 *
58 * final String content = "Lorem ipsum";
59 * final Text text = new Text(10, 20, "");
60 *
61 * final Animation animation = new Transition() {
62 * {
63 * setCycleDuration(Duration.millis(2000));
64 * }
65 *
66 * protected void interpolate(double frac) {
67 * final int length = content.length();
68 * final int n = Math.round(length * (float) frac);
69 * text.setText(content.substring(0, n));
70 * }
71 *
72 * };
73 *
74 * animation.play();
75 * }</pre>
76 *
77 * @see Animation
78 *
79 * @since JavaFX 2.0
80 */
81 public abstract class Transition extends Animation {
82
83 /**
84 * Controls the timing for acceleration and deceleration at each
85 * {@code Transition} cycle.
86 * <p>
87 * This may only be changed prior to starting the transition or after the
88 * transition has ended. If the value of {@code interpolator} is changed for
89 * a running {@code Transition}, the animation has to be stopped and started again to
90 * pick up the new value.
91 * <p>
92 * Default interpolator is set to {@link Interpolator#EASE_BOTH}.
93 *
94 * @defaultValue EASE_BOTH
95 */
|
1 /*
2 * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
35 * {@code Transition} based animations, such as {@link PathTransition} and
36 * {@link RotateTransition}.
37 * <p>
38 * This class offers a simple framework to define animation. It provides all the
39 * basic functionality defined in {@link Animation}. {@code Transition} requires
40 * the implementation of a method {@link #interpolate(double)} which is the
41 * called in each frame, while the {@code Transition} is running.
42 * <p>
43 * In addition an extending class needs to set the duration of a single cycle
44 * with {@link Animation#setCycleDuration(javafx.util.Duration)}. This duration
45 * is usually set by the user via a duration property (as in
46 * {@link FadeTransition#durationProperty() duration}) for example. But it can also be calculated
47 * by the extending class as is done in {@link ParallelTransition} and
48 * {@link FadeTransition}.
49 * <p>
50 * Below is a simple example. It creates a small animation that updates the
51 * {@code text} property of a {@link javafx.scene.text.Text} node. It starts
52 * with an empty {@code String} and adds gradually letter by letter until the
53 * full {@code String} was set when the animation finishes.
54 *
55 * <pre> {@code final String content = "Lorem ipsum";
56 * final Text text = new Text(10, 20, "");
57 *
58 * final Animation animation = new Transition() {
59 * {
60 * setCycleDuration(Duration.millis(2000));
61 * }
62 *
63 * protected void interpolate(double frac) {
64 * final int length = content.length();
65 * final int n = Math.round(length * (float) frac);
66 * text.setText(content.substring(0, n));
67 * }
68 *
69 * };
70 *
71 * animation.play();}</pre>
72 *
73 * @see Animation
74 *
75 * @since JavaFX 2.0
76 */
77 public abstract class Transition extends Animation {
78
79 /**
80 * Controls the timing for acceleration and deceleration at each
81 * {@code Transition} cycle.
82 * <p>
83 * This may only be changed prior to starting the transition or after the
84 * transition has ended. If the value of {@code interpolator} is changed for
85 * a running {@code Transition}, the animation has to be stopped and started again to
86 * pick up the new value.
87 * <p>
88 * Default interpolator is set to {@link Interpolator#EASE_BOTH}.
89 *
90 * @defaultValue EASE_BOTH
91 */
|