01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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;
23: import java.io.OutputStream;
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 os) throws IOException {
55:
56: byte[] data = new byte[] { 0x5A, 0x00, 0x17, (byte) 0xD3,
57: (byte) 0xA6, (byte) 0xAF, 0x00, 0x00, 0x00, 0x00, 0x00,
58: 0x09, 0x60, 0x09, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
59: 0x00, 0x00, 0x00, 0x00, };
60:
61: byte[] x = BinaryUtils.convert(_width, 3);
62: data[15] = x[0];
63: data[16] = x[1];
64: data[17] = x[2];
65:
66: byte[] y = BinaryUtils.convert(_height, 3);
67: data[18] = y[0];
68: data[19] = y[1];
69: data[20] = y[2];
70:
71: os.write(data);
72:
73: }
74:
75: }
|