01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.ui.client.fx;
09:
10: /**
11: * Effects transitions, to be used with all the effects.
12: *
13: * <p>
14: * Credits: Code adapted from the MooTool framework, see http://mootools.net.
15: * Easing Equations by Robert Penner, see http://www.robertpenner.com/easing.
16: * </p>
17: *
18: * @see FX
19: */
20: public interface Transition {
21:
22: /**
23: * EaseIn transtion.
24: */
25: public static class EaseIn implements Transition {
26:
27: private Transition transition;
28:
29: public EaseIn(Transition transition) {
30: this .transition = transition;
31: }
32:
33: public double compute(double value) {
34: return transition.compute(value);
35: }
36:
37: }
38:
39: /**
40: * EastOut transtion.
41: */
42: public static class EaseOut implements Transition {
43:
44: private Transition transition;
45:
46: public EaseOut(Transition transition) {
47: this .transition = transition;
48: }
49:
50: public double compute(double value) {
51: return 1 - transition.compute(1 - value);
52: }
53:
54: }
55:
56: /**
57: * Computes the adjusted value.
58: *
59: * @param value the current value
60: * @return the adjusted value
61: */
62: public double compute(double value);
63:
64: /**
65: * Displays a sineousidal transition.
66: */
67: public static Transition SINE = new Transition() {
68: public double compute(double value) {
69: return 1 - Math.sin((1 - value) * Math.PI / 2);
70: }
71: };
72:
73: /**
74: * Displays a exponential transition.
75: */
76: public static Transition EXPO = new Transition() {
77: public double compute(double value) {
78: return Math.pow(2, 8 * (value - 1));
79: }
80: };
81:
82: /**
83: * Displays a linear transition.
84: */
85: public static Transition LINEAR = new Transition() {
86:
87: public double compute(double value) {
88: return value;
89: }
90:
91: };
92:
93: }
|