78 lines
2.3 KiB
Java
78 lines
2.3 KiB
Java
package jxl.biff.drawing;
|
|
|
|
import common.Logger;
|
|
import jxl.biff.IntegerHelper;
|
|
|
|
class ClientAnchor extends EscherAtom {
|
|
private static final Logger logger = Logger.getLogger(ClientAnchor.class);
|
|
|
|
private byte[] data;
|
|
|
|
private double x1;
|
|
|
|
private double y1;
|
|
|
|
private double x2;
|
|
|
|
private double y2;
|
|
|
|
public ClientAnchor(EscherRecordData erd) {
|
|
super(erd);
|
|
byte[] bytes = getBytes();
|
|
int x1Cell = IntegerHelper.getInt(bytes[2], bytes[3]);
|
|
int x1Fraction = IntegerHelper.getInt(bytes[4], bytes[5]);
|
|
this.x1 = x1Cell + x1Fraction / 1024.0D;
|
|
int y1Cell = IntegerHelper.getInt(bytes[6], bytes[7]);
|
|
int y1Fraction = IntegerHelper.getInt(bytes[8], bytes[9]);
|
|
this.y1 = y1Cell + y1Fraction / 256.0D;
|
|
int x2Cell = IntegerHelper.getInt(bytes[10], bytes[11]);
|
|
int x2Fraction = IntegerHelper.getInt(bytes[12], bytes[13]);
|
|
this.x2 = x2Cell + x2Fraction / 1024.0D;
|
|
int y2Cell = IntegerHelper.getInt(bytes[14], bytes[15]);
|
|
int y2Fraction = IntegerHelper.getInt(bytes[16], bytes[17]);
|
|
this.y2 = y2Cell + y2Fraction / 256.0D;
|
|
}
|
|
|
|
public ClientAnchor(double x1, double y1, double x2, double y2) {
|
|
super(EscherRecordType.CLIENT_ANCHOR);
|
|
this.x1 = x1;
|
|
this.y1 = y1;
|
|
this.x2 = x2;
|
|
this.y2 = y2;
|
|
}
|
|
|
|
byte[] getData() {
|
|
this.data = new byte[18];
|
|
IntegerHelper.getTwoBytes(2, this.data, 0);
|
|
IntegerHelper.getTwoBytes((int)this.x1, this.data, 2);
|
|
int x1fraction = (int)((this.x1 - (int)this.x1) * 1024.0D);
|
|
IntegerHelper.getTwoBytes(x1fraction, this.data, 4);
|
|
IntegerHelper.getTwoBytes((int)this.y1, this.data, 6);
|
|
int y1fraction = (int)((this.y1 - (int)this.y1) * 256.0D);
|
|
IntegerHelper.getTwoBytes(y1fraction, this.data, 8);
|
|
IntegerHelper.getTwoBytes((int)this.x2, this.data, 10);
|
|
int x2fraction = (int)((this.x2 - (int)this.x2) * 1024.0D);
|
|
IntegerHelper.getTwoBytes(x2fraction, this.data, 12);
|
|
IntegerHelper.getTwoBytes((int)this.y2, this.data, 14);
|
|
int y2fraction = (int)((this.y2 - (int)this.y2) * 256.0D);
|
|
IntegerHelper.getTwoBytes(y2fraction, this.data, 16);
|
|
return setHeaderData(this.data);
|
|
}
|
|
|
|
double getX1() {
|
|
return this.x1;
|
|
}
|
|
|
|
double getY1() {
|
|
return this.y1;
|
|
}
|
|
|
|
double getX2() {
|
|
return this.x2;
|
|
}
|
|
|
|
double getY2() {
|
|
return this.y2;
|
|
}
|
|
}
|