Source Code Cross Referenced for ImageField.java in  » Report » datavision-1.1.0 » jimm » datavision » field » 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 » Report » datavision 1.1.0 » jimm.datavision.field 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision.field;
002:
003:        import jimm.datavision.Report;
004:        import jimm.datavision.Section;
005:        import jimm.datavision.ErrorHandler;
006:        import jimm.datavision.gui.FieldWidget;
007:        import jimm.datavision.gui.ImageFieldWidget;
008:        import jimm.datavision.gui.SectionWidget;
009:        import java.net.URL;
010:        import java.net.MalformedURLException;
011:        import java.awt.MediaTracker;
012:        import javax.swing.ImageIcon;
013:        import javax.swing.GrayFilter;
014:
015:        /**
016:         * Represents an external image. The <code>value</code> instance value
017:         * stores the images file's path.
018:         *
019:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
020:         */
021:        public class ImageField extends Field {
022:
023:            public static final String TYPE_STRING = "image";
024:
025:            protected URL imageURL;
026:            protected ImageIcon imageIcon;
027:            protected ImageIcon hiddenImageIcon;
028:
029:            /**
030:             * Constructor. We make sure the value (a file path) is an absolute file
031:             * path.
032:             *
033:             * @param id the unique identifier for the new field
034:             * @param report the report containing this line
035:             * @param section the section containing this line
036:             * @param value the value; a file path string
037:             * @param visible show/hide flag
038:             */
039:            public ImageField(Long id, Report report, Section section,
040:                    Object value, boolean visible) {
041:                super (id, report, section, null, visible);
042:                setValue(value);
043:            }
044:
045:            /**
046:             * Always returns the bounds height.
047:             */
048:            public double getOutputHeight() {
049:                return bounds.height;
050:            }
051:
052:            /**
053:             * Returns the image URL.
054:             *
055:             * @return the image URL
056:             */
057:            public URL getImageURL() {
058:                return imageURL;
059:            }
060:
061:            /**
062:             * Returns the image icon, visually dimmed if the field is hidden.
063:             *
064:             * @return the image icon, dimmed if the field is not visible
065:             */
066:            public ImageIcon getImageIcon() {
067:                if (isVisible())
068:                    return getVisibleImageIcon();
069:                else
070:                    return getHiddenImageIcon();
071:            }
072:
073:            /**
074:             * Returns the image icon.
075:             *
076:             * @return the image icon
077:             */
078:            public ImageIcon getVisibleImageIcon() {
079:                if (imageIcon == null && value != null)
080:                    imageIcon = new ImageIcon(getImageURL());
081:                return imageIcon;
082:            }
083:
084:            /**
085:             * Returns a dimmed version of the the image icon.
086:             *
087:             * @return a dimmed version of the the image icon
088:             */
089:            public ImageIcon getHiddenImageIcon() {
090:                if (hiddenImageIcon == null && value != null && canLoad()) {
091:                    ImageIcon ii = getVisibleImageIcon();
092:                    if (ii != null) {
093:                        hiddenImageIcon = new ImageIcon(GrayFilter
094:                                .createDisabledImage(ii.getImage()));
095:                    }
096:                }
097:                return hiddenImageIcon;
098:            }
099:
100:            /**
101:             * Sets our value and image URL.
102:             * <p>
103:             * 
104:             */
105:            public void setValue(Object newValue) {
106:                imageIcon = null;
107:                String str = newValue.toString();
108:
109:                // If the string is not a URL, add "file:" to the beginning of the
110:                // string.
111:                if (str.indexOf(":/") == -1 && !str.startsWith("file:"))
112:                    str = "file:" + str;
113:
114:                try {
115:                    imageURL = (str == null || str.length() == 0) ? null
116:                            : new URL(str);
117:                    super .setValue(newValue); // Notify observers
118:                } catch (MalformedURLException e) {
119:                    ErrorHandler.error(e);
120:                }
121:            }
122:
123:            public boolean canLoad() {
124:                return getVisibleImageIcon() != null
125:                        && getVisibleImageIcon().getImageLoadStatus() == MediaTracker.COMPLETE;
126:            }
127:
128:            public FieldWidget makeWidget(SectionWidget sw) {
129:                return new ImageFieldWidget(sw, this );
130:            }
131:
132:            public String dragString() {
133:                return typeString() + ":" + value;
134:            }
135:
136:            public String typeString() {
137:                return TYPE_STRING;
138:            }
139:
140:            public String formulaString() {
141:                return "{" + value + "}";
142:            }
143:
144:            public String toString() {
145:                if (!visible)
146:                    return null;
147:
148:                Object v = getValue();
149:                return v == null ? "" : v.toString();
150:            }
151:
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.