KickJava   Java API By Example, From Geeks To Geeks.

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


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: PresentationTextDescriptor.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.render.afp.modca;
21
22 import java.io.IOException JavaDoc;
23 import java.io.OutputStream JavaDoc;
24 import org.apache.fop.render.afp.tools.BinaryUtils;
25
26 /**
27  * The Presentation Text Descriptor specifies the units of measure for the
28  * Presentation Text object space, the size of the Presentation Text object
29  * space, and the initial values for modal parameters, called initial text
30  * conditions. Initial values not provided are defaulted by the controlling
31  * environment or the receiving device.
32  *
33  * The Presentation Text Descriptor provides the following initial values:
34  * - Unit base
35  * - Xp-units per unit base
36  * - Yp-units per unit base
37  * - Xp-extent of the presentation space
38  * - Yp-extent of the presentation space
39  * - Initial text conditions.
40  *
41  * The initial text conditions are values provided by the Presentation Text
42  * Descriptor to initialize the modal parameters of the control sequences.
43  * Modal control sequences typically are characterized by the word set in
44  * the name of the control sequence. Modal parameters are identified as such
45  * in their semantic descriptions.
46  *
47  */

48 public class PresentationTextDescriptor extends AbstractAFPObject {
49
50     private int _width = 0;
51     private int _height = 0;
52
53     /**
54      * Constructor a PresentationTextDescriptor for the specified
55      * width and height.
56      * @param width The width of the page.
57      * @param height The height of the page.
58      */

59     public PresentationTextDescriptor(int width, int height) {
60
61         _width = width;
62         _height = height;
63
64     }
65
66     /**
67      * Accessor method to write the AFP datastream for the Presentation Text Descriptor
68      * @param os The stream to write to
69      * @throws java.io.IOException
70      */

71     public void writeDataStream(OutputStream JavaDoc os)
72         throws IOException JavaDoc {
73
74         byte[] data = new byte[] {
75             0x5A,
76             0x00,
77             0x16,
78             (byte) 0xD3,
79             (byte) 0xB1,
80             (byte) 0x9B,
81             0x00,
82             0x00,
83             0x00,
84             0x00,
85             0x00,
86             0x09,
87             0x60,
88             0x09,
89             0x60,
90             0x00,
91             0x00,
92             0x00,
93             0x00,
94             0x00,
95             0x00,
96             0x00,
97             0x00,
98         };
99
100         byte[] x = BinaryUtils.convert(_width, 3);
101         data[15] = x[0];
102         data[16] = x[1];
103         data[17] = x[2];
104
105         byte[] y = BinaryUtils.convert(_height, 3);
106         data[18] = y[0];
107         data[19] = y[1];
108         data[20] = y[2];
109
110         os.write(data);
111
112     }
113
114 }
Popular Tags