diff options
author | Jeremias Maerki <jeremias@apache.org> | 2006-07-24 13:15:33 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2006-07-24 13:15:33 +0000 |
commit | 423453976de29088ee76156baec1a83bc58b9518 (patch) | |
tree | 862dc8f568a4debcbd648f69797381df97adece5 /src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java | |
parent | 0f58ef4c39df7e8525f52325a10e3c1aa1ae5ad9 (diff) | |
download | xmlgraphics-fop-423453976de29088ee76156baec1a83bc58b9518.tar.gz xmlgraphics-fop-423453976de29088ee76156baec1a83bc58b9518.zip |
Promoting the AFP renderer from sandbox to the main source tree.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@425037 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java')
-rw-r--r-- | src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java b/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java new file mode 100644 index 000000000..8a2aaaede --- /dev/null +++ b/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java @@ -0,0 +1,207 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.render.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import org.apache.fop.render.afp.tools.BinaryUtils; + +/** + * The IM Image Output Control structured field specifies the position and + * orientation of the IM image object area and the mapping of the image points + * to presentation device pels. + * + */ +public class ImageOutputControl extends AbstractAFPObject { + + /** + * The orientation of the image + */ + private int _orientation = 0; + + /** + * Specifies the offset, along the X-axis, of the IM image object area + * origin to the origin of the including page + */ + private int _Xcoordinate = 0; + + /** + * Specifies the offset, along the Y-axis, of the IM image object area + * origin to the origin of the including page + */ + private int _Ycoordinate = 0; + + /** + * Map an image point to a single presentation device pel + */ + private boolean _singlepoint = true; + + /** + * Constructor for the ImageOutputControl The x parameter specifies the + * offset, along the X-axis, of the IM image object area origin to the + * origin of the including page and the y parameter specifies the offset + * along the Y-axis. The offset is specified in image points and is resolved + * using the units of measure specified for the image in the IID structured + * field. + * + * @param x + * The X-axis offset. + * @param y + * The Y-axis offset. + */ + public ImageOutputControl(int x, int y) { + + _Xcoordinate = x; + _Ycoordinate = y; + + } + + /** + * Accessor method to write the AFP datastream for the Image Output Control + * @param os The stream to write to + * @throws java.io.IOException + */ + public void writeDataStream(OutputStream os) + throws IOException { + + byte[] data = new byte[33]; + + data[0] = 0x5A; + data[1] = 0x00; + data[2] = 0x20; + data[3] = (byte) 0xD3; + data[4] = (byte) 0xA7; + data[5] = (byte) 0x7B; + data[6] = 0x00; + data[7] = 0x00; + data[8] = 0x00; + + // XoaOset + byte[] x1 = BinaryUtils.convert(_Xcoordinate, 3); + data[9] = x1[0]; + data[10] = x1[1]; + data[11] = x1[2]; + + // YoaOset + byte[] x2 = BinaryUtils.convert(_Ycoordinate, 3); + data[12] = x2[0]; + data[13] = x2[1]; + data[14] = x2[2]; + + switch (_orientation) { + case 0: + // 0 and 90 degrees respectively + data[15] = 0x00; + data[16] = 0x00; + data[17] = 0x2D; + data[18] = 0x00; + break; + case 90: + // 90 and 180 degrees respectively + data[15] = 0x2D; + data[16] = 0x00; + data[17] = 0x5A; + data[18] = 0x00; + break; + case 180: + // 180 and 270 degrees respectively + data[15] = 0x5A; + data[16] = 0x00; + data[17] = (byte) 0x87; + data[18] = 0x00; + break; + case 270: + // 270 and 0 degrees respectively + data[15] = (byte) 0x87; + data[16] = 0x00; + data[17] = 0x00; + data[18] = 0x00; + break; + default: + // 0 and 90 degrees respectively + data[15] = 0x00; + data[16] = 0x00; + data[17] = 0x2D; + data[18] = 0x00; + break; + + } + + // Constant Data + data[19] = 0x00; + data[20] = 0x00; + data[21] = 0x00; + data[22] = 0x00; + data[23] = 0x00; + data[24] = 0x00; + data[25] = 0x00; + data[26] = 0x00; + + if (_singlepoint) { + data[27] = 0x03; + data[28] = (byte) 0xE8; + data[29] = 0x03; + data[30] = (byte) 0xE8; + } else { + data[27] = 0x07; + data[28] = (byte) 0xD0; + data[29] = 0x07; + data[30] = (byte) 0xD0; + } + + // Constant Data + data[31] = (byte) 0xFF; + data[32] = (byte) 0xFF; + + os.write(data); + + } + + /** + * Sets the orientation which specifies the amount of clockwise rotation of + * the IM image object area. + * + * @param orientation + * The orientation to set. + */ + public void setOrientation(int orientation) { + + if (orientation == 0 || orientation == 90 || orientation == 180 + || orientation == 270) { + _orientation = orientation; + } else { + throw new IllegalArgumentException( + "The orientation must be one of the values 0, 90, 180, 270"); + } + + } + + /** + * Sets the singlepoint, if true map an image point to a single presentation + * device pel in the IM image object area. If false map an image point to + * two presentation device pels in the IM image object area (double-dot) + * + * @param singlepoint + * Use the singlepoint basis when true. + */ + public void setSinglepoint(boolean singlepoint) { + _singlepoint = singlepoint; + } + +}
\ No newline at end of file |