KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > render > afp > modca > Overlay


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: Overlay.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.render.afp.modca;
21
22 import java.io.ByteArrayOutputStream JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.io.OutputStream JavaDoc;
25 import java.util.Iterator JavaDoc;
26
27 /**
28  */

29 public class Overlay extends AbstractPageObject{
30
31     /**
32      * Construct a new overlay object for the specified name argument, the overlay
33      * name should be an 8 character identifier.
34      *
35      * @param name
36      * the name of the page.
37      * @param width
38      * the width of the page.
39      * @param height
40      * the height of the page.
41      * @param rotation
42      * the rotation of the page.
43      */

44     public Overlay(String JavaDoc name, int width, int height, int rotation) {
45
46         super(name, width, height, rotation);
47
48     }
49
50     /**
51      * Accessor method to write the AFP datastream for the overlay.
52      *
53      * @param os The stream to write to
54      * @throws java.io.IOException
55      */

56     public void writeDataStream(OutputStream JavaDoc os)
57         throws IOException JavaDoc {
58
59         writeStart(os);
60
61         _activeEnvironmentGroup.writeDataStream(os);
62
63         writeObjectList(_segments, os);
64
65         writeObjectList(_tagLogicalElements, os);
66
67         writeObjectList(_objects, os);
68
69         writeEnd(os);
70
71     }
72
73     /**
74      * Helper method to write the start of the overlay.
75      * @param os The stream to write to
76      */

77     private void writeStart(OutputStream JavaDoc os)
78         throws IOException JavaDoc {
79
80         byte[] data = new byte[17];
81
82         data[0] = 0x5A; // Structured field identifier
83
data[1] = 0x00; // Length byte 1
84
data[2] = 0x10; // Length byte 2
85
data[3] = (byte) 0xD3; // Structured field id byte 1
86
data[4] = (byte) 0xA8; // Structured field id byte 2
87
data[5] = (byte) 0xDF; // Structured field id byte 3
88
data[6] = 0x00; // Flags
89
data[7] = 0x00; // Reserved
90
data[8] = 0x00; // Reserved
91

92         for (int i = 0; i < _nameBytes.length; i++) {
93
94             data[9 + i] = _nameBytes[i];
95
96         }
97
98         os.write(data);
99
100     }
101
102     /**
103      * Helper method to write the end of the overlay.
104      * @param os The stream to write to
105      */

106     private void writeEnd(OutputStream JavaDoc os)
107         throws IOException JavaDoc {
108
109         byte[] data = new byte[17];
110
111         data[0] = 0x5A; // Structured field identifier
112
data[1] = 0x00; // Length byte 1
113
data[2] = 0x10; // Length byte 2
114
data[3] = (byte) 0xD3; // Structured field id byte 1
115
data[4] = (byte) 0xA9; // Structured field id byte 2
116
data[5] = (byte) 0xDF; // Structured field id byte 3
117
data[6] = 0x00; // Flags
118
data[7] = 0x00; // Reserved
119
data[8] = 0x00; // Reserved
120

121         for (int i = 0; i < _nameBytes.length; i++) {
122
123             data[9 + i] = _nameBytes[i];
124
125         }
126
127         os.write(data);
128
129     }
130
131 }
132
Popular Tags