1 17 18 19 20 package org.apache.fop.render.afp.modca; 21 22 import java.io.IOException ; 23 import java.io.OutputStream ; 24 import java.io.UnsupportedEncodingException ; 25 26 import org.apache.fop.render.afp.tools.BinaryUtils; 27 28 41 public class IncludePageOverlay extends AbstractNamedAFPObject { 42 43 46 private int _xCoor = 0; 47 48 51 private int _yCoor = 0; 52 53 56 private int _orientation = 0; 57 58 65 public IncludePageOverlay(String overlayName, int x, int y, int orientation) { 66 67 super(overlayName); 68 69 _xCoor = x; 70 _yCoor = y; 71 setOrientation(orientation); 72 } 73 74 80 public void setOrientation(int orientation) { 81 82 if (orientation == 0 || orientation == 90 || orientation == 180 83 || orientation == 270) { 84 _orientation = orientation; 85 } else { 86 throw new IllegalArgumentException ( 87 "The orientation must be one of the values 0, 90, 180, 270"); 88 } 89 90 } 91 92 97 public void writeDataStream(OutputStream os) 98 throws IOException { 99 100 byte[] data = new byte[25]; 102 data[0] = 0x5A; 103 104 byte[] rl1 = BinaryUtils.convert(24, 2); data[1] = rl1[0]; 107 data[2] = rl1[1]; 108 109 data[3] = (byte) 0xD3; 111 data[4] = (byte) 0xAF; 112 data[5] = (byte) 0xD8; 113 114 data[6] = 0x00; data[7] = 0x00; data[8] = 0x00; 118 for (int i = 0; i < _nameBytes.length; i++) { 119 120 data[9 + i] = _nameBytes[i]; 121 122 } 123 124 byte[] r2 = BinaryUtils.convert(_xCoor, 3); 125 data[17] = r2[0]; data[18] = r2[1]; 127 data[19] = r2[2]; 128 129 byte[] r3 = BinaryUtils.convert(_yCoor, 3); 130 data[20] = r3[0]; data[21] = r3[1]; 132 data[22] = r3[2]; 133 134 switch (_orientation) { 135 case 90: 136 data[23] = 0x2D; 137 data[24] = 0x00; 138 break; 139 case 180: 140 data[23] = 0x5A; 141 data[24] = 0x00; 142 break; 143 case 270: 144 data[23] = (byte) 0x87; 145 data[24] = 0x00; 146 break; 147 default: 148 data[23] = 0x00; 149 data[24] = 0x00; 150 break; 151 } 152 153 os.write(data); 154 155 } 156 157 } | Popular Tags |