Source Code Cross Referenced for PresentationTextObject.java in  » Graphic-Library » fop » org » apache » fop » render » afp » modca » 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 » fop » org.apache.fop.render.afp.modca 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /* $Id: PresentationTextObject.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020:        package org.apache.fop.render.afp.modca;
021:
022:        import java.awt.Color;
023:        import java.io.IOException;
024:        import java.io.OutputStream;
025:        import java.io.UnsupportedEncodingException;
026:        import java.util.ArrayList;
027:
028:        /**
029:         * The Presentation Text object is the data object used in document processing
030:         * environments for representing text which has been prepared for presentation.
031:         * Text, as used here, means an ordered string of characters, such as graphic
032:         * symbols, numbers, and letters, that are suitable for the specific purpose of
033:         * representing coherent information. Text which has been prepared for
034:         * presentation has been reduced to a primitive form through explicit
035:         * specification of the characters and their placement in the presentation
036:         * space. Control sequences which designate specific control functions may be
037:         * embedded within the text. These functions extend the primitive form by
038:         * applying specific characteristics to the text when it is presented. The
039:         * collection of the graphic characters and control codes is called Presentation
040:         * Text, and the object that contains the Presentation Text is called the
041:         * PresentationText object.
042:         *
043:         */
044:        public class PresentationTextObject extends AbstractNamedAFPObject {
045:
046:            /**
047:             * Default name for the presentation text object
048:             */
049:            private static final String DEFAULT_NAME = "PTO00001";
050:
051:            private PresentationTextData currentPresentationTextData = null;
052:
053:            private ArrayList presentationTextData = new ArrayList();
054:
055:            /**
056:             * Default constructor for the PresentationTextObject
057:             */
058:            public PresentationTextObject() {
059:
060:                this (DEFAULT_NAME);
061:
062:            }
063:
064:            /**
065:             * Construct a new PresentationTextObject for the specified name argument,
066:             * the name should be an 8 character identifier.
067:             */
068:            public PresentationTextObject(String name) {
069:
070:                super (name);
071:
072:            }
073:
074:            /**
075:             * Create the presentation text data for the byte array of data.
076:             *
077:             * @param fontNumber
078:             *            The font resource identifier.
079:             * @param x
080:             *            The x coordinate for the text data.
081:             * @param y
082:             *            The y coordinate for the text data.
083:             * @param col
084:             *            The text color.
085:             * @param vsci
086:             *            The variable space character increment.
087:             * @param ica
088:             *            The inter character increment.
089:             * @param data
090:             *            The text data to be created.
091:             */
092:            public void createTextData(int fontNumber, int x, int y, Color col,
093:                    int vsci, int ica, byte[] data) {
094:
095:                // Use a default orientation of zero
096:                createTextData(fontNumber, x, y, 0, col, vsci, ica, data);
097:
098:            }
099:
100:            /**
101:             * Create the presentation text data for the byte array of data.
102:             *
103:             * @param fontNumber
104:             *            The font resource identifier.
105:             * @param x
106:             *            The x coordinate for the text data.
107:             * @param y
108:             *            The y coordinate for the text data.
109:             * @param orientation
110:             *            The orientation of the text data.
111:             * @param col
112:             *            The text color.
113:             * @param vsci
114:             *            The variable space character increment.
115:             * @param ica
116:             *            The inter character adjustment.
117:             * @param data
118:             *            The text data to be created.
119:             */
120:            public void createTextData(int fontNumber, int x, int y,
121:                    int orientation, Color col, int vsci, int ica, byte[] data) {
122:
123:                if (currentPresentationTextData == null) {
124:                    startPresentationTextData();
125:                }
126:
127:                try {
128:
129:                    currentPresentationTextData.createTextData(fontNumber, x,
130:                            y, orientation, col, vsci, ica, data);
131:
132:                } catch (MaximumSizeExceededException msee) {
133:
134:                    endPresentationTextData();
135:                    createTextData(fontNumber, x, y, orientation, col, vsci,
136:                            ica, data);
137:
138:                }
139:
140:            }
141:
142:            /**
143:             * Drawing of lines using the starting and ending coordinates, thickness.
144:             *
145:             * @param x1
146:             *            The first x coordinate of the line.
147:             * @param y1
148:             *            The first y coordinate of the line.
149:             * @param x2
150:             *            The second x coordinate of the line.
151:             * @param y2
152:             *            The second y coordinate of the line.
153:             * @param thickness
154:             *            The thickness of the line.
155:             * @param col
156:             *            The text color.
157:             */
158:            public void createLineData(int x1, int y1, int x2, int y2,
159:                    int thickness, Color col) {
160:                // Default orientation
161:                createLineData(x1, y1, x2, y2, thickness, 0, col);
162:            }
163:
164:            /**
165:             * Drawing of lines using the starting and ending coordinates, thickness and
166:             * orientation arguments.
167:             *
168:             * @param x1
169:             *            The first x coordinate of the line.
170:             * @param y1
171:             *            The first y coordinate of the line.
172:             * @param x2
173:             *            The second x coordinate of the line.
174:             * @param y2
175:             *            The second y coordinate of the line.
176:             * @param thickness
177:             *            The thickness of the line.
178:             * @param orientation
179:             *            The orientation of the line.
180:             * @param col
181:             *            The text color.
182:             */
183:            public void createLineData(int x1, int y1, int x2, int y2,
184:                    int thickness, int orientation, Color col) {
185:
186:                if (currentPresentationTextData == null) {
187:                    startPresentationTextData();
188:                }
189:
190:                try {
191:
192:                    currentPresentationTextData.createLineData(x1, y1, x2, y2,
193:                            thickness, orientation, col);
194:
195:                } catch (MaximumSizeExceededException msee) {
196:
197:                    endPresentationTextData();
198:                    createLineData(x1, y1, x2, y2, thickness, orientation, col);
199:
200:                }
201:
202:            }
203:
204:            /**
205:             * Helper method to mark the start of the presentation text data
206:             */
207:            private void startPresentationTextData() {
208:
209:                if (presentationTextData.size() == 0) {
210:                    currentPresentationTextData = new PresentationTextData(true);
211:                } else {
212:                    currentPresentationTextData = new PresentationTextData();
213:                }
214:
215:                presentationTextData.add(currentPresentationTextData);
216:
217:            }
218:
219:            /**
220:             * Helper method to mark the end of the presentation text data
221:             */
222:            private void endPresentationTextData() {
223:
224:                currentPresentationTextData = null;
225:
226:            }
227:
228:            /**
229:             * Accessor method to write the AFP datastream for the PresentationTextObject.
230:             * @param os The stream to write to
231:             * @throws java.io.IOException
232:             */
233:            public void writeDataStream(OutputStream os) throws IOException {
234:
235:                writeStart(os);
236:
237:                writeObjectList(presentationTextData, os);
238:
239:                writeEnd(os);
240:
241:            }
242:
243:            public String getName() {
244:
245:                return _name;
246:
247:            }
248:
249:            /**
250:             * Helper method to write the start of the presenation text object.
251:             * @param os The stream to write to
252:             */
253:            private void writeStart(OutputStream os) throws IOException {
254:
255:                byte[] data = new byte[17];
256:
257:                data[0] = 0x5A; // Structured field identifier
258:                data[1] = 0x00; // Length byte 1
259:                data[2] = 0x10; // Length byte 2
260:                data[3] = (byte) 0xD3; // Structured field id byte 1
261:                data[4] = (byte) 0xA8; // Structured field id byte 2
262:                data[5] = (byte) 0x9B; // Structured field id byte 3
263:                data[6] = 0x00; // Flags
264:                data[7] = 0x00; // Reserved
265:                data[8] = 0x00; // Reserved
266:
267:                for (int i = 0; i < _nameBytes.length; i++) {
268:
269:                    data[9 + i] = _nameBytes[i];
270:
271:                }
272:
273:                os.write(data);
274:
275:            }
276:
277:            /**
278:             * Helper method to write the end of the presenation text object.
279:             * @param os The stream to write to
280:             */
281:            private void writeEnd(OutputStream os) throws IOException {
282:
283:                byte[] data = new byte[17];
284:
285:                data[0] = 0x5A; // Structured field identifier
286:                data[1] = 0x00; // Length byte 1
287:                data[2] = 0x10; // Length byte 2
288:                data[3] = (byte) 0xD3; // Structured field id byte 1
289:                data[4] = (byte) 0xA9; // Structured field id byte 2
290:                data[5] = (byte) 0x9B; // Structured field id byte 3
291:                data[6] = 0x00; // Flags
292:                data[7] = 0x00; // Reserved
293:                data[8] = 0x00; // Reserved
294:
295:                for (int i = 0; i < _nameBytes.length; i++) {
296:
297:                    data[9 + i] = _nameBytes[i];
298:
299:                }
300:
301:                os.write(data);
302:
303:            }
304:
305:            /**
306:             * A control sequence is a sequence of bytes that specifies a control
307:             * function. A control sequence consists of a control sequence introducer
308:             * and zero or more parameters. The control sequence can extend multiple
309:             * presentation text data objects, but must eventually be terminated. This
310:             * method terminates the control sequence.
311:             */
312:            public void endControlSequence() {
313:
314:                if (currentPresentationTextData == null) {
315:                    startPresentationTextData();
316:                }
317:
318:                try {
319:
320:                    currentPresentationTextData.endControlSequence();
321:
322:                } catch (MaximumSizeExceededException msee) {
323:
324:                    endPresentationTextData();
325:                    endControlSequence();
326:
327:                }
328:
329:            }
330:
331:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.