Source Code Cross Referenced for SResourceIcon.java in  » Swing-Library » wings3 » org » wings » 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 » wings3 » org.wings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2000,2005 wingS development team.
003:         *
004:         * This file is part of wingS (http://wingsframework.org).
005:         *
006:         * wingS is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU Lesser General Public License
008:         * as published by the Free Software Foundation; either version 2.1
009:         * of the License, or (at your option) any later version.
010:         *
011:         * Please see COPYING for the complete licence.
012:         */
013:        package org.wings;
014:
015:        import org.apache.commons.logging.Log;
016:        import org.apache.commons.logging.LogFactory;
017:        import org.wings.resource.ClassPathResource;
018:        import org.wings.util.ImageInfo;
019:
020:        import java.io.ByteArrayInputStream;
021:        import java.io.IOException;
022:
023:        /*
024:         * Diese Klasse ist nur ein Wrapper, um Eingabestroeme von Grafiken mit dem
025:         * ExternalizeManager mit der richtigen Endung und ohne Umweg einer neuen
026:         * Codierung (die z.B. keine Transparenz unterstuetzt) uebers WWW zugreifbar zu
027:         * machen. Zugleich muss diese Klasse aber auch zu der API der Componenten
028:         * passen, also ein Image bzw. ImageIcon sein. ImageIcon ist einfacher zu
029:         * benutzen und implementiert schon alles was benoetigt wird...
030:         */
031:
032:        /**
033:         * SIcon that gets it's content from an image found in the classpath.
034:         * i.e. an image that is deployed in the classes/jar/war file.
035:         * <p/>
036:         * An SIcon of this type is externalized globally. It is not bound
037:         * to a session.
038:         * 
039:         * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
040:         */
041:        public class SResourceIcon extends ClassPathResource implements  SIcon {
042:
043:            private final transient static Log log = LogFactory
044:                    .getLog(SResourceIcon.class);
045:
046:            /**
047:             * Width of icon, <code>-1</code> if not set.
048:             */
049:            private int width = -1;
050:
051:            /**
052:             * Height of icon, <code>-1</code> if not set.
053:             */
054:            private int height = -1;
055:
056:            /**
057:             * Title of icon, <code>""</code> if not set.
058:             */
059:            private String title = null;
060:
061:            public SResourceIcon(String resourceFileName) {
062:                this (Thread.currentThread().getContextClassLoader(),
063:                        resourceFileName);
064:            }
065:
066:            public SResourceIcon(ClassLoader classLoader,
067:                    String resourceFileName) {
068:                super (classLoader, resourceFileName);
069:
070:                try {
071:                    bufferResource();
072:                } catch (Throwable e) {
073:                    log.fatal("Can not buffer resource " + resourceFileName);
074:                }
075:
076:                if (buffer != null && buffer.isValid()) {
077:                    ImageInfo tImageInfo = new ImageInfo();
078:                    ByteArrayInputStream tImageInput = new ByteArrayInputStream(
079:                            buffer.getBytes());
080:                    tImageInfo.setInput(tImageInput);
081:
082:                    if (tImageInfo.check()) {
083:                        extension = tImageInfo.getFormatName();
084:                        mimeType = tImageInfo.getMimeType();
085:                        width = tImageInfo.getWidth();
086:                        height = tImageInfo.getHeight();
087:                    }
088:
089:                    try {
090:                        tImageInput.close();
091:                    } catch (IOException ex) {
092:                        // ignore it, we don't need it anymore...
093:                    }
094:                }
095:            }
096:
097:            public int getIconWidth() {
098:                return width;
099:            }
100:
101:            public int getIconHeight() {
102:                return height;
103:            }
104:
105:            public void setIconWidth(int width) {
106:                this .width = width;
107:            }
108:
109:            public void setIconHeight(int height) {
110:                this .height = height;
111:            }
112:
113:            public String getIconTitle() {
114:                return (title != null) ? title : "";
115:            }
116:
117:            public void setIconTitle(String title) {
118:                this.title = title;
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.