Source Code Cross Referenced for ErrorPaneRobot.java in  » Swing-Library » substance-look-feel » docrobot » 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 » substance look feel » docrobot 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2008 Kirill Grouchnikov, based on work by
003:         * Sun Microsystems, Inc. All rights reserved.
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library 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 GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
018:         */
019:        package docrobot;
020:
021:        import java.awt.*;
022:        import java.awt.image.BufferedImage;
023:        import java.io.File;
024:        import java.io.IOException;
025:        import java.net.MalformedURLException;
026:        import java.net.URL;
027:        import java.util.HashMap;
028:        import java.util.Map;
029:
030:        import javax.imageio.ImageIO;
031:        import javax.swing.*;
032:
033:        import org.jdesktop.swingx.JXErrorPane;
034:        import org.jdesktop.swingx.error.ErrorInfo;
035:        import org.jvnet.substance.SubstanceDefaultLookAndFeel;
036:        import org.jvnet.substance.SubstanceLookAndFeel;
037:        import org.jvnet.substance.skin.SubstanceSkin;
038:
039:        /**
040:         * The base class for taking a single screenshot for Substance documentation.
041:         * 
042:         * @author Kirill Grouchnikov
043:         */
044:        public class ErrorPaneRobot {
045:            /**
046:             * The associated Substance skin.
047:             */
048:            protected SubstanceSkin skin;
049:
050:            /**
051:             * The screenshot filename.
052:             */
053:            protected String screenshotFilename;
054:
055:            /**
056:             * Indicates whether the screenshot process is complete.
057:             */
058:            protected boolean done = false;
059:
060:            protected JDialog dialog;
061:
062:            /**
063:             * Creates the new screenshot robot.
064:             * 
065:             * @param skin
066:             *            Substance skin.
067:             * @param screenshotFilename
068:             *            The screenshot filename.
069:             */
070:            public ErrorPaneRobot(SubstanceSkin skin, String screenshotFilename) {
071:                this .skin = skin;
072:                this .screenshotFilename = screenshotFilename;
073:            }
074:
075:            /**
076:             * Runs the screenshot process.
077:             */
078:            public void run() {
079:                long start = System.currentTimeMillis();
080:                SwingUtilities.invokeLater(new Runnable() {
081:                    public void run() {
082:                        try {
083:                            UIManager
084:                                    .setLookAndFeel(new SubstanceDefaultLookAndFeel());
085:                            SubstanceLookAndFeel.setSkin(skin);
086:                        } catch (Exception exc) {
087:                            exc.printStackTrace();
088:                        }
089:                        SwingUtilities.invokeLater(new Runnable() {
090:                            public void run() {
091:                                JDialog.setDefaultLookAndFeelDecorated(true);
092:                                // sf = new TaskPaneFrame();
093:                                final Frame owner = JOptionPane.getRootFrame();
094:                                try {
095:                                    URL url = new URL("some wrong URL string");
096:                                } catch (MalformedURLException murle) {
097:                                    String msg = "<html>An error just happened. Possible reasons:"
098:                                            + "<ol><li>Development team hoped nobody would notice."
099:                                            + "<li>The testers missed this scenario. Wait, we don't have testers."
100:                                            + "<li>Didn't your momma teach you not to use Linux?"
101:                                            + "</ol>"
102:                                            + "In any case, it's all open source so it's all good. Fix it yourself.";
103:                                    String details = "<html>Web resources should begin with \"http://\""
104:                                            + " and cannot contain any spaces. Below are a few"
105:                                            + " more guidelines.<ul></ul></html>";
106:                                    Thread tracking = new Thread() {
107:                                        @Override
108:                                        public void run() {
109:                                            while (true) {
110:                                                while (owner.getOwnedWindows().length > 1) {
111:                                                    System.out
112:                                                            .println("["
113:                                                                    + skin
114:                                                                            .getDisplayName()
115:                                                                    + "] GCing");
116:                                                    System.gc();
117:                                                }
118:
119:                                                System.out
120:                                                        .println("["
121:                                                                + skin
122:                                                                        .getDisplayName()
123:                                                                + "] Windows : "
124:                                                                + owner
125:                                                                        .getOwnedWindows().length);
126:
127:                                                if (owner.getOwnedWindows().length == 1) {
128:                                                    try {
129:                                                        Thread.sleep(1500);
130:                                                    } catch (InterruptedException ie) {
131:                                                    }
132:                                                    break;
133:                                                }
134:                                                try {
135:                                                    Thread.sleep(500);
136:                                                } catch (InterruptedException ie) {
137:                                                    break;
138:                                                }
139:                                            }
140:                                            dialog = (JDialog) owner
141:                                                    .getOwnedWindows()[owner
142:                                                    .getOwnedWindows().length - 1];
143:                                            makeScreenshot();
144:                                            SwingUtilities
145:                                                    .invokeLater(new Runnable() {
146:                                                        public void run() {
147:                                                            dialog.dispose();
148:                                                            done = true;
149:                                                        }
150:                                                    });
151:                                        }
152:                                    };
153:                                    // tracking.setPriority(Thread.MIN_PRIORITY);
154:                                    tracking.start();
155:                                    JXErrorPane.showDialog(owner,
156:                                            new ErrorInfo(
157:                                                    "JXErrorPane example", msg,
158:                                                    details, null, murle, null,
159:                                                    null));
160:                                }
161:                            }
162:                        });
163:                    }
164:                });
165:                while (!done) {
166:                    try {
167:                        Thread.sleep(300);
168:                    } catch (InterruptedException ie) {
169:                    }
170:                }
171:                long end = System.currentTimeMillis();
172:                System.out.println(this .getClass().getSimpleName() + " ["
173:                        + this .skin.getDisplayName() + "] : " + (end - start)
174:                        + "ms");
175:            }
176:
177:            /**
178:             * Creates the screenshot and saves it on the disk.
179:             */
180:            public void makeScreenshot() {
181:                BufferedImage bi = new BufferedImage(dialog.getWidth(), dialog
182:                        .getHeight(), BufferedImage.TYPE_INT_ARGB);
183:                Map<Component, Boolean> map = new HashMap<Component, Boolean>();
184:                RobotUtilities.makePreviewable(dialog, map);
185:                Graphics g = bi.getGraphics();
186:                dialog.paint(g);
187:                try {
188:                    ImageIO.write(bi, "png", new File(this .screenshotFilename
189:                            + ".png"));
190:                } catch (IOException ioe) {
191:                    ioe.printStackTrace();
192:                }
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.