Source Code Cross Referenced for BasicTextAnimations.java in  » Swing-Library » jgoodies-animation » com » jgoodies » animation » animations » 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 » Swing Library » jgoodies animation » com.jgoodies.animation.animations 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         * 
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer. 
009:         *     
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution. 
013:         *     
014:         *  o Neither the name of JGoodies Karsten Lentzsch nor the names of 
015:         *    its contributors may be used to endorse or promote products derived 
016:         *    from this software without specific prior written permission. 
017:         *     
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029:         */
030:
031:        package com.jgoodies.animation.animations;
032:
033:        import java.awt.Color;
034:        import java.util.LinkedList;
035:        import java.util.List;
036:
037:        import com.jgoodies.animation.Animation;
038:        import com.jgoodies.animation.Animations;
039:        import com.jgoodies.animation.components.BasicTextLabel;
040:
041:        /**
042:         * Provides a text animation that shows an overlapping sequence of 
043:         * texts using a bunch of different effects: color fade, scaling, glyph spacing.
044:         * 
045:         * @author Karsten Lentzsch
046:         * @version $Revision: 1.1 $
047:         * 
048:         * @see BasicTextAnimation
049:         */
050:        public final class BasicTextAnimations {
051:
052:            private static final int FADE_TYPE = 0;
053:            private static final int SCALE_TYPE = 1;
054:            private static final int SPACE_TYPE = 2;
055:
056:            private BasicTextAnimations() {
057:                // Override default constructor; prevents instantiation.
058:            }
059:
060:            /**
061:             * Creates and answers the default color fade text sequence.
062:             * 
063:             * @param label1           a text label used to blend over
064:             * @param label2           a second text label used to blend over
065:             * @param singleDuration   the duration of a single animation
066:             * @param beginOffset      an initial animation time offset
067:             * @param separatedTexts   a sequence of texts in a string separated
068:             * by the | character
069:             * @param baseColor        the base color for the fade
070:             * @return a default fade animation
071:             */
072:            public static Animation defaultFade(BasicTextLabel label1,
073:                    BasicTextLabel label2, long singleDuration,
074:                    long beginOffset, String separatedTexts, Color baseColor) {
075:
076:                return createTextSequence(label1, label2, singleDuration,
077:                        beginOffset, separatedTexts, baseColor, FADE_TYPE);
078:            }
079:
080:            /**
081:             * Creates and answers the default scaling text sequence.
082:             * 
083:             * @param label1           a text label used to blend over
084:             * @param label2           a second text label used to blend over
085:             * @param singleDuration   the duration of a single animation
086:             * @param beginOffset      an initial animation time offset
087:             * @param separatedTexts   a sequence of texts in a string separated
088:             * by the | character
089:             * @param baseColor        the base color for the fade
090:             * @return a default scaling blend over animation
091:             */
092:            public static Animation defaultScale(BasicTextLabel label1,
093:                    BasicTextLabel label2, long singleDuration,
094:                    long beginOffset, String separatedTexts, Color baseColor) {
095:
096:                return createTextSequence(label1, label2, singleDuration,
097:                        beginOffset, separatedTexts, baseColor, SCALE_TYPE);
098:            }
099:
100:            /**
101:             * Creates and answers the default glyph spacing text sequence.
102:             * 
103:             * @param label1           a text label used to blend over
104:             * @param label2           a second text label used to blend over
105:             * @param singleDuration   the duration of a single animation
106:             * @param beginOffset      an initial animation time offset
107:             * @param separatedTexts   a sequence of texts in a string separated
108:             * by the | character
109:             * @param baseColor        the base color for the fade
110:             * @return a default space blend over animation
111:             */
112:            public static Animation defaultSpace(BasicTextLabel label1,
113:                    BasicTextLabel label2, long singleDuration,
114:                    long beginOffset, String separatedTexts, Color baseColor) {
115:
116:                return createTextSequence(label1, label2, singleDuration,
117:                        beginOffset, separatedTexts, baseColor, SPACE_TYPE);
118:            }
119:
120:            // Private Helper Code ****************************************************
121:
122:            /**
123:             * Creates and returns the default glyph spacing text sequence.
124:             * 
125:             * @param label1    the first label to render the sequence
126:             * @param label2    the second label to render
127:             * @param singleDuration  the duration of a step in the sequence
128:             * @param beginOffset     an offset in ms between to steps
129:             * @param separatedTexts  a '|' separated lists of texts to display
130:             * @param baseColor       the color used as a basis for the text
131:             * @param type            the type of the effect used to change
132:             * @return a composed animation that displays a sequence of texts
133:             */
134:            private static Animation createTextSequence(BasicTextLabel label1,
135:                    BasicTextLabel label2, long singleDuration,
136:                    long beginOffset, String separatedTexts, Color baseColor,
137:                    int type) {
138:
139:                Animation animation;
140:                String[] texts = separatedTexts.split("\\|");
141:                List animations = new LinkedList();
142:                long beginTime = 0;
143:
144:                BasicTextLabel label = label1;
145:                for (int i = 0; i < texts.length; i++) {
146:                    label = i % 2 == 0 ? label1 : label2;
147:                    animation = animation(label, singleDuration, texts[i],
148:                            baseColor, type);
149:                    animations.add(Animations.offset(beginTime, animation));
150:                    beginTime += singleDuration + beginOffset;
151:                }
152:
153:                return Animations.parallel(animations);
154:            }
155:
156:            private static Animation animation(BasicTextLabel label,
157:                    long duration, String text, Color baseColor, int type) {
158:                switch (type) {
159:                case FADE_TYPE:
160:                    return BasicTextAnimation.defaultFade(label, duration,
161:                            text, baseColor);
162:
163:                case SCALE_TYPE:
164:                    return BasicTextAnimation.defaultScale(label, duration,
165:                            text, baseColor);
166:
167:                case SPACE_TYPE:
168:                    return BasicTextAnimation.defaultSpace(label, duration,
169:                            text, baseColor);
170:
171:                default:
172:                    return null;
173:                }
174:            }
175:
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.