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


001:        /* 
002:         * $Id: JGraphpadBusinessObject.java,v 1.4 2005/09/11 08:50:27 gaudenz Exp $
003:         * Copyright (c) 2001-2005, Gaudenz Alder
004:         * 
005:         * All rights reserved.
006:         * 
007:         * See LICENSE file for license details. If you are unable to locate
008:         * this file please contact info (at) jgraph (dot) com.
009:         */
010:        package com.jgraph.pad.graph;
011:
012:        import java.awt.Component;
013:        import java.io.Serializable;
014:        import java.util.Hashtable;
015:        import java.util.Iterator;
016:        import java.util.Map;
017:
018:        /**
019:         * User object with a dynamic set of properties in a hashtable. The property
020:         * under {@link #valueKey} is used in {@link #toString()} to represent the
021:         * object as a string. This object supports values of type
022:         * {@link JGraphpadRichTextValue}.
023:         * 
024:         * @see JGraphpadGraphModel
025:         */
026:        public class JGraphpadBusinessObject implements  Cloneable, Serializable {
027:
028:            /**
029:             * Key to use for converting this object to a string.
030:             */
031:            public static String valueKey = "value";
032:
033:            /**
034:             * Holds the properties as (key, value) pairs.
035:             */
036:            protected Map properties = new Hashtable();
037:
038:            /**
039:             * Constructs a business object with an empty string as its value.
040:             */
041:            public JGraphpadBusinessObject() {
042:                this ("");
043:            }
044:
045:            /**
046:             * Constructs a business object with the specified value.
047:             * 
048:             * @param value
049:             *            The value of the new object.
050:             */
051:            public JGraphpadBusinessObject(Object value) {
052:                setValue(value);
053:            }
054:
055:            /**
056:             * Returns the properties.
057:             * 
058:             * @return Returns the properties.
059:             */
060:            public Map getProperties() {
061:                return properties;
062:            }
063:
064:            /**
065:             * Sets the properties.
066:             * 
067:             * @param properties
068:             *            The properties to set.
069:             */
070:            public void setProperties(Map properties) {
071:                this .properties = properties;
072:            }
073:
074:            /**
075:             * Sets the value for {@link #valueKey}.
076:             * 
077:             * @param value
078:             *            The value to set.
079:             */
080:            public void setValue(Object value) {
081:                putProperty(valueKey, value);
082:            }
083:
084:            /**
085:             * Returns the value for {@link #valueKey}.
086:             * 
087:             * @return Returns the value.
088:             */
089:            public Object getValue() {
090:                return getProperty(valueKey);
091:            }
092:
093:            /**
094:             * Returns true if the value is a rich text value.
095:             * 
096:             * @return Returns true if value is rich text.
097:             */
098:            public boolean isRichText() {
099:                return getValue() instanceof  JGraphpadRichTextValue;
100:            }
101:
102:            /**
103:             * Returns true if the value is a component.
104:             * 
105:             * @return Returns true if value is a component.
106:             */
107:            public boolean isComponent() {
108:                return getValue() instanceof  Component;
109:            }
110:
111:            /**
112:             * Sets the property under the specified key.
113:             * 
114:             * @param key
115:             *            They key of the property.
116:             * @param value
117:             *            The value of the property.
118:             * @return Returns the previous value.
119:             */
120:            public Object putProperty(Object key, Object value) {
121:                if (key != null && value != null)
122:                    return properties.put(key, value);
123:                return null;
124:            }
125:
126:            /**
127:             * Returns the property under the specified key.
128:             * 
129:             * @param key
130:             *            The key of the property.
131:             * @return Returns the specified property.
132:             */
133:            public Object getProperty(Object key) {
134:                if (key != null)
135:                    return properties.get(key);
136:                return null;
137:            }
138:
139:            /**
140:             * Hook for subclassers to create a custom tooltip for this user object.
141:             * This is used in {@link JGraphpadGraph#getToolTipForCell(Object)}.
142:             * 
143:             * @return Returns a tooltip for the user object.
144:             */
145:            public String getTooltip() {
146:                String html = "";
147:                String title = toString();
148:                if (title.length() > 0)
149:                    html += "<strong>" + chopString(title, 20)
150:                            + "</strong><br>";
151:                Iterator it = getProperties().entrySet().iterator();
152:                while (it.hasNext()) {
153:                    Map.Entry element = (Map.Entry) it.next();
154:                    if (!element.getKey().equals(valueKey))
155:                        html += element.getKey()
156:                                + ": "
157:                                + chopString(
158:                                        String.valueOf(element.getValue()), 20)
159:                                + "<br>";
160:                }
161:                return html;
162:            }
163:
164:            /**
165:             * A helper method that crops string to the specified length, adding 3 dots
166:             * if there were more characters.
167:             * 
168:             * @return The chopped string.
169:             */
170:            protected String chopString(String s, int max) {
171:                if (s != null) {
172:                    if (s.length() > max)
173:                        s = s.substring(0, max) + "...";
174:                }
175:                return s;
176:            }
177:
178:            /**
179:             * Returns the string representation of the value or an empty string if no
180:             * value exists.
181:             * 
182:             * @return Returns the value as a string.
183:             */
184:            public String toString() {
185:                Object value = getValue();
186:                if (value != null)
187:                    return String.valueOf(value);
188:                return "";
189:            }
190:
191:            /**
192:             * Returns a clone of the object. Note: The properties are not cloned, only
193:             * a clone of the containing map is used. As a special case, if the user
194:             * object is a JSlider or a JTree then a new instance will be put in place
195:             * of the old instance.
196:             * 
197:             * @return Returns a clone of this object.
198:             */
199:            public Object clone() {
200:                JGraphpadBusinessObject clone;
201:                try {
202:                    clone = (JGraphpadBusinessObject) super .clone();
203:                } catch (CloneNotSupportedException e) {
204:                    clone = new JGraphpadBusinessObject();
205:                }
206:                clone.setProperties(new Hashtable(getProperties()));
207:                if (isComponent()) {
208:                    Object value = getValue();
209:                    if (value instanceof  JGraphpadHeavyweightRenderer) {
210:                        clone.setValue(((JGraphpadHeavyweightRenderer) value)
211:                                .clone());
212:                    }
213:                }
214:                return clone;
215:            }
216:
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.