1 19 20 package jxl.biff.drawing; 21 22 import jxl.biff.IntegerHelper; 23 24 class ClientAnchor extends EscherAtom 25 { 26 private byte[] data; 27 28 private double x1; 29 private double y1; 30 private double x2; 31 private double y2; 32 33 public ClientAnchor(EscherRecordData erd) 34 { 35 super(erd); 36 byte[] bytes = getBytes(); 37 38 int x1Cell = IntegerHelper.getInt(bytes[2], bytes[3]); 40 int x1Fraction = IntegerHelper.getInt(bytes[4], bytes[5]); 41 42 x1 = x1Cell + (double) x1Fraction / (double) 1024; 43 44 int y1Cell = IntegerHelper.getInt(bytes[6], bytes[7]); 46 int y1Fraction = IntegerHelper.getInt(bytes[8], bytes[9]); 47 48 y1 = y1Cell + (double) y1Fraction / (double) 256; 49 50 int x2Cell = IntegerHelper.getInt(bytes[10], bytes[11]); 52 int x2Fraction = IntegerHelper.getInt(bytes[12], bytes[13]); 53 54 x2 = x2Cell + (double) x2Fraction / (double) 1024; 55 56 int y2Cell = IntegerHelper.getInt(bytes[14], bytes[15]); 58 int y2Fraction = IntegerHelper.getInt(bytes[16], bytes[17]); 59 60 y2 = y2Cell + (double) y2Fraction / (double) 256; 61 } 62 63 public ClientAnchor(double x1, double y1, double x2, double y2) 64 { 65 super(EscherRecordType.CLIENT_ANCHOR); 66 this.x1 = x1; 67 this.y1 = y1; 68 this.x2 = x2; 69 this.y2 = y2; 70 } 71 72 byte[] getData() 73 { 74 data = new byte[18]; 75 IntegerHelper.getTwoBytes(0x2, data, 0); 76 77 IntegerHelper.getTwoBytes((int) x1, data, 2); 79 80 int x1fraction = (int) ((x1 - (int) x1) * 1024); 82 IntegerHelper.getTwoBytes(x1fraction, data, 4); 83 84 IntegerHelper.getTwoBytes((int) y1, data, 6); 86 87 int y1fraction = (int) ((y1 - (int) y1) * 256); 89 IntegerHelper.getTwoBytes(y1fraction, data, 8); 90 91 IntegerHelper.getTwoBytes((int) x2, data, 10); 93 94 int x2fraction = (int) ((x2 - (int) x2) * 1024); 96 IntegerHelper.getTwoBytes(x2fraction, data, 12); 97 98 IntegerHelper.getTwoBytes((int) y2, data, 14); 100 101 int y2fraction = (int) ((y2 - (int) y2) * 256); 103 IntegerHelper.getTwoBytes(y2fraction, data, 16); 104 105 return setHeaderData(data); 106 } 107 108 double getX1() 109 { 110 return x1; 111 } 112 113 double getY1() 114 { 115 return y1; 116 } 117 118 double getX2() 119 { 120 return x2; 121 } 122 123 double getY2() 124 { 125 return y2; 126 } 127 } 128 | Popular Tags |