Source Code Cross Referenced for SplashScreen.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » gui » 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 » jEdit » org.gjt.sp.jedit.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SplashScreen.java - Splash screen
003:         * Copyright (C) 1998, 2004 Slava Pestov
004:         *
005:         * This program is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU General Public License
007:         * as published by the Free Software Foundation; either version 2
008:         * of the License, or any later version.
009:         *
010:         * This program is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:         * GNU General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU General Public License
016:         * along with this program; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
018:         */
019:
020:        package org.gjt.sp.jedit.gui;
021:
022:        import javax.swing.*;
023:        import java.awt.*;
024:
025:        import org.gjt.sp.jedit.jEdit;
026:        import org.gjt.sp.util.Log;
027:
028:        /**
029:         * The splash screen displayed on startup.
030:         * @version $Id: SplashScreen.java 8122 2006-11-24 11:29:49Z kpouer $
031:         */
032:        public class SplashScreen extends JComponent {
033:            public SplashScreen() {
034:                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
035:                setBackground(Color.white);
036:
037:                Font font = new Font("Dialog", Font.PLAIN, 10);
038:                setFont(font);
039:                fm = getFontMetrics(font);
040:
041:                image = getToolkit().getImage(
042:                        getClass().getResource(
043:                                "/org/gjt/sp/jedit/icons/splash.png"));
044:                MediaTracker tracker = new MediaTracker(this );
045:                tracker.addImage(image, 0);
046:
047:                try {
048:                    tracker.waitForAll();
049:                } catch (Exception e) {
050:                    Log.log(Log.ERROR, this , e);
051:                }
052:
053:                win = new JWindow();
054:                GraphicsEnvironment ge = GraphicsEnvironment
055:                        .getLocalGraphicsEnvironment();
056:                GraphicsDevice[] gs = ge.getScreenDevices();
057:                int height = gs[0].getDisplayMode().getHeight();
058:                int width = gs[0].getDisplayMode().getWidth();
059:                Dimension screen = new Dimension(width, height);
060:                Dimension size = new Dimension(image.getWidth(this ) + 2, image
061:                        .getHeight(this )
062:                        + 2 + PROGRESS_HEIGHT);
063:                win.setSize(size);
064:
065:                win.getContentPane().add(this , BorderLayout.CENTER);
066:
067:                win.setLocation((screen.width - size.width) / 2,
068:                        (screen.height - size.height) / 2);
069:                win.validate();
070:                win.setVisible(true);
071:            }
072:
073:            public void dispose() {
074:                win.dispose();
075:            }
076:
077:            public synchronized void advance() {
078:                logAdvanceTime(null);
079:                progress++;
080:                repaint();
081:
082:                // wait for it to be painted to ensure progress is updated
083:                // continuously
084:                try {
085:                    wait();
086:                } catch (InterruptedException ie) {
087:                    Log.log(Log.ERROR, this , ie);
088:                }
089:            }
090:
091:            public synchronized void advance(String label) {
092:                logAdvanceTime(label);
093:                progress++;
094:                this .label = label;
095:                repaint();
096:
097:                // wait for it to be painted to ensure progress is updated
098:                // continuously
099:                try {
100:                    wait();
101:                } catch (InterruptedException ie) {
102:                    Log.log(Log.ERROR, this , ie);
103:                }
104:            }
105:
106:            private void logAdvanceTime(String label) {
107:                long currentTime = System.currentTimeMillis();
108:                if (lastLabel != null) {
109:                    Log.log(Log.DEBUG, SplashScreen.class, lastLabel + ':'
110:                            + (currentTime - lastAdvanceTime) + "ms");
111:                }
112:                if (label != null) {
113:                    lastLabel = label;
114:                    lastAdvanceTime = currentTime;
115:
116:                }
117:
118:            }
119:
120:            public synchronized void paintComponent(Graphics g) {
121:                Dimension size = getSize();
122:
123:                g.setColor(Color.black);
124:                g.drawRect(0, 0, size.width - 1, size.height - 1);
125:
126:                g.drawImage(image, 1, 1, this );
127:
128:                // XXX: This should not be hardcoded
129:                g.setColor(Color.white);
130:                g.fillRect(1, image.getHeight(this ) + 1,
131:                        ((win.getWidth() - 2) * progress) / PROGRESS_COUNT,
132:                        PROGRESS_HEIGHT);
133:
134:                g.setColor(Color.black);
135:
136:                if (label != null) {
137:                    g.drawString(label,
138:                            (getWidth() - fm.stringWidth(label)) / 2, image
139:                                    .getHeight(this )
140:                                    + (PROGRESS_HEIGHT + fm.getAscent() + fm
141:                                            .getDescent()) / 2);
142:                }
143:
144:                String version = jEdit.getVersion();
145:                g.drawString(version, getWidth() - fm.stringWidth(version) - 2,
146:                        image.getHeight(this ) - fm.getDescent());
147:                notify();
148:            }
149:
150:            // private members
151:            private final FontMetrics fm;
152:            private final JWindow win;
153:            private final Image image;
154:            private int progress;
155:            private static final int PROGRESS_HEIGHT = 20;
156:            private static final int PROGRESS_COUNT = 28;
157:            private String label;
158:            private String lastLabel;
159:            private long lastAdvanceTime = System.currentTimeMillis();
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.