KickJava   Java API By Example, From Geeks To Geeks.

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


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: ImageCellPosition.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 IM Image Cell Position structured field specifies the placement,
28  * size, and replication of IM image cells.
29  */

30 public class ImageCellPosition extends AbstractAFPObject {
31
32     /**
33      * Offset of image cell in X direction
34      */

35     private int _XcoSet = 0;
36
37     /**
38      * Offset of image cell in Y direction
39      */

40     private int _YcoSet = 0;
41
42     /**
43      * Size of image cell in X direction
44      */

45     private byte[] _XcSize = new byte[] { (byte)0xFF, (byte)0xFF };
46
47     /**
48      * Size of image cell in Y direction
49      */

50     private byte[] _YcSize = new byte[] { (byte)0xFF, (byte)0xFF };
51
52     /**
53      * Size of fill rectangle in X direction
54      */

55     private byte[] _XFillSize = new byte[] { (byte)0xFF, (byte)0xFF };
56
57     /**
58      * Size of fill rectangle in Y direction
59      */

60     private byte[] _YFillSize = new byte[] { (byte)0xFF, (byte)0xFF };
61
62     /**
63      * Constructor for the ImageCellPosition
64      * @param x The offset of image cell in X direction
65      * @param y The offset of image cell in Y direction
66      */

67     public ImageCellPosition(int x, int y) {
68
69         _XcoSet = x;
70         _YcoSet = y;
71
72     }
73
74     /**
75      * Accessor method to write the AFP datastream for the Image Cell Position
76      * @param os The stream to write to
77      * @throws java.io.IOException
78      */

79     public void writeDataStream(OutputStream JavaDoc os)
80         throws IOException JavaDoc {
81
82         byte[] data = new byte[21];
83
84         data[0] = 0x5A;
85
86         data[1] = 0x00;
87         data[2] = 0x14;
88
89         data[3] = (byte) 0xD3;
90         data[4] = (byte) 0xAC;
91         data[5] = (byte) 0x7B;
92         data[6] = 0x00;
93         data[7] = 0x00;
94         data[8] = 0x00;
95
96         /**
97          * Specifies the offset along the Xp direction, in image points,
98          * of this image cell from the IM image object area origin.
99          */

100         byte[] x1 = BinaryUtils.convert(_XcoSet, 2);
101         data[9] = x1[0];
102         data[10] = x1[1];
103
104         /**
105          * Specifies the offset along the Yp direction, in image points,
106          * of this image cell from the IM image object area origin.
107          */

108         byte[] x2 = BinaryUtils.convert(_YcoSet, 2);
109         data[11] = x2[0];
110         data[12] = x2[1];
111
112         data[13] = _XcSize[0];
113         data[14] = _XcSize[1];
114
115         data[15] = _YcSize[0];
116         data[16] = _YcSize[1];
117
118         data[17] = _XFillSize[0];
119         data[18] = _XFillSize[1];
120
121         data[19] = _YFillSize[0];
122         data[20] = _YFillSize[1];
123
124         os.write(data);
125
126     }
127
128     /**
129      * Specifies the extent in the X direction, in image points,
130      * of this image cell. A value of X'FFFF' indicates that the
131      * default extent specified in bytes 28 and 29 of the Image
132      * Input Descriptor (IID) is to be used.
133      * @param xcSize The size to set.
134      */

135     public void setXSize(int xcSize) {
136
137         byte[] x = BinaryUtils.convert(xcSize, 2);
138         _XcSize[0] = x[0];
139         _XcSize[1] = x[1];
140
141     }
142
143     /**
144      * Specifies the extent of the fill rectangle in the X direction,
145      * in image points. This value can be smaller than, equal to, or
146      * larger than the image cell extent in the X direction (XCSize).
147      * A value of X'FFFF' indicates that the image cell X-extent should
148      * be used as the fill rectangle X-extent. The fill rectangle is
149      * filled in the X direction by repeating the image cell in the
150      * X direction. The image cell can be truncated to fit the rectangle.
151      * @param xFillSize The size to set.
152      */

153     public void setXFillSize(int xFillSize) {
154
155         byte[] x = BinaryUtils.convert(xFillSize, 2);
156         _XFillSize[0] = x[0];
157         _XFillSize[1] = x[1];
158
159     }
160
161     /**
162      * Specifies the extent in the Y direction, in image points,
163      * of this image cell. A value of X'FFFF' indicates that the
164      * default extent specified in bytes 30 and 31 of the Image
165      * Input Descriptor (IID) is to be used.
166      * @param ycSize The size to set.
167      */

168     public void setYSize(int ycSize) {
169
170         byte[] x = BinaryUtils.convert(ycSize, 2);
171         _YcSize[0] = x[0];
172         _YcSize[1] = x[1];
173
174     }
175
176     /**
177      * Specifies the extent of the fill rectangle in the Y direction,
178      * in image points. This value can be smaller than, equal to, or
179      * larger than the image cell extent in the Y direction (YCSize).
180      * A value of X'FFFF' indicates that the image cell Y-extent should
181      * be used as the fill rectangle Y-extent. The fill rectangle is
182      * filled in the Y direction by repeating the image cell in the
183      * Y direction. The image cell can be truncated to fit the rectangle.
184      * @param yFillSize The size to set.
185      */

186     public void setYFillSize(int yFillSize) {
187
188         byte[] x = BinaryUtils.convert(yFillSize, 2);
189         _YFillSize[0] = x[0];
190         _YFillSize[1] = x[1];
191
192     }
193
194 }
Popular Tags