222 |
|
|
223 |
/** Get selected area of pagespanlayout in enfilade |
/** Get selected area of pagespanlayout in enfilade |
224 |
*/ |
*/ |
225 |
Enfilade1D getSelection(int x, int y, int width, int height) { |
public Enfilade1D getSelection(int x, int y, int width, int height) { |
226 |
if (x<0 || y<0) throw new Error ("X or Y smaller than zero, x:"+x+", y:"+y); |
if (x<0 || y<0) throw new Error ("X or Y smaller than zero, x:"+x+", y:"+y); |
227 |
|
|
228 |
int w=0, wLeft = width, p=0; |
int w=0, wLeft = width, p=0; |
229 |
Enfilade1D enf = new Enfilade1DImpl(null); |
Enfilade1D enf = null; |
|
Enfilade1D.Maker m = enf.getMaker(); |
|
230 |
|
|
231 |
// Go into page where selection starts |
// Go into page where selection starts |
232 |
for (; p<pages.length; p++) |
for (; p<pages.length; p++) |
239 |
if (height > xywh[4*p + 3]) throw new Error("Selection out of page,"+p+", h:"+height); |
if (height > xywh[4*p + 3]) throw new Error("Selection out of page,"+p+", h:"+height); |
240 |
|
|
241 |
// everything ok, so get a clip from page for returning enfilade. |
// everything ok, so get a clip from page for returning enfilade. |
242 |
if (enf.length() == 0) { |
if (enf == null) { |
243 |
w = (int)Math.min(wLeft, xywh[4*p + 2] - x); |
w = (int)Math.min(wLeft, xywh[4*p + 2] - x); |
244 |
enf.plus(m.makeEnfilade(pages[p].subArea(x,y, w, height))); |
enf = new Enfilade1DImpl(pages[p].subArea(x,y, w, height)); |
245 |
} else { |
} else { |
246 |
w = (int)Math.min(wLeft, xywh[4*p + 2]); |
w = (int)Math.min(wLeft, xywh[4*p + 2]); |
247 |
|
Enfilade1D.Maker m = enf.getMaker(); |
248 |
enf.plus(m.makeEnfilade(pages[p].subArea(0,y, w, height))); |
enf.plus(m.makeEnfilade(pages[p].subArea(0,y, w, height))); |
249 |
} |
} |
250 |
wLeft -= w; |
wLeft -= w; |
251 |
} |
} |
252 |
return enf; |
return enf; |
253 |
} |
} |
|
|
|
254 |
} |
} |
255 |
|
|
256 |
|
|