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


001:        /*
002:         * (C) Copyright IBM Corp. 1998-2004.  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.styledtext;
014:
015:        import com.ibm.richtext.textlayout.attributes.AttributeMap;
016:        import com.ibm.richtext.textlayout.attributes.AttributeSet;
017:
018:        /**
019:         * StyleModifier is the base class for operations on AttributeMap.  To implement
020:         * an operation on AttributeMap, subclass StyleModifier and override
021:         * <code>modifyStyle</code>.  StyleModifiers are used by MText.
022:         * <p>
023:         * For convenience, this class contains factory methods which will create a
024:         * StyleModifier for
025:         * certain common operations: attribute union, attribute removal, and AttributeMap
026:         * replacement.
027:         * @see AttributeMap
028:         * @see AttributeSet
029:         * @see MText
030:         */
031:        /*
032:         * {jbr} StyleModifier is not the best name for this class - styles are immutable and never
033:         * really modified.
034:         */
035:        public class StyleModifier {
036:            static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
037:
038:            /**
039:             * Create a StyleModifier.
040:             */
041:            protected StyleModifier() {
042:            }
043:
044:            /**
045:             * Return the result of this StyleModifier's operation on the given style.
046:             * Default implementation just returns the given style.
047:             * @param style the AttributeMap to perform the operation on
048:             */
049:            public AttributeMap modifyStyle(AttributeMap style) {
050:                return style;
051:            }
052:
053:            /**
054:             * A StyleModifier which simply returns the given style.
055:             */
056:            public static final StyleModifier IDENTITY = new StyleModifier();
057:
058:            /**
059:             * Create a StyleModifier whose operation is
060:             * <code>style.addAttributes(s)</code>,
061:             * where <code>style</code> is the AttributeMap passed to
062:             * <code>modifyStyle</code>.
063:             * @param s the AttributeMap to union with
064:             * @return a StyleModifier for this operation
065:             */
066:            public static StyleModifier createAddModifier(AttributeMap s) {
067:
068:                return new StyleAddModifier(s);
069:            }
070:
071:            /**
072:             * Create a StyleModifier whose operation is
073:             * <code>style.addAttribute(key, value)</code>,
074:             * where <code>style</code> is the AttributeMap passed to
075:             * <code>modifyStyle</code>.
076:             * @param key the key to add
077:             * @param value the value to add
078:             * @return a StyleModifier for this operation
079:             */
080:            public static StyleModifier createAddModifier(Object key,
081:                    Object value) {
082:
083:                return new AttributeAddModifier(key, value);
084:            }
085:
086:            /**
087:             * Create a StyleModifier whose operation returns <code>s</code>,
088:             * ignoring the parameter to <code>modifyStyle</code>.
089:             * @param s the AttributeMap which will replace any other AttributeMap
090:             * @return a StyleModifier for this operation
091:             */
092:            public static StyleModifier createReplaceModifier(AttributeMap s) {
093:
094:                return new StyleReplaceModifier(s);
095:            }
096:
097:            /**
098:             * Create a StyleModifier whose operation is
099:             * <code>style.removeAttributes(s)</code>,
100:             * where <code>style</code> is the AttributeMap passed to
101:             * <code>modifyStyle</code>.
102:             * @param s the AttributeSet of attributes to remove
103:             * @return a StyleModifier for this operation
104:             */
105:            public static StyleModifier createRemoveModifier(AttributeSet s) {
106:
107:                return new StyleRemoveModifier(s);
108:            }
109:
110:            static final class AttributeAddModifier extends StyleModifier {
111:
112:                private Object fKey;
113:                private Object fValue;
114:
115:                public AttributeAddModifier(Object key, Object value) {
116:
117:                    fKey = key;
118:                    fValue = value;
119:                }
120:
121:                public AttributeMap modifyStyle(AttributeMap style) {
122:
123:                    return style.addAttribute(fKey, fValue);
124:                }
125:            }
126:
127:            /**
128:             * Create this with the styles to add.  These styles will add to and override any already
129:             * present in the style passed to modifyStyle.
130:             */
131:            static final class StyleAddModifier extends StyleModifier {
132:                private AttributeMap fStyle;
133:
134:                public StyleAddModifier(AttributeMap style) {
135:                    if (style == null) {
136:                        throw new IllegalArgumentException("style is null");
137:                    }
138:                    fStyle = style;
139:                }
140:
141:                public AttributeMap modifyStyle(AttributeMap style) {
142:                    return style.addAttributes(fStyle);
143:                }
144:            }
145:
146:            /**
147:             * Create this with the styles to replace.  All style runs will have only these
148:             * styles.
149:             */
150:            static final class StyleReplaceModifier extends StyleModifier {
151:                private AttributeMap fStyle;
152:
153:                public StyleReplaceModifier(AttributeMap style) {
154:                    if (style == null) {
155:                        throw new IllegalArgumentException("style is null");
156:                    }
157:                    fStyle = style;
158:                }
159:
160:                public AttributeMap modifyStyle(AttributeMap style) {
161:                    return fStyle;
162:                }
163:            }
164:
165:            static final class StyleRemoveModifier extends StyleModifier {
166:
167:                private AttributeSet fRemoveSet;
168:
169:                public StyleRemoveModifier(AttributeSet removeSet) {
170:
171:                    if (removeSet == null) {
172:                        throw new IllegalArgumentException("set is null");
173:                    }
174:                    fRemoveSet = removeSet;
175:                }
176:
177:                public AttributeMap modifyStyle(AttributeMap style) {
178:
179:                    return style.removeAttributes(fRemoveSet);
180:                }
181:            }
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.