Source Code Cross Referenced for TextPanelSettings.java in  » Internationalization-Localization » icu4j » com » ibm » richtext » textpanel » 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 » Internationalization Localization » icu4j » com.ibm.richtext.textpanel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * (C) Copyright IBM Corp. 1998-2005.  All Rights Reserved.
003:         *
004:         * The program is provided "as is" without any warranty express or
005:         * implied, including the warranty of non-infringement and the implied
006:         * warranties of merchantibility and fitness for a particular purpose.
007:         * IBM will not be liable for any damages suffered by you as a result
008:         * of using the Program. In no event will IBM be liable for any
009:         * special, indirect or consequential damages or lost profits even if
010:         * IBM has been advised of the possibility of their occurrence. IBM
011:         * will not be liable for any third party claims against you.
012:         */
013:        package com.ibm.richtext.textpanel;
014:
015:        import java.awt.Color;
016:        import java.io.Serializable;
017:        import java.util.Hashtable;
018:
019:        import com.ibm.richtext.textlayout.attributes.AttributeMap;
020:        import com.ibm.richtext.textlayout.attributes.TextAttribute;
021:        import com.ibm.richtext.styledtext.StandardTabRuler;
022:
023:        /**
024:         * This class contains settings used when constructing an MTextPanel.
025:         * The settings controled by this class include:
026:         * <ul>
027:         * <li>whether the text in the MTextPanel can be scrolled</li>
028:         * <li>whether scroll bars in the MTextPanel are visible</li>
029:         * <li>whether the text in the MTextPanel can be selected</li>
030:         * <li>whether the text in the MTextPanel can be edited</li>
031:         * <li>whether lines of text wrap to the MTextPanel's width, or
032:         * only end at paragraph separators</li>
033:         * <li>the default values for unspecified styles</li>
034:         * </ul>
035:         * Some settings are dependent on others.  Scroll bars are visible
036:         * only if the text is scrollable.  Also, text which is not editable
037:         * if it is not selectable.
038:         * <p>
039:         *
040:         * @see MTextPanel
041:         */
042:        public final class TextPanelSettings implements  Cloneable, Serializable {
043:
044:            static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
045:
046:            static final long serialVersionUID = -4089186663018707478L;
047:
048:            private static final AttributeMap DEFAULTS;
049:
050:            static {
051:                final Float floatZero = new Float(0.0f);
052:
053:                Hashtable defaults = new Hashtable();
054:                defaults.put(TextAttribute.FAMILY, "Serif");
055:                defaults.put(TextAttribute.WEIGHT, new Float(1.0f));
056:                defaults.put(TextAttribute.POSTURE, floatZero);
057:                defaults.put(TextAttribute.SIZE, new Float(18.0f));
058:                defaults.put(TextAttribute.SUPERSCRIPT, new Integer(0));
059:                defaults.put(TextAttribute.FOREGROUND, Color.black);
060:                defaults.put(TextAttribute.UNDERLINE, new Integer(-1));
061:                defaults.put(TextAttribute.STRIKETHROUGH, Boolean.FALSE);
062:
063:                defaults.put(TextAttribute.EXTRA_LINE_SPACING, floatZero);
064:                defaults.put(TextAttribute.FIRST_LINE_INDENT, floatZero);
065:                defaults.put(TextAttribute.MIN_LINE_SPACING, floatZero);
066:                defaults.put(TextAttribute.LINE_FLUSH,
067:                        TextAttribute.FLUSH_LEADING);
068:                defaults.put(TextAttribute.LEADING_MARGIN, floatZero);
069:                defaults.put(TextAttribute.TRAILING_MARGIN, floatZero);
070:                defaults.put(TextAttribute.TAB_RULER, new StandardTabRuler());
071:
072:                DEFAULTS = new AttributeMap(defaults);
073:            }
074:
075:            private boolean fScrollable = true;
076:            private boolean fScrollBarsVisible = true;
077:            private boolean fSelectable = true;
078:            private boolean fEditable = true;
079:            private boolean fWraps = true;
080:            private AttributeMap fDefaultValues = DEFAULTS;
081:
082:            /**
083:             * Create a TextPanelSettings instance with all settings
084:             * set to true.
085:             */
086:            public TextPanelSettings() {
087:            }
088:
089:            /**
090:             * Return a new TextPanelSettings instance with the
091:             * same settings as this.
092:             * @return a new TextPanelSettings instance
093:             */
094:            public Object clone() {
095:
096:                TextPanelSettings rhs = new TextPanelSettings();
097:
098:                rhs.fScrollable = fScrollable;
099:                rhs.fScrollBarsVisible = fScrollBarsVisible;
100:                rhs.fSelectable = fSelectable;
101:                rhs.fEditable = fEditable;
102:                rhs.fWraps = fWraps;
103:                rhs.fDefaultValues = fDefaultValues;
104:
105:                return rhs;
106:            }
107:
108:            /**
109:             * Return the scrollable setting, which determines whether text
110:             * in an MTextPanel can be scrolled.
111:             * @return the scrollable setting
112:             */
113:            public boolean getScrollable() {
114:
115:                return fScrollable;
116:            }
117:
118:            /**
119:             * Set the scrollable setting.
120:             * @param scrollable the scrollable setting.  If false,
121:             * the scrollBarsVisible setting is also set to false.
122:             */
123:            public void setScrollable(boolean scrollable) {
124:
125:                fScrollable = scrollable;
126:                fScrollBarsVisible &= scrollable;
127:            }
128:
129:            /**
130:             * Return the scrollBarsVisible setting, which determines whether
131:             * scroll bars in an MTextPanel are visible.
132:             * @return the scrollBarsVisible setting
133:             */
134:            public boolean getScrollBarsVisible() {
135:
136:                return fScrollBarsVisible;
137:            }
138:
139:            /**
140:             * Set the scrollBarsVisible setting.
141:             * @param vis the scrollBarsVisible setting.  If true,
142:             * the scrollable setting is also set to true.
143:             */
144:            public void setScrollBarsVisible(boolean vis) {
145:
146:                fScrollBarsVisible = vis;
147:                fScrollable |= vis;
148:            }
149:
150:            /**
151:             * Return the selectable setting, which determines whether
152:             * text in an MTextPanel can be selected.
153:             * @return the selectable setting
154:             */
155:            public boolean getSelectable() {
156:
157:                return fSelectable;
158:            }
159:
160:            /**
161:             * Set the selectable setting.
162:             * @param selectable the selectable setting.  If false,
163:             * the editable setting is also set to false.
164:             */
165:            public void setSelectable(boolean selectable) {
166:
167:                fSelectable = selectable;
168:                fEditable &= selectable;
169:            }
170:
171:            /**
172:             * Return the editable setting, which determines whether
173:             * text in an MTextPanel can be edited.
174:             * @return the editable setting
175:             */
176:            public boolean getEditable() {
177:
178:                return fEditable;
179:            }
180:
181:            /**
182:             * Set the editable setting.
183:             * @param editable the editable setting.  If true,
184:             * the selectable setting is also set to true.
185:             */
186:            public void setEditable(boolean editable) {
187:
188:                fEditable = editable;
189:                fSelectable |= editable;
190:            }
191:
192:            /**
193:             * Return the wraps setting, which determines whether
194:             * lines of text wrap to the length of the MTextPanel,
195:             * or only at paragraph separators.
196:             * @return the wraps setting
197:             */
198:            public boolean getWraps() {
199:
200:                return fWraps;
201:            }
202:
203:            /**
204:             * Set the wraps setting.
205:             * @param wraps the wraps setting
206:             */
207:            public void setWraps(boolean wraps) {
208:
209:                fWraps = wraps;
210:            }
211:
212:            /**
213:             * Return the AttributeMap of default values for certain keys.
214:             * When a key in this AttributeMap is not specified, its value
215:             * is taken from this AttributeMap.
216:             * @return the AttributeMap of default values
217:             * @see MTextPanel#getDefaultValues
218:             */
219:            public AttributeMap getDefaultValues() {
220:
221:                return fDefaultValues;
222:            }
223:
224:            /**
225:             * Add the key-value pairs in the given AttributeMap to the
226:             * default values.  If a key does not appear in the given
227:             * AttributeMap, its value in the default value map is
228:             * unchanged.
229:             * @param map an AttributeMap containing new default values
230:             */
231:            public void addDefaultValues(AttributeMap map) {
232:
233:                fDefaultValues = fDefaultValues.addAttributes(map);
234:            }
235:
236:            /**
237:             * Compare this to another Object.  This is equal
238:             * to another Object if the other Object is a
239:             * TextPanelSettings instance with the same
240:             * settings as this one.
241:             * @param rhs the Object to compare to
242:             */
243:            public boolean equals(Object rhs) {
244:
245:                if (rhs == this ) {
246:                    return true;
247:                }
248:
249:                if (rhs == null) {
250:                    return false;
251:                }
252:
253:                TextPanelSettings other;
254:                try {
255:                    other = (TextPanelSettings) rhs;
256:                } catch (ClassCastException e) {
257:                    return false;
258:                }
259:
260:                return other.fScrollable == this .fScrollable
261:                        && other.fScrollBarsVisible == this .fScrollBarsVisible
262:                        && other.fSelectable == this .fSelectable
263:                        && other.fEditable == this .fEditable
264:                        && other.fWraps == this .fWraps
265:                        && other.fDefaultValues.equals(this .fDefaultValues);
266:            }
267:
268:            /**
269:             * Return the hash code for this Object.
270:             * @return the hash code for this Object
271:             */
272:            public int hashCode() {
273:
274:                int code = fDefaultValues.hashCode();
275:                code = code * 2 + (fScrollable ? 1 : 0);
276:                code = code * 2 + (fScrollBarsVisible ? 1 : 0);
277:                code = code * 2 + (fSelectable ? 1 : 0);
278:                code = code * 2 + (fEditable ? 1 : 0);
279:                code = code * 2 + (fWraps ? 1 : 0);
280:
281:                return code;
282:            }
283:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.