Source Code Cross Referenced for Effect.java in  » Web-Framework » ThinWire » thinwire » ui » style » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » ThinWire » thinwire.ui.style 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        #IFNDEF ALT_LICENSE
003:                                   ThinWire(R) RIA Ajax Framework
004:                         Copyright (C) 2003-2007 Custom Credit Systems
005:
006:          This library is free software; you can redistribute it and/or modify it under
007:          the terms of the GNU Lesser General Public License as published by the Free
008:          Software Foundation; either version 2.1 of the License, or (at your option) any
009:          later version.
010:
011:          This library is distributed in the hope that it will be useful, but WITHOUT ANY
012:          WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
013:          PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
014:
015:          You should have received a copy of the GNU Lesser General Public License along
016:          with this library; if not, write to the Free Software Foundation, Inc., 59
017:          Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:
019:          Users who would rather have a commercial license, warranty or support should
020:          contact the following company who invented, built and supports the technology:
021:          
022:                        Custom Credit Systems, Richardson, TX 75081, USA.
023:                        email: info@thinwire.com    ph: +1 (888) 644-6405
024:                                    http://www.thinwire.com
025:        #ENDIF
026:         [ v1.2_RC2 ] 
027:         */
028:        package thinwire.ui.style;
029:
030:        import java.util.ArrayList;
031:        import java.util.List;
032:
033:        public final class Effect {
034:            public static abstract class Transition {
035:                private static List<Transition> VALUES = new ArrayList<Transition>();
036:
037:                public static final Transition LINEAR = new Transition(true) {
038:                    public double apply(double position) {
039:                        return position;
040:                    }
041:
042:                    public String toString() {
043:                        return "LINEAR";
044:                    }
045:                };
046:
047:                public static final Transition SMOOTH = new Transition(true) {
048:                    public double apply(double position) {
049:                        return (-Math.cos(position * Math.PI) / 2) + 0.5;
050:                    }
051:
052:                    public String toString() {
053:                        return "SMOOTH";
054:                    }
055:                };
056:
057:                public static final Transition WOBBLE = new Transition(true) {
058:                    public double apply(double position) {
059:                        return (-Math.cos(position * Math.PI * (9 * position)) / 2) + 0.5;
060:                    }
061:
062:                    public String toString() {
063:                        return "WOBBLE";
064:                    }
065:                };
066:
067:                public static final Transition FLICKER = new Transition(true) {
068:                    public double apply(double position) {
069:                        return ((-Math.cos(position * Math.PI) / 4) + 0.75)
070:                                + Math.random();
071:                    }
072:
073:                    public String toString() {
074:                        return "FLICKER";
075:                    }
076:                };
077:
078:                public static final Transition PULSE = new Transition(true) {
079:                    public double apply(double position) {
080:                        return Math.floor(position * 10) % 2 == 0 ? (position * 10 - Math
081:                                .floor(position * 10))
082:                                : 1 - (position * 10 - Math
083:                                        .floor(position * 10));
084:                    }
085:
086:                    public String toString() {
087:                        return "PULSE";
088:                    }
089:                };
090:
091:                public static final Transition valueOf(String value) {
092:                    value = value.toUpperCase();
093:
094:                    for (Transition t : VALUES) {
095:                        if (t.toString().equals(value))
096:                            return t;
097:                    }
098:
099:                    throw new IllegalArgumentException("the specified value '"
100:                            + value + "' does not identify a known transition");
101:                }
102:
103:                protected Transition() {
104:                }
105:
106:                private Transition(boolean addToList) {
107:                    VALUES.add(this );
108:                }
109:
110:                public abstract double apply(double position);
111:            }
112:
113:            public static final class Motion {
114:                private static final List<Motion> VALUES = new ArrayList<Motion>();
115:
116:                public static final Motion NONE = new Motion(0, 1,
117:                        Transition.LINEAR, "NONE");
118:                public static final Motion SLOW_LINEAR = new Motion(2000, 25,
119:                        Transition.LINEAR, "SLOW_LINEAR");
120:                public static final Motion SLOW_SMOOTH = new Motion(2000, 25,
121:                        Transition.SMOOTH, "SLOW_SMOOTH");
122:                public static final Motion SLOW_WOBBLE = new Motion(2000, 25,
123:                        Transition.WOBBLE, "SLOW_WOBBLE");
124:                public static final Motion SLOW_FLICKER = new Motion(2000, 25,
125:                        Transition.FLICKER, "SLOW_FLICKER");
126:                public static final Motion SLOW_PULSE = new Motion(2000, 25,
127:                        Transition.PULSE, "SLOW_PULSE");
128:                public static final Motion LINEAR = new Motion(1000, 25,
129:                        Transition.LINEAR, "LINEAR");
130:                public static final Motion SMOOTH = new Motion(1000, 25,
131:                        Transition.SMOOTH, "SMOOTH");
132:                public static final Motion WOBBLE = new Motion(1000, 25,
133:                        Transition.WOBBLE, "WOBBLE");
134:                public static final Motion FLICKER = new Motion(1000, 25,
135:                        Transition.FLICKER, "FLICKER");
136:                public static final Motion PULSE = new Motion(1000, 25,
137:                        Transition.PULSE, "PULSE");
138:                public static final Motion FAST_LINEAR = new Motion(500, 25,
139:                        Transition.LINEAR, "FAST_LINEAR");
140:                public static final Motion FAST_SMOOTH = new Motion(500, 25,
141:                        Transition.SMOOTH, "FAST_SMOOTH");
142:                public static final Motion FAST_WOBBLE = new Motion(500, 25,
143:                        Transition.WOBBLE, "FAST_WOBBLE");
144:                public static final Motion FAST_FLICKER = new Motion(500, 25,
145:                        Transition.FLICKER, "FAST_FLICKER");
146:                public static final Motion FAST_PULSE = new Motion(500, 25,
147:                        Transition.PULSE, "FAST_PULSE");
148:
149:                private static int nextOrdinal = 0;
150:
151:                public static final Motion valueOf(String value) {
152:                    value = value.toUpperCase();
153:
154:                    for (Motion t : VALUES) {
155:                        if (t.stringValue.equals(value))
156:                            return t;
157:                    }
158:
159:                    String[] parts = value.split("\\s+");
160:                    int duration = parts.length > 0 ? Integer
161:                            .parseInt(parts[0]) : 0;
162:                    int frames = parts.length > 1 ? Integer.parseInt(parts[1])
163:                            : 25;
164:                    Transition transition = parts.length > 2 ? Transition
165:                            .valueOf(parts[2].toUpperCase())
166:                            : Transition.SMOOTH;
167:
168:                    for (Motion t : VALUES) {
169:                        if (t.duration == duration && t.frames == frames
170:                                && t.transition == transition)
171:                            return t;
172:                    }
173:
174:                    return new Motion(duration, frames, transition);
175:                }
176:
177:                public static final Motion[] values() {
178:                    return VALUES.toArray(new Motion[VALUES.size()]);
179:                }
180:
181:                private int ordinal;
182:                private String stringValue;
183:                private String name;
184:                private int duration;
185:                private int frames;
186:                private Transition transition;
187:
188:                public Motion(int duration) {
189:                    this (duration, 0, null, null);
190:                }
191:
192:                public Motion(int duration, int frames) {
193:                    this (duration, frames, null, null);
194:                }
195:
196:                public Motion(int duration, int frames, Transition transition) {
197:                    this (duration, frames, transition, null);
198:                }
199:
200:                private Motion(int duration, int frames, Transition transition,
201:                        String name) {
202:                    if (duration < 0)
203:                        throw new IllegalArgumentException("duration{"
204:                                + duration + "} < 0");
205:                    if (frames == 0)
206:                        frames = 25;
207:                    if (frames < 1 || frames > 100)
208:                        throw new IllegalArgumentException("frames{" + duration
209:                                + "} < 1 || frames > 100");
210:                    if (transition == null)
211:                        transition = Transition.SMOOTH;
212:                    this .duration = duration;
213:                    this .frames = frames;
214:                    this .transition = transition;
215:
216:                    if (name == null) {
217:                        stringValue = duration
218:                                + " "
219:                                + frames
220:                                + (duration == 0 && frames == 1 ? "" : " "
221:                                        + transition);
222:                        ordinal = -1;
223:                        this .name = "";
224:                    } else {
225:                        this .name = name.toUpperCase();
226:                        stringValue = name.toLowerCase();
227:                        ordinal = nextOrdinal++;
228:                        VALUES.add(this );
229:                    }
230:                }
231:
232:                public int getDuration() {
233:                    return duration;
234:                }
235:
236:                public int getFrames() {
237:                    return frames;
238:                }
239:
240:                public Transition getTransition() {
241:                    return transition;
242:                }
243:
244:                public String name() {
245:                    return name.toUpperCase();
246:                }
247:
248:                public int ordinal() {
249:                    return ordinal;
250:                }
251:
252:                public boolean equals(Object o) {
253:                    return o instanceof  Motion
254:                            && toString().equals(o.toString());
255:                }
256:
257:                public int hashCode() {
258:                    return toString().hashCode();
259:                }
260:
261:                public String toString() {
262:                    return stringValue;
263:                }
264:            }
265:
266:            private Effect() {
267:
268:            }
269:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.