final ArrayList<Overlay> oo = new ArrayList<Overlay>();
for (double [][] coords:new double [][][] {
{ { 5, 6}, { 3, 7 }},
{ { 1, 4}, { 14, 5}}
}) {
final RectangleOverlay o = new RectangleOverlay(context.getContext());
for (int i=0; i<coords.length; i++) {
o.setOrigin(coords[i][0], i);
o.setExtent(coords[i][1], i);
oo.add(o);
}
}
getOverlayService().addOverlays(iDisplay, oo);
for (DataView v:iDisplay) {
v.setSelected(true);
}
Img<BitType> mask = OverlayUtils.extractMask(iDisplay);
assertNotNull(mask);
assertNotNull(mask);
Cursor<BitType> c = mask.cursor();
double [] position = new double [2];
while(c.hasNext()) {
BitType t = c.next();
position[1] = c.getDoublePosition(0);
position[0] = c.getDoublePosition(1);
boolean inside = false;
for (Overlay o:oo) {
inside |= o.getRegionOfInterest().contains(position);
}
assertEquals(t.get(), inside);
}
}