Source Code Cross Referenced for ImportedBeanInfo.java in  » Swing-Library » abeille-forms-designer » com » jeta » swingbuilder » store » 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 » abeille forms designer » com.jeta.swingbuilder.store 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005 Jeff Tassin
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package com.jeta.swingbuilder.store;
020:
021:        import java.awt.Graphics2D;
022:        import java.awt.image.BufferedImage;
023:        import java.io.Externalizable;
024:        import java.io.IOException;
025:
026:        import javax.swing.Icon;
027:        import javax.swing.ImageIcon;
028:
029:        import com.jeta.forms.store.memento.IconMemento;
030:
031:        /**
032:         * Represents an imported java bean used in the builder.
033:         * 
034:         * @author Jeff Tassin
035:         */
036:        public class ImportedBeanInfo implements  Externalizable,
037:                RegisteredBean, Comparable, Cloneable {
038:            static final long serialVersionUID = -6517746440901771760L;
039:
040:            public static final int VERSION = 2;
041:
042:            /**
043:             * The class name of the imported java bean
044:             */
045:            private String m_bean_name;
046:
047:            /**
048:             * Used to store the icon for this bean
049:             */
050:            private IconMemento m_icon_memento;
051:
052:            /**
053:             * Flag that indicates if this bean is scrollable
054:             */
055:            private boolean m_scrollable;
056:
057:            /**
058:             * This is a scaled version of the m_icon_memento icon. It is scaled to
059:             * 16x16 pixels if the icon_memento is not exactly 16x16. We do this so it
060:             * will fit on the toolbar.
061:             */
062:            private transient ImageIcon m_scaled_icon;
063:
064:            /**
065:             * ctor - for serialization
066:             */
067:            public ImportedBeanInfo() {
068:
069:            }
070:
071:            /**
072:             * ctor
073:             */
074:            public ImportedBeanInfo(String beanName, boolean scrollable) {
075:                m_bean_name = beanName;
076:                m_scrollable = scrollable;
077:            }
078:
079:            /**
080:             * @return the icon
081:             */
082:            public Icon getIcon() {
083:                Icon result = null;
084:                if (m_scaled_icon == null) {
085:                    if (m_icon_memento != null) {
086:                        ImageIcon ii = m_icon_memento.getImageIcon();
087:                        if (ii != null) {
088:                            if ((ii.getIconWidth() == 16)
089:                                    && (ii.getIconHeight() == 16)) {
090:                                m_scaled_icon = ii;
091:                            } else {
092:                                // we need to scale the image to fit 16x16 pixels if it
093:                                // is too big or too small
094:                                BufferedImage bimage = new BufferedImage(16,
095:                                        16, BufferedImage.TYPE_INT_RGB);
096:                                Graphics2D bg = bimage.createGraphics();
097:                                bg.drawImage(ii.getImage(), 0, 0, 16, 16, null);
098:                                bg.dispose();
099:                                m_scaled_icon = new ImageIcon(bimage);
100:                            }
101:                        }
102:                    }
103:                }
104:                return m_scaled_icon;
105:            }
106:
107:            public String getDescription() {
108:                return getBeanName();
109:            }
110:
111:            public String getClassName() {
112:                return getBeanName();
113:            }
114:
115:            /**
116:             * @return the class name of the imported java bean
117:             */
118:            public String getBeanName() {
119:                return m_bean_name;
120:            }
121:
122:            /**
123:             * @return true if this component is scrollable
124:             */
125:            public boolean isScrollable() {
126:                return m_scrollable;
127:            }
128:
129:            /**
130:             * Sets the class name of the imported java bean
131:             */
132:            public void setBeanName(String name) {
133:                m_bean_name = name;
134:            }
135:
136:            /**
137:             * Sets the icon memento for this object
138:             */
139:            public void setIconMemento(IconMemento im) {
140:                m_icon_memento = im;
141:                m_scaled_icon = null;
142:            }
143:
144:            /**
145:             */
146:            public void setScrollable(boolean scrollable) {
147:                m_scrollable = scrollable;
148:            }
149:
150:            public boolean equals(Object obj) {
151:                if (this  == obj)
152:                    return true;
153:
154:                if (null == obj)
155:                    return false;
156:
157:                if (!(obj instanceof  ImportedBeanInfo))
158:                    return false;
159:
160:                ImportedBeanInfo mObj = (ImportedBeanInfo) obj;
161:
162:                if ((m_scrollable == mObj.m_scrollable)
163:                        && ((null == m_bean_name && null == mObj.m_bean_name)
164:                                || (m_bean_name != null && m_bean_name
165:                                        .equals(mObj.m_bean_name)) || (mObj.m_bean_name != null && mObj.m_bean_name
166:                                .equals(m_bean_name)))
167:                        && ((null == m_icon_memento && null == mObj.m_icon_memento)
168:                                || (m_icon_memento != null && m_icon_memento
169:                                        .equals(mObj.m_icon_memento)) || (mObj.m_icon_memento != null && mObj.m_icon_memento
170:                                .equals(m_icon_memento)))) {
171:                    return true;
172:                } else {
173:                    return false;
174:                }
175:            }
176:
177:            public int compareTo(Object o) throws ClassCastException {
178:                if (!(o instanceof  ImportedBeanInfo))
179:                    throw new ClassCastException(
180:                            "An ImportedBeanInfo object was expected.");
181:                ImportedBeanInfo beanInfo = (ImportedBeanInfo) o;
182:                return this .m_bean_name.compareTo(beanInfo.getBeanName());
183:            }
184:
185:            public Object clone() {
186:                ImportedBeanInfo other = null;
187:                try {
188:                    other = (ImportedBeanInfo) super .clone();
189:                    //
190:                    other.m_bean_name = m_bean_name;
191:                    other.m_scrollable = m_scrollable;
192:                    //
193:                    m_scaled_icon = null;
194:                    getIcon();
195:                    other.m_scaled_icon = m_scaled_icon;
196:                    m_scaled_icon = null;
197:                    getIcon();
198:                    //
199:                    other.m_icon_memento = (m_icon_memento != null ? (IconMemento) m_icon_memento
200:                            .clone()
201:                            : (IconMemento) null);
202:                } catch (CloneNotSupportedException e) {
203:                    // this shouldn't happen, since we are Cloneable
204:                    throw new InternalError();
205:                }
206:                //
207:                return other;
208:            }
209:
210:            /**
211:             * Externalizable Implementation
212:             */
213:            public void readExternal(java.io.ObjectInput in)
214:                    throws ClassNotFoundException, IOException {
215:                int version = in.readInt();
216:                m_bean_name = (String) in.readObject();
217:                m_icon_memento = (IconMemento) in.readObject();
218:                if (version >= 2)
219:                    m_scrollable = in.readBoolean();
220:            }
221:
222:            /**
223:             * Externalizable Implementation
224:             */
225:            public void writeExternal(java.io.ObjectOutput out)
226:                    throws IOException {
227:                out.writeInt(VERSION);
228:                out.writeObject(m_bean_name);
229:                out.writeObject(m_icon_memento);
230:                out.writeBoolean(m_scrollable);
231:            }
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.