1 17 18 19 20 package org.apache.fop.render.afp.modca; 21 import java.io.IOException ; 22 import java.io.OutputStream ; 23 import java.io.UnsupportedEncodingException ; 24 25 26 37 public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { 38 39 42 private static final String DEFAULT_NAME = "OEG00001"; 43 44 47 private ObjectAreaDescriptor _objectAreaDescriptor = null; 48 49 52 private ObjectAreaPosition _objectAreaPosition = null; 53 54 57 private ImageDataDescriptor _imageDataDescriptor = null; 58 59 62 public ObjectEnvironmentGroup() { 63 64 this(DEFAULT_NAME); 65 66 } 67 68 73 public ObjectEnvironmentGroup(String name) { 74 75 super(name); 76 77 } 78 79 87 public void setObjectArea(int x, int y, int width, int height, int rotation) { 88 89 _objectAreaDescriptor = new ObjectAreaDescriptor(width, height); 90 _objectAreaPosition = new ObjectAreaPosition(x, y, rotation); 91 92 } 93 94 101 public void setImageData(int xresol, int yresol, int width, int height) { 102 _imageDataDescriptor = new ImageDataDescriptor(xresol, yresol, width, height); 103 } 104 105 111 public void writeDataStream(OutputStream os) 112 throws IOException { 113 114 115 writeStart(os); 116 117 _objectAreaDescriptor.writeDataStream(os); 118 119 _objectAreaPosition.writeDataStream(os); 120 121 if (_imageDataDescriptor != null) { 122 _imageDataDescriptor.writeDataStream(os); 123 } 124 125 writeEnd(os); 126 127 } 128 129 133 private void writeStart(OutputStream os) 134 throws IOException { 135 136 byte[] data = new byte[] { 137 0x5A, 0x00, 0x10, (byte) 0xD3, (byte) 0xA8, (byte) 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; 155 156 for (int i = 0; i < _nameBytes.length; i++) { 157 158 data[9 + i] = _nameBytes[i]; 159 160 } 161 162 os.write(data); 163 164 } 165 166 170 private void writeEnd(OutputStream os) 171 throws IOException { 172 173 byte[] data = new byte[17]; 174 175 data[0] = 0x5A; data[1] = 0x00; data[2] = 0x10; data[3] = (byte) 0xD3; data[4] = (byte) 0xA9; data[5] = (byte) 0xC7; data[6] = 0x00; data[7] = 0x00; data[8] = 0x00; 185 for (int i = 0; i < _nameBytes.length; i++) { 186 187 data[9 + i] = _nameBytes[i]; 188 189 } 190 191 os.write(data); 192 193 } 194 195 } | Popular Tags |