KickJava   Java API By Example, From Geeks To Geeks.

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


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: ImageSizeParameter.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  * Describes the measurement characteristics of the image when it is created.
28  */

29 public class ImageSizeParameter extends AbstractAFPObject {
30
31     private int _hresol = 0;
32     private int _vresol = 0;
33     private int _hsize = 0;
34     private int _vsize = 0;
35
36     /**
37      * Constructor for a ImageSizeParameter for the specified
38      * resolution, hsize and vsize.
39      * @param hresol The horizontal resolution of the image.
40      * @param vresol The vertical resolution of the image.
41      * @param hsize The hsize of the image.
42      * @param vsize The vsize of the vsize.
43      */

44     public ImageSizeParameter(int hresol, int vresol, int hsize, int vsize) {
45
46         _hresol = hresol;
47         _vresol = vresol;
48         _hsize = hsize;
49         _vsize = vsize;
50
51     }
52
53     /**
54      * Accessor method to write the AFP datastream for the Image Size Parameter
55      * @param os The stream to write to
56      * @throws java.io.IOException
57      */

58     public void writeDataStream(OutputStream JavaDoc os)
59         throws IOException JavaDoc {
60
61         byte[] data = new byte[] {
62             (byte)0x94, // ID = Image Size Parameter
63
0x09, // Length
64
0x00, // Unit base - 10 Inches
65
0x00, // HRESOL
66
0x00, //
67
0x00, // VRESOL
68
0x00, //
69
0x00, // HSIZE
70
0x00, //
71
0x00, // VSIZE
72
0x00, //
73
};
74
75         byte[] x = BinaryUtils.convert(_hresol, 2);
76         data[3] = x[0];
77         data[4] = x[1];
78
79         byte[] y = BinaryUtils.convert(_vresol, 2);
80         data[5] = y[0];
81         data[6] = y[1];
82
83         byte[] w = BinaryUtils.convert(_hsize, 2);
84         data[7] = w[0];
85         data[8] = w[1];
86
87         byte[] h = BinaryUtils.convert(_vsize, 2);
88         data[9] = h[0];
89         data[10] = h[1];
90
91         os.write(data);
92
93     }
94
95 }
96
Popular Tags