Source Code Cross Referenced for TabStop.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 java.io.Externalizable;
016:        import java.io.ObjectInput;
017:        import java.io.ObjectOutput;
018:        import java.io.IOException;
019:
020:        /**
021:         * TabStop represents a position on a tab ruler.  Each tab stop has a
022:         * position, giving its location on the ruler, and one of several
023:         * types.  The type determines how a segment controled by this TabStop
024:         * is positioned on a line:
025:         * <ul>
026:         * <li><code>kLeading</code> - the leading edge of the segment is aligned to
027:         *     the TabStop's position</li>
028:         * <li><code>kCenter</code> - the segment is centered on this TabStop's
029:         *     position</li>
030:         * <li><code>kTrailing</code> - the trailing edge of the segment is aligned to
031:         *     the TabStop's position</li>
032:         * <li><code>kDecimal</code> - the first decimal in the segment is aligned to
033:         *     the TabStop's position</li>
034:         * <li><code>kAuto</code> - semantically the same as <code>kLeading</code>.
035:         *     Used by tab rulers to indicate that all subsequent tab stops
036:         *     will be at autospaced intervals.</li>
037:         * </ul>
038:         * @see MTabRuler
039:         */
040:        public final class TabStop implements  Externalizable {
041:            static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
042:            private static final int CURRENT_VERSION = 1;
043:            private static final long serialVersionUID = 22356934;
044:
045:            private byte fType; // left, center, right, decimal
046:            private int fPosition; // tab stop position from line origin.
047:
048:            /**
049:             * A TabStop with this type aligns its segment's leading edge
050:             * to the TabStop's position.
051:             */
052:            public static final byte kLeading = 0;
053:
054:            /**
055:             * A TabStop with this type aligns its segment's center
056:             * to the TabStop's position.
057:             */
058:            public static final byte kCenter = 1;
059:
060:            /**
061:             * A TabStop with this type aligns its segment's trailing edge
062:             * to the TabStop's position.
063:             */
064:            public static final byte kTrailing = 2;
065:
066:            /**
067:             * A TabStop with this type aligns its segment's first decimal
068:             * to the TabStop's position.
069:             */
070:            public static final byte kDecimal = 3;
071:
072:            /**
073:             * A TabStop with this type aligns its segment's leading edge
074:             * to the TabStop's position.  After a TabStop of this type,
075:             * all tabs are at autospace intervals.  Usually, clients will
076:             * not construct TabStops with this type.
077:             */
078:            public static final byte kAuto = 4;
079:
080:            /**
081:             * Create a TabStop with position 0 and type <code>kLeading</code>.
082:             */
083:            public TabStop() {
084:
085:                this (0, kLeading);
086:            }
087:
088:            /**
089:             * Create a TabStop with the given position and type.
090:             * @param position the TabStop's position
091:             * @param type the TabStop's type.  Must be one of constants
092:             *      in this class.
093:             */
094:            public TabStop(int position, byte type) {
095:
096:                if (type < kLeading || type > kAuto) {
097:                    throw new IllegalArgumentException("Invalid tab type");
098:                }
099:
100:                fPosition = position;
101:                fType = type;
102:            }
103:
104:            public void readExternal(ObjectInput in) throws IOException,
105:                    ClassNotFoundException {
106:
107:                int version = in.readInt();
108:                if (version != CURRENT_VERSION) {
109:                    throw new IOException("Invalid version of TabStop.");
110:                }
111:                fPosition = in.readInt();
112:                fType = in.readByte();
113:            }
114:
115:            public void writeExternal(ObjectOutput out) throws IOException {
116:
117:                out.writeInt(CURRENT_VERSION);
118:                out.writeInt(fPosition);
119:                out.writeByte(fType);
120:            }
121:
122:            /**
123:             * Compare this to another Object.  TabStops are equal if
124:             * their position and type are the same.
125:             */
126:            public boolean equals(Object rhs) {
127:                if (rhs == null) {
128:                    return false;
129:                }
130:
131:                TabStop rhsTab;
132:                try {
133:                    rhsTab = (TabStop) rhs;
134:                } catch (ClassCastException e) {
135:                    return false;
136:                }
137:
138:                return fType == rhsTab.fType && fPosition == rhsTab.fPosition;
139:            }
140:
141:            /**
142:             * Return the hash code for this TabStop.  The hash code is
143:             * <code>position << type</code>.
144:             */
145:            public int hashCode() {
146:
147:                return fPosition << fType;
148:            }
149:
150:            public String toString() {
151:                char typeChar;
152:                switch (fType) {
153:                case kLeading:
154:                    typeChar = 'L';
155:                    break;
156:                case kCenter:
157:                    typeChar = 'C';
158:                    break;
159:                case kTrailing:
160:                    typeChar = 'R';
161:                    break;
162:                case kDecimal:
163:                    typeChar = 'D';
164:                    break;
165:                case kAuto:
166:                    typeChar = 'A';
167:                    break;
168:                default:
169:                    typeChar = '?';
170:                    break;
171:                }
172:                return "TabStop[" + Integer.toString(fPosition) + typeChar
173:                        + ']';
174:            }
175:
176:            /**
177:             * Return the type of this TabStop.  Will be one of the constants
178:             * in this class.
179:             */
180:            public byte getType() {
181:                return fType;
182:            }
183:
184:            /**
185:             * Return the position of this TabStop.
186:             */
187:            public int getPosition() {
188:                return fPosition;
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.