public class CTM implements Serializable {
private double a,b,c,d,e,f;
- private static CTM s_CTM_lrtb = new CTM(1,0,0,-1,0,0);
- private static CTM s_CTM_rltb = new CTM(-1,0,0,-1,0,0);
- private static CTM s_CTM_tbrl = new CTM(0,-1,-1,0,0,0);
+ private static CTM s_CTM_lrtb = new CTM(1,0,0,1,0,0);
+ private static CTM s_CTM_rltb = new CTM(-1,0,0,1,0,0);
+ private static CTM s_CTM_tbrl = new CTM(0,1,-1,0,0,0);
/**
* Create the identity matrix
*/
this.f = y;
}
+ protected CTM(CTM ctm) {
+ this.a = ctm.a;
+ this.b = ctm.b;
+ this.c = ctm.c;
+ this.d = ctm.d;
+ this.e = ctm.e;
+ this.f = ctm.f;
+ }
+
/**
* Return a CTM which will transform coordinates for a particular writing-mode
* into normalized first quandrant coordinates.
* CTM is being set.
*/
static public CTM getWMctm(int wm, int ipd, int bpd) {
+ CTM wmctm;
switch (wm) {
case WritingMode.LR_TB:
- return s_CTM_lrtb.translate(0,bpd);
+ return new CTM(s_CTM_lrtb);
case WritingMode.RL_TB:
- return s_CTM_rltb.translate(ipd, bpd);
+ {
+ wmctm = new CTM(s_CTM_rltb);
+ wmctm.e = ipd;
+ return wmctm;
+ }
+ //return s_CTM_rltb.translate(ipd, 0);
case WritingMode.TB_RL: // CJK
- return s_CTM_tbrl.translate(bpd, ipd);
+ {
+ wmctm = new CTM(s_CTM_tbrl);
+ wmctm.e = bpd;
+ return wmctm;
+ }
+ //return s_CTM_tbrl.translate(0, ipd);
default:
return null;
}
* @return CTM The result of rotating this CTM.
*/
public CTM rotate(double angle) {
- double rad = Math.toRadians(angle);
- double cos = Math.cos(rad);
- double sin = Math.sin(rad);
- CTM rotate= new CTM(cos, sin, -sin, cos, 0, 0);
+ double cos, sin;
+ if (angle == 90.0) {
+ cos = 0.0;
+ sin = 1.0;
+ }
+ else if (angle == 270.0) {
+ cos = 0.0;
+ sin = -1.0;
+ }
+ else if (angle == 180.0) {
+ cos = -1.0;
+ sin = 0.0;
+ }
+ else {
+ double rad = Math.toRadians(angle);
+ cos = Math.cos(rad);
+ sin = Math.sin(rad);
+ }
+ CTM rotate= new CTM(cos,-sin, sin, cos, 0, 0);
return multiply(rotate);
}
}
return new Rectangle(x1t, y1t, x2t-x1t, y2t-y1t);
}
+
+ public String toString() {
+ return "[" + a + " " + b + " " + c + " " + d + " " + e + " " + f + "]";
+ }
}
* (Note: scrolling between region vp and ref area when doing online content!)
*/
CTM ctm = new CTM(absVPrect.getX(), absVPrect.getY());
+
// First transform for rotation
if (absRefOrient != 0) {
// Rotation implies translation to keep the drawing area in the
// first quadrant. Note: rotation is counter-clockwise
switch (absRefOrient) {
case 90:
- ctm = ctm.translate(height, 0); // height = absVPrect.width
+ ctm = ctm.translate(0, width); // width = absVPrect.height
break;
case 180:
ctm = ctm.translate(width, height);
break;
case 270:
- ctm = ctm.translate(0, width); // width = absVPrect.height
+ ctm = ctm.translate(height,0); // height = absVPrect.width
break;
}
ctm = ctm.rotate(absRefOrient);
// Need these in writing-mode relative coordinates
// Or shall we get absolute and transform to relative using writing mode?
MarginProps mProps = propMgr.getMarginProps();
+ /**
+ System.err.println("BodyRegion margin props=" + mProps.startIndent + ","
+ + mProps.spaceBefore + "," + mProps.endIndent + ","
+ + mProps.spaceAfter);
+
return new Rectangle( mProps.startIndent, mProps.spaceBefore,
reldims.ipd - mProps.startIndent - mProps.endIndent,
reldims.bpd - mProps.spaceBefore - mProps.spaceAfter);
+ **/
+ return new Rectangle( mProps.marginLeft, mProps.marginTop,
+ reldims.ipd - mProps.marginLeft - mProps.marginRight,
+ reldims.bpd - mProps.marginTop - mProps.marginBottom);
}
protected void setRegionTraits(RegionReference r, Rectangle2D absRegVPRect) {
public RegionReference makeRegionReferenceArea(Rectangle2D absRegVPRect) {
// Should set some column stuff here I think, or put it elsewhere
BodyRegion body = new BodyRegion();
+ setRegionTraits(body, absRegVPRect);
int columnCount=
this.properties.get("column-count").getNumber().intValue();
if ((columnCount > 1) && (overflow == Overflow.SCROLL)) {