Source Code Cross Referenced for SplashPanel.java in  » Database-Client » executequery » org » underworldlabs » 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 » Database Client » executequery » org.underworldlabs.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SplashPanel.java
003:         *
004:         * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         */
021:
022:        package org.underworldlabs.swing;
023:
024:        import java.awt.BorderLayout;
025:        import java.awt.Canvas;
026:        import java.awt.Color;
027:        import java.awt.Cursor;
028:        import java.awt.Dimension;
029:        import java.awt.Font;
030:        import java.awt.FontMetrics;
031:        import java.awt.Frame;
032:        import java.awt.GradientPaint;
033:        import java.awt.Graphics;
034:        import java.awt.Graphics2D;
035:        import java.awt.Image;
036:        import java.awt.MediaTracker;
037:        import java.awt.RenderingHints;
038:        import java.awt.Window;
039:        import org.underworldlabs.swing.plaf.UIUtils;
040:
041:        /* ----------------------------------------------------------
042:         * CVS NOTE: Changes to the CVS repository prior to the 
043:         *           release of version 3.0.0beta1 has meant a 
044:         *           resetting of CVS revision numbers.
045:         * ----------------------------------------------------------
046:         */
047:
048:        /** 
049:         * This class creates a splash panel to the size of the image to be 
050:         * displayed. The panel is displayed for as long as is required to 
051:         * load required classes and build the application frame and associated 
052:         * components.
053:         *
054:         * @author   Takis Diakoumis
055:         * @version  $Revision: 1.8 $
056:         * @date     $Date: 2006/07/15 12:51:52 $
057:         */
058:        public class SplashPanel extends Canvas {
059:
060:            /** This object's font metrics */
061:            private FontMetrics fontMetrics;
062:
063:            /** The window displayed */
064:            private Window window;
065:
066:            /** The splash image */
067:            private Image image;
068:
069:            /** The off-screen image */
070:            private Image offscreenImg;
071:
072:            /** The off-screen graphics */
073:            private Graphics offscreenGfx;
074:
075:            /** The startup progress posiiton */
076:            private int progress;
077:
078:            /** The version info string */
079:            private String version;
080:
081:            /** The progress bar's colour */
082:            private Color progressColour;
083:
084:            /** the light gradient colour */
085:            private Color gradientColour;
086:
087:            /** the x-coord of the version string */
088:            private int versionLabelX;
089:
090:            /** the y-coord of the version string */
091:            private int versionLabelY;
092:
093:            /** The progress bar height */
094:            private int PROGRESS_HEIGHT = 20;
095:
096:            /** Creates a new instance of the splash panel. */
097:            public SplashPanel(Color progressBarColour,
098:                    String imageResourcePath, String versionNumber) {
099:                this (progressBarColour, imageResourcePath, versionNumber, -1,
100:                        -1);
101:            }
102:
103:            public SplashPanel(Color progressBarColour,
104:                    String imageResourcePath, String versionNumber,
105:                    int versionLabelX, int versionLabelY) {
106:
107:                this .versionLabelX = versionLabelX;
108:                this .versionLabelY = versionLabelY;
109:
110:                progressColour = progressBarColour;
111:                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
112:                setBackground(Color.white);
113:
114:                gradientColour = UIUtils.getBrighter(progressBarColour, 0.65);
115:
116:                Font font = new Font("Dialog", Font.PLAIN, 15);
117:                setFont(font);
118:                fontMetrics = getFontMetrics(font);
119:
120:                image = getToolkit().getImage(
121:                        getClass().getResource(imageResourcePath));
122:
123:                MediaTracker tracker = new MediaTracker(this );
124:                tracker.addImage(image, 0);
125:
126:                if (versionNumber != null) {
127:                    version = "Version " + versionNumber;
128:                }
129:
130:                try {
131:                    tracker.waitForAll();
132:                } catch (Exception e) {
133:                    e.printStackTrace();
134:                }
135:
136:                window = new Window(new Frame());
137:
138:                Dimension screen = getToolkit().getScreenSize();
139:                Dimension size = new Dimension(image.getWidth(this ), image
140:                        .getHeight(this ));
141:                window.setSize(size);
142:
143:                window.setLayout(new BorderLayout());
144:                window.add(BorderLayout.CENTER, this );
145:
146:                window.setLocation((screen.width - size.width) / 2,
147:                        (screen.height - size.height) / 2);
148:                window.validate();
149:                window.setVisible(true);
150:
151:            }
152:
153:            public synchronized void advance() {
154:                progress++;
155:                repaint();
156:
157:                // wait for it to be painted to ensure
158:                // progress is updated continuously
159:                try {
160:                    wait();
161:                } catch (InterruptedException ie) {
162:                    ie.printStackTrace();
163:                }
164:
165:            }
166:
167:            public synchronized void paint(Graphics g) {
168:                Dimension size = getSize();
169:
170:                if (offscreenImg == null) {
171:                    offscreenImg = createImage(size.width, size.height);
172:                    offscreenGfx = offscreenImg.getGraphics();
173:                    Font font = new Font("dialog", Font.PLAIN, 12);
174:                    offscreenGfx.setFont(font);
175:                }
176:
177:                offscreenGfx.drawImage(image, 0, 0, this );
178:
179:                offscreenGfx.setColor(progressColour);
180:                /*
181:                offscreenGfx.fillRect(0, 
182:                                      image.getHeight(this) - PROGRESS_HEIGHT,
183:                                      (window.getWidth() * progress) / 9, 
184:                                      PROGRESS_HEIGHT);
185:                 */
186:                ((Graphics2D) offscreenGfx).setPaint(new GradientPaint(0, image
187:                        .getHeight(this )
188:                        - PROGRESS_HEIGHT, gradientColour,//new Color(95,95,190), 
189:                        0, image.getHeight(this ), progressColour));
190:
191:                offscreenGfx.fillRect(0, image.getHeight(this )
192:                        - PROGRESS_HEIGHT, (window.getWidth() * progress) / 9,
193:                        PROGRESS_HEIGHT);
194:
195:                if (version != null) {
196:
197:                    if (versionLabelX == -1) {
198:                        versionLabelX = (getWidth() - fontMetrics
199:                                .stringWidth(version)) / 2;
200:                    }
201:
202:                    if (versionLabelY == -1) {
203:                        // if no y value - set just above progress bar
204:                        versionLabelY = image.getHeight(this ) - PROGRESS_HEIGHT
205:                                - fontMetrics.getHeight();
206:                    }
207:
208:                    ((Graphics2D) offscreenGfx).setRenderingHint(
209:                            RenderingHints.KEY_ANTIALIASING,
210:                            RenderingHints.VALUE_ANTIALIAS_ON);
211:
212:                    offscreenGfx.setColor(Color.WHITE);
213:                    offscreenGfx.drawString(version, versionLabelX,
214:                            versionLabelY);
215:                }
216:
217:                g.drawImage(offscreenImg, 0, 0, this );
218:
219:                notify();
220:            }
221:
222:            public void dispose() {
223:                // wait a moment
224:                try {
225:                    Thread.sleep(600);
226:                    //Thread.sleep(20000);
227:                } catch (Exception e) {
228:                }
229:                window.dispose();
230:            }
231:
232:            public void update(Graphics g) {
233:                paint(g);
234:            }
235:
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.