KickJava   Java API By Example, From Geeks To Geeks.

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


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: PageDescriptor.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 Page Descriptor structured field specifies the size and attributes of
28  * a page or overlay presentation space.
29  *
30  */

31 public class PageDescriptor extends AbstractAFPObject {
32
33     private int _width = 0;
34     private int _height = 0;
35
36     /**
37      * Construct a page descriptor for the specified page width
38      * and page height.
39      * @param width The page width.
40      * @param height The page height.
41      */

42     public PageDescriptor(int width, int height) {
43
44         _width = width;
45         _height = height;
46
47     }
48
49     /**
50      * Accessor method to write the AFP datastream for the Page Descriptor
51      * @param os The stream to write to
52      * @throws java.io.IOException
53      */

54     public void writeDataStream(OutputStream JavaDoc os)
55         throws IOException JavaDoc {
56
57         byte[] data = new byte[] {
58             0x5A,
59             0x00,
60             0x17,
61             (byte) 0xD3,
62             (byte) 0xA6,
63             (byte) 0xAF,
64             0x00,
65             0x00,
66             0x00,
67             0x00,
68             0x00,
69             0x09,
70             0x60,
71             0x09,
72             0x60,
73             0x00,
74             0x00,
75             0x00,
76             0x00,
77             0x00,
78             0x00,
79             0x00,
80             0x00,
81             0x00,
82         };
83
84         byte[] x = BinaryUtils.convert(_width, 3);
85         data[15] = x[0];
86         data[16] = x[1];
87         data[17] = x[2];
88
89         byte[] y = BinaryUtils.convert(_height, 3);
90         data[18] = y[0];
91         data[19] = y[1];
92         data[20] = y[2];
93
94         os.write(data);
95
96     }
97
98 }
Popular Tags