Source Code Cross Referenced for JGraphpadImageIcon.java in  » Graphic-Library » jgraphpad » com » jgraph » pad » util » 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 » Graphic Library » jgraphpad » com.jgraph.pad.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: JGraphpadImageIcon.java,v 1.2 2005/08/17 21:20:29 gaudenz Exp $
003:         * Copyright (c) 2001-2005, Gaudenz Alder
004:         * 
005:         * All rights reserved. 
006:         * 
007:         * This file is licensed under the JGraph software license, a copy of which
008:         * will have been provided to you in the file LICENSE at the root of your
009:         * installation directory. If you are unable to locate this file please
010:         * contact JGraph sales for another copy.
011:         */
012:        package com.jgraph.pad.util;
013:
014:        import java.io.File;
015:        import java.net.MalformedURLException;
016:        import java.net.URL;
017:
018:        import javax.swing.ImageIcon;
019:
020:        import com.jgraph.editor.JGraphEditorResources;
021:
022:        /**
023:         * This class transform a <CODE>ImageIcon</CODE> into a bean, allowing for
024:         * encoding and decoding in XML using <CODE>XMLEncoder</CODE> and <CODE>
025:         * XMLDecoder</CODE>.
026:         */
027:        public class JGraphpadImageIcon extends ImageIcon {
028:
029:            private String filename = null;
030:
031:            /**
032:             * Creates an uninitialized image icon.
033:             */
034:            public JGraphpadImageIcon() {
035:                super ();
036:            }
037:
038:            /**
039:             * Creates an image icon from the specified file. The image will be
040:             * preloaded by using <CODE>MediaTracker</CODE> to monitor the loading
041:             * answer of the image. The specified <CODE>String</CODE> can be a file
042:             * name or a file path. When specifying a path, use the Internet-standard
043:             * forward-slash ("/") as a separator. (The string is converted to an <CODE>
044:             * URL</CODE>, so the forward-slash works on all systems.) For example,
045:             * specify:
046:             * 
047:             * <PRE>
048:             * 
049:             * new JGraphpadImageIcon("images/myImage.gif")
050:             * 
051:             * </PRE>
052:             * 
053:             * The <CODE>description</CODE> is initialized to the filename string.
054:             * 
055:             * @param filename
056:             *            A <CODE>String</CODE> specifying a filename or path.
057:             */
058:            public JGraphpadImageIcon(String filename) {
059:                setFileName(filename);
060:            }
061:
062:            /**
063:             * Creates an image icon from the specified file. The image will be
064:             * preloaded by using <CODE>MediaTracker</CODE> to monitor the loading
065:             * answer of the image.
066:             * 
067:             * @param filename
068:             *            The name of the file containing the image.
069:             * @param description
070:             *            A brief textual description of the image.
071:             */
072:            public JGraphpadImageIcon(String filename, String description) {
073:                setDescription(description);
074:                setFileName(filename);
075:            }
076:
077:            /**
078:             * Creates an image icon from the specified <CODE>URL</CODE>. The image
079:             * will be preloaded by using <CODE>MediaTracker</CODE> to monitor the
080:             * loaded answer of the image. The icon's <CODE>description</CODE> is
081:             * initialized to be a string representation of the URL.
082:             * 
083:             * @param location
084:             *            The <CODE>URL</CODE> for the image.
085:             */
086:            public JGraphpadImageIcon(URL location) {
087:                setFileName(location.toExternalForm());
088:            }
089:
090:            /**
091:             * Creates an image icon from the specified <CODE>URL</CODE>. The image
092:             * will be preloaded by using <CODE>MediaTracker</CODE> to monitor the
093:             * loaded answer of the image.
094:             * 
095:             * @param location
096:             *            The URL for the image.
097:             * @param description
098:             *            A brief textual description of the image.
099:             */
100:            public JGraphpadImageIcon(URL location, String description) {
101:                setDescription(description);
102:                setFileName(location.toExternalForm());
103:            }
104:
105:            /**
106:             * Returns the file name used to initialize the image.
107:             */
108:            public String getFileName() {
109:                return filename;
110:            }
111:
112:            /**
113:             * Initializes this image icon from the specified file. The image will be
114:             * preloaded by using <CODE>MediaTracker</CODE> to monitor the loading
115:             * answer of the image. The specified <CODE>String</CODE> can be a file
116:             * name or a file path. When specifying a path, use the Internet-standard
117:             * forward-slash ("/") as a separator. (The string is converted to an <CODE>
118:             * URL</CODE>, so the forward-slash works on all systems.) For example,
119:             * specify:
120:             * 
121:             * <PRE>
122:             * 
123:             * new BeanifiedIcon().setFileName("images/myImage.gif")
124:             * 
125:             * </PRE>
126:             * 
127:             * @param filename
128:             *            A <CODE>String</CODE> specifying a filename or path.
129:             */
130:            public void setFileName(String filename) {
131:
132:                // Try classpath first
133:                ImageIcon icon = JGraphEditorResources.getImage(filename);
134:                if (icon != null) {
135:                    this .filename = filename;
136:                    setImage(icon.getImage());
137:                } else {
138:
139:                    URL loadableName;
140:
141:                    try {
142:                        try {
143:                            loadableName = new URL(filename);
144:                        } catch (MalformedURLException ex) {
145:                            loadableName = new File(filename).toURL();
146:                        }
147:                        this .filename = loadableName.toExternalForm();
148:                    } catch (Exception ex) {
149:                        return;
150:                    }
151:
152:                    if (getDescription() == null)
153:                        setDescription(filename);
154:
155:                    icon = JGraphEditorResources.getImage(this.filename);
156:                    if (icon != null)
157:                        setImage(icon.getImage());
158:
159:                }
160:
161:            }
162:
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.