45 |
float w; |
float w; |
46 |
float h; |
float h; |
47 |
|
|
|
// XXX KLUDGE! |
|
|
public float xoffs, yoffs; |
|
48 |
|
|
49 |
public Layout(Enfilade1D enf) { |
public Layout(Enfilade1D enf) { |
50 |
npages = enf.length(); |
npages = enf.length(); |
56 |
h = 0; |
h = 0; |
57 |
|
|
58 |
boolean foundCenter = false; |
boolean foundCenter = false; |
|
xoffs = 0; |
|
|
yoffs = 0; |
|
59 |
|
|
60 |
for(int p = 0; p < npages; p++) { |
for(int p = 0; p < npages; p++) { |
61 |
pages[p] = (PageSpan)enf.sub(p, p+1).getList().get(0); // XXX INEFFICIENT! |
pages[p] = (PageSpan)enf.sub(p, p+1).getList().get(0); // XXX INEFFICIENT! |
91 |
* Currently, only the first intersecting page |
* Currently, only the first intersecting page |
92 |
* is used, but this may change. |
* is used, but this may change. |
93 |
*/ |
*/ |
94 |
public void getExtents(PageSpan s, float[] xywh_out) { |
public float[] getExtents(PageSpan s, float[] xywh_out) { |
95 |
|
if(xywh_out == null) xywh_out = new float[4]; |
96 |
|
|
97 |
|
float curw = 0; |
98 |
|
|
99 |
for(int p = 0; p < npages; p++) { |
for(int p = 0; p < npages; p++) { |
100 |
if(s.intersects(pages[p])) { |
if(s.intersects(pages[p])) { |
101 |
Point l_c = s.getLocation(); |
Point l_c = s.getLocation(); |
102 |
Dimension d_c = s.getSize(); |
Dimension d_c = s.getSize(); |
103 |
|
|
104 |
xoffs = w + scale * (psps[p].getX(l_c.x + .5f * d_c.width) - xywh[4*p + 0]); |
xywh_out[0] = curw + scale * psps[p].getX(l_c.x); |
105 |
yoffs = scale * (psps[p].getY(l_c.y + .5f * d_c.height) - xywh[4*p + 1]); |
xywh_out[2] = curw + scale * psps[p].getX(d_c.width); |
106 |
|
|
107 |
|
xywh_out[1] = scale * ( |
108 |
|
psps[p].getX(l_c.x) - xywh[4*p + 1]); |
109 |
|
xywh_out[3] = scale * psps[p].getX(d_c.width); |
110 |
|
|
111 |
if(dbg) pa("Center found: "+p+" "+pages[p]+" "+ |
if(dbg) pa("Center found: "+p+" "+pages[p]+" "+ |
112 |
xoffs + " " + yoffs); |
xywh_out[0] + " " + xywh_out[1] + " " + |
113 |
|
xywh_out[2] + " " + xywh_out[3] + " " ); |
114 |
|
|
115 |
|
return xywh_out; |
116 |
} |
} |
117 |
|
curw += scale * xywh[4*p + 2]; |
118 |
} |
} |
119 |
|
return null; |
120 |
} |
} |
121 |
|
|
122 |
/** Place this layout into the given coordinate system. |
/** Place this layout into the given coordinate system. |
130 |
// We want a coordinate system |
// We want a coordinate system |
131 |
// whose box is exactly the span |
// whose box is exactly the span |
132 |
int around = vs.orthoBoxCS(into, pages[p], 0, |
int around = vs.orthoBoxCS(into, pages[p], 0, |
133 |
curx, -yoffs, scale, scale, |
curx, 0, scale, scale, |
134 |
xywh[4*p+2], xywh[4*p+3]); |
xywh[4*p+2], xywh[4*p+3]); |
135 |
// and then translate to the whole page. |
// and then translate to the whole page. |
136 |
int tr = vs.translateCS(around, "T", -xywh[4*p+0], -xywh[4*p+1]); |
int tr = vs.translateCS(around, "T", -xywh[4*p+0], -xywh[4*p+1]); |