Source Code Cross Referenced for XAnimatedText.java in  » XML-UI » xui32 » com » xoetrope » swing » 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 » XML UI » xui32 » com.xoetrope.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.swing;
002:
003:        import java.awt.Graphics2D;
004:        import com.xoetrope.swing.animation.FadeInStep;
005:        import javax.swing.SwingConstants;
006:
007:        import net.xoetrope.xui.XAttributedComponent;
008:        import net.xoetrope.xui.helper.XuiUtilities;
009:        import org.jdesktop.animation.timing.Animator;
010:
011:        /**
012:         * A fade in animation of text. The text is faded in from the background color
013:         * to the foreground color.
014:         *
015:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
016:         * the GNU Public License (GPL), please see license.txt for more details. If
017:         * you make commercial use of this software you must purchase a commercial
018:         * license from Xoetrope.</p>
019:         * <p> $Revision: 1.17 $</p>
020:         */
021:        public class XAnimatedText extends XFlowedTextComponent implements 
022:                /*XAnimationContext,*/XAttributedComponent, SwingConstants {
023:            private FadeInStep fadeIn = new FadeInStep();
024:            private int alignment;
025:
026:            /**
027:             * Create a new XAnimatedText instance
028:             */
029:            public XAnimatedText() {
030:                setLoopTime(32000);
031:                setSleepTime(32);
032:            }
033:
034:            /**
035:             * Initialize the animation surface and prepare the starting point/setup
036:             */
037:            public void init() {
038:                super .init();
039:                fadeIn.init();
040:                fadeIn.setStartColor(XuiUtilities.unsaturateColor(
041:                        getForeground(), 15));
042:                fadeIn.setEndColor(getForeground());
043:            }
044:
045:            /**
046:             * Specifies a new style for the control.
047:             * @param newStyle the new style name
048:             */
049:            public void useStyle(int newStyle) {
050:                repaint();
051:            }
052:
053:            /**
054:             * This method will receive all of the timing events from an Animator
055:             * during an animation.  The fraction is the percent elapsed (0 to 1)
056:             * of the current animation cycle.
057:             * @param fraction the fraction of completion between the start and
058:             * end of the current cycle.  Note that on reversing cycles
059:             * ({@link Animator.Direction#BACKWARD}) the fraction decreases
060:             * from 1.0 to 0 on backwards-running cycles.  Note also that animations
061:             * with a duration of {@link Animator#INFINITE INFINITE} will call
062:             * timingEvent with an undefined value for fraction, since there is
063:             * no fraction that makes sense if the animation has no defined length.
064:             * @see Animator.Direction
065:             */
066:            public void timingEvent(float fraction) {
067:                timingFraction = fraction;
068:                step(0, 0);
069:                repaint();
070:            }
071:
072:            //=========================================================================
073:            //	    Rendering
074:            //=========================================================================
075:            /**
076:             * Apply the current state to the graphics rendering context
077:             * @param g2 the graphics context
078:             */
079:            public void applyState(Graphics2D g2) {
080:                fadeIn.apply(animator, g2);
081:            }
082:
083:            /**
084:             * Adjust the settings for the next step.
085:             * 
086:             * @param w the width
087:             * @param h the height
088:             */
089:            public void reset(int w, int h) {
090:                fadeIn.reset();
091:            }
092:
093:            /**
094:             * Adjust the settings for the next step.
095:             * 
096:             * 
097:             * @param w the width
098:             * @param h the height
099:             */
100:            public void step(int w, int h) {
101:                fadeIn.step(animator);
102:            }
103:
104:            /**
105:             * Are there more steps to come?
106:             * @param at the animation thread
107:             * @return true if the animation has completed, false otherwise
108:             */
109:            public boolean isFinished(Animator at) {
110:                return fadeIn.isFinished(at);
111:            }
112:
113:            /**
114:             * Should the object be animated in this step?
115:             * @param at the animation thread
116:             * @return true is the animation is running
117:             */
118:            public boolean isAnimated(Animator at) {
119:                return fadeIn.isAnimated(at);
120:            }
121:
122:            //=========================================================================
123:            //	    Access Functions
124:            //=========================================================================
125:            /**
126:             * Sets the update increment.
127:             * @param incr the time in milliseconds between animation steps
128:             */
129:            public void setIncrement(int incr) {
130:                increment = (int) ((float) incr / 100.0f);
131:            }
132:
133:            /**
134:             * Get the update increment
135:             * @return the time between animation steps in milliseconds
136:             */
137:            public int getIncrement() {
138:                return (int) (increment * 100.0);
139:            }
140:
141:            /**
142:             * Sets the text alignment.
143:             * @param align the alignment
144:             */
145:            public void setAlignment(int align) {
146:                alignment = align;
147:            }
148:
149:            /**
150:             * Get the text alignment
151:             * @return the alignment value
152:             */
153:            public int getAlignment() {
154:                return alignment;
155:            }
156:
157:            /**
158:             * Set one or more attributes of the component.
159:             * @param attribName the name of the attribute
160:             * <ul>
161:             * <li>text - set the text</li>
162:             * <li>content - set the text</li>
163:             * <li>step - set the step size</li>
164:             * <li>align - the text alignment, left, right, center</li>
165:             * </ul>
166:             * @param attribValue the value of the attribute
167:             * @return 0 for success, non zero otherwise
168:             */
169:            public int setAttribute(String attribName, Object attribValue) {
170:                String attribNameLwr = attribName.toLowerCase();
171:                String attribValueStr = (String) attribValue;
172:                String attribValueLwr = attribValueStr.toLowerCase();
173:                if (attribNameLwr.equals("step"))
174:                    setIncrement(Integer.parseInt(attribValueStr));
175:                else if (attribNameLwr.equals("align")
176:                        || attribNameLwr.equals("alignment"))
177:                    alignment = attribValueLwr.equals("right") ? SwingConstants.RIGHT
178:                            : attribValueLwr.equals("center") ? SwingConstants.CENTER
179:                                    : SwingConstants.LEFT;
180:                else
181:                    super .setAttribute(attribName, attribValue);
182:                return 0;
183:            }
184:
185:            /**
186:             * Set the text content for the component.
187:             * @param set the text value
188:             */
189:            public void setContent(String content) {
190:                super .setAttribute("text", content);
191:            }
192:
193:            /**
194:             * Get the text content
195:             * @return the text value
196:             */
197:            public String getContent() {
198:                return super.getText();
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.