Source Code Cross Referenced for ImageReferenceTest.java in  » Ajax » NextApp-Echo2 » nextapp » echo2 » testapp » interactive » testscreen » 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 » Ajax » NextApp Echo2 » nextapp.echo2.testapp.interactive.testscreen 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003:         * Copyright (C) 2002-2005 NextApp, Inc.
004:         *
005:         * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006:         *
007:         * The contents of this file are subject to the Mozilla Public License Version
008:         * 1.1 (the "License"); you may not use this file except in compliance with
009:         * the License. You may obtain a copy of the License at
010:         * http://www.mozilla.org/MPL/
011:         *
012:         * Software distributed under the License is distributed on an "AS IS" basis,
013:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014:         * for the specific language governing rights and limitations under the
015:         * License.
016:         *
017:         * Alternatively, the contents of this file may be used under the terms of
018:         * either the GNU General Public License Version 2 or later (the "GPL"), or
019:         * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020:         * in which case the provisions of the GPL or the LGPL are applicable instead
021:         * of those above. If you wish to allow use of your version of this file only
022:         * under the terms of either the GPL or the LGPL, and not to allow others to
023:         * use your version of this file under the terms of the MPL, indicate your
024:         * decision by deleting the provisions above and replace them with the notice
025:         * and other provisions required by the GPL or the LGPL. If you do not delete
026:         * the provisions above, a recipient may use your version of this file under
027:         * the terms of any one of the MPL, the GPL or the LGPL.
028:         */
029:
030:        package nextapp.echo2.testapp.interactive.testscreen;
031:
032:        import java.awt.Graphics2D;
033:        import java.awt.image.BufferedImage;
034:        import java.io.IOException;
035:        import java.io.InputStream;
036:        import java.io.OutputStream;
037:        import java.net.URL;
038:
039:        import javax.swing.ImageIcon;
040:
041:        import nextapp.echo2.app.ApplicationInstance;
042:        import nextapp.echo2.app.AwtImageReference;
043:        import nextapp.echo2.app.HttpImageReference;
044:        import nextapp.echo2.app.Label;
045:        import nextapp.echo2.app.ResourceImageReference;
046:        import nextapp.echo2.app.StreamImageReference;
047:        import nextapp.echo2.testapp.interactive.Styles;
048:        import nextapp.echo2.testapp.interactive.TestGrid;
049:
050:        /**
051:         * An interactive test for <code>ImageReference</code>s.
052:         */
053:        public class ImageReferenceTest extends TestGrid {
054:
055:            private static final String RESOURCE_IMAGE_LOCATION = Styles.IMAGE_PATH
056:                    + "Two.jpg";
057:
058:            private static final int BUFFER_SIZE = 4096;
059:
060:            // Static for memory conservation w/ live demos.
061:            private static final AwtImageReference AWT_IMAGE_REFERENCE;
062:            static {
063:                URL resourceUrl = ImageReferenceTest.class
064:                        .getResource(RESOURCE_IMAGE_LOCATION);
065:                ImageIcon imageIcon = new ImageIcon(resourceUrl);
066:                BufferedImage image = new BufferedImage(85, 100,
067:                        BufferedImage.TYPE_INT_RGB);
068:                Graphics2D graphics = (Graphics2D) image.getGraphics();
069:                graphics.drawImage(imageIcon.getImage(), 0, 0, null);
070:                graphics.setColor(java.awt.Color.BLUE);
071:                graphics.drawString("Java2D", 5, 40);
072:                AWT_IMAGE_REFERENCE = new AwtImageReference(image);
073:            }
074:
075:            private StreamImageReference streamImageReference = new StreamImageReference() {
076:
077:                private String id = ApplicationInstance.generateSystemId();
078:
079:                /**
080:                 * @see nextapp.echo2.app.StreamImageReference#getContentType()
081:                 */
082:                public String getContentType() {
083:                    return "image/jpeg";
084:                }
085:
086:                /**
087:                 * @see nextapp.echo2.app.RenderIdSupport#getRenderId()
088:                 */
089:                public String getRenderId() {
090:                    return id;
091:                }
092:
093:                /**
094:                 * @see nextapp.echo2.app.StreamImageReference#render(java.io.OutputStream)
095:                 */
096:                public void render(OutputStream out) throws IOException {
097:                    InputStream in = null;
098:                    byte[] buffer = new byte[BUFFER_SIZE];
099:                    int bytesRead = 0;
100:
101:                    try {
102:                        in = ImageReferenceTest.class
103:                                .getResourceAsStream(RESOURCE_IMAGE_LOCATION);
104:                        do {
105:                            bytesRead = in.read(buffer);
106:                            if (bytesRead > 0) {
107:                                out.write(buffer, 0, bytesRead);
108:                            }
109:                        } while (bytesRead > 0);
110:                    } finally {
111:                        if (in != null) {
112:                            try {
113:                                in.close();
114:                            } catch (IOException ex) {
115:                            }
116:                        }
117:                    }
118:                }
119:            };
120:
121:            public ImageReferenceTest() {
122:                addHeaderRow("ImageReference Types");
123:                HttpImageReference httpImageReference = new HttpImageReference(
124:                        "images/two.jpg");
125:                ResourceImageReference resourceImageReference = new ResourceImageReference(
126:                        RESOURCE_IMAGE_LOCATION);
127:                addTestRow("AwtImageReference", new Label(AWT_IMAGE_REFERENCE));
128:                addTestRow("HttpImageReference", new Label(httpImageReference));
129:                addTestRow("ResourceImageReference", new Label(
130:                        resourceImageReference));
131:                addTestRow("StreamImageReference", new Label(
132:                        streamImageReference));
133:            }
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.