clear();
add(modified);
}
public void removeIndices(final int index, final int length) {
MultiRectArea modified = new MultiRectArea();
Rectangle[] rects = getRectangles();
for (int i = 0; i < rects.length; i++) {
Rectangle rect = rects[i];
int rectEnd = rect.x + rect.width - length - 1;
if (index <= rect.x) {
if (rectEnd >= index) {
int rectBegin = rect.x - length < index ? index : rect.x - length;
modified.add(new Segment(rectBegin, rectEnd));
}
} else if (rect.x < index && index < rect.x + rect.width) {
if (rectEnd < index - 1) {
rectEnd = index - 1;
}
modified.add(new Segment(rect.x, rectEnd));
} else {
modified.add((Rectangle)rect.clone());
}
}
clear();
add(modified);
}