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


001:        package com.xoetrope.swing.animation;
002:
003:        import java.awt.Color;
004:        import java.awt.Graphics2D;
005:        import org.jdesktop.animation.timing.Animator;
006:
007:        /**
008:         * A colour fade-in
009:         *
010:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
011:         * the GNU Public License (GPL), please see license.txt for more details. If
012:         * you make commercial use of this software you must purchase a commercial
013:         * license from Xoetrope.</p>
014:         * <p> $Revision: 1.8 $</p>
015:         */
016:        public class FadeInStep implements  AnimationStep {
017:            private float increment = 0.02f;
018:            private float value;
019:            private float hsbStart[];
020:            private float hsbFinal[];
021:            private Color actualColor, startColor, endColor;
022:            private int ascent;
023:            private boolean finished;
024:
025:            /** Creates a new instance of FadeInStep */
026:            public FadeInStep() {
027:                init();
028:            }
029:
030:            /**
031:             * Set the initial state
032:             */
033:            public void init() {
034:                finished = false;
035:                value = 0.0F;
036:
037:                reset();
038:            }
039:
040:            /**
041:             * Is the animation loop finished
042:             * 
043:             * @param at the animation thread on which this object is running
044:             * @return true if the animation has completed
045:             */
046:            public boolean isFinished(Animator at) {
047:                return finished;
048:            }
049:
050:            /**
051:             * Is the animation loop still active/running
052:             * 
053:             * @param at the animation thread on which this object is running
054:             * @return true if the animation has started and is still in progress
055:             */
056:            public boolean isAnimated(Animator at) {
057:                return !finished;
058:            }
059:
060:            /**
061:             * Set the color used at the start of the fade-in, normally this is the background color
062:             * @param sc the start/initial color
063:             */
064:            public void setStartColor(Color sc) {
065:                startColor = sc;
066:            }
067:
068:            /**
069:             * Set the color used once the fade in has completed
070:             * @param ec the end color
071:             */
072:            public void setEndColor(Color ec) {
073:                endColor = ec;
074:            }
075:
076:            /**
077:             * Advance to the next step in the animation
078:             * 
079:             * @param g2 the graphics context
080:             * @param at the animation thread on which this object is running
081:             */
082:            public void apply(Animator at, Graphics2D g2) {
083:                actualColor = Color.getHSBColor(hsbStart[0], hsbStart[1],
084:                        hsbStart[2]);
085:                Color frgdColor = new Color(actualColor.getRed(), actualColor
086:                        .getGreen(), actualColor.getBlue(), Math.min(255,
087:                        (int) (value * 255)));
088:                g2.setColor(frgdColor);
089:                //g2.setBackground( startColor );
090:            }
091:
092:            /**
093:             * Reset the animation to its initial state
094:             */
095:            public void reset() {
096:                float rgb[] = new float[3];
097:                if (startColor == null)
098:                    startColor = Color.white;
099:
100:                rgb = startColor.getRGBColorComponents(rgb);
101:                hsbStart = Color.RGBtoHSB((int) (255 * rgb[0]),
102:                        (int) (255 * rgb[1]), (int) (255 * rgb[2]), null);
103:
104:                if (endColor == null)
105:                    endColor = Color.black;
106:
107:                float rgb2[] = endColor.getRGBColorComponents(rgb);
108:                hsbFinal = Color.RGBtoHSB((int) (255 * rgb2[0]),
109:                        (int) (255 * rgb2[1]), (int) (255 * rgb2[2]), null);
110:
111:                actualColor = Color.getHSBColor(hsbStart[0], hsbStart[1],
112:                        hsbStart[2]);
113:                finished = false;
114:            }
115:
116:            /**
117:             * Move to the next step in the animation
118:             * @param at the animation thread
119:             */
120:            public void step(Animator at) {
121:                if (actualColor == null)
122:                    reset();
123:                else if (value >= 1.0F) {
124:                    finished = true;
125:                    return;
126:                }
127:
128:                value += increment;
129:                hsbStart[0] += value * (hsbFinal[0] - hsbStart[0]);
130:                hsbStart[1] += value * (hsbFinal[1] - hsbStart[1]);
131:                hsbStart[2] += value * (hsbFinal[2] - hsbStart[2]);
132:            }
133:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.