/** Merge with another Outline by adding it at the end. Thereafter, the other outline must not be used any more. */ public void append(Outline o) { int size = last - first; int oSize = o.last - o.first; if (size <= o.first && oSize > reserved - last) { // we don't have enough space in our own array but in that of 'o' System.arraycopy(x, first, o.x, o.first - size, size); // so prepend our own data to that of 'o' System.arraycopy(y, first, o.y, o.first - size, size); x = o.x; y = o.y; first = o.first - size; last = o.last; reserved = o.reserved; } else { // append to our own array needs(0, oSize); System.arraycopy(o.x, o.first, x, last, oSize); System.arraycopy(o.y, o.first, y, last, oSize); last += oSize; } }
outline[x + 1] = outline[x] = new Outline(); outline[x].append(x + 1, y); outline[x].append(x, y); } else { outline[x] = outline[x + 1]; // line from top-right to top-left outline[x + 1] = null; outline[x].append(x, y); outline[x + 1] = outline[x]; outline[x] = oAfterLowerRightCorner; outline[x].append(x, y); outline[x + 1].prepend(x + 1, y); } else { outline[x + 1] = outline[x]; outline[x] = null; outline[x + 1].prepend(x + 1, y); outline[x + 1].prepend(x + 1,y); xAfterLowerRightCorner = x + 1; oAfterLowerRightCorner = outline[x + 1]; } else { polygons.add(outline[x].getPolygon()); // MINUS (add inner hole) outline[x + 1] = null; outline[x] = (x == xAfterLowerRightCorner) ? oAfterLowerRightCorner : null; outline[x].prepend(outline[x + 1]); // merge for (int x1 = 0; x1 <= w; x1++) if (x1 != x + 1 && outline[x1] == outline[x + 1]) {
outline[x + 1] = outline[x] = new Outline(); outline[x].append(x + 1, y); outline[x].append(x, y); } else { outline[x] = outline[x + 1]; // line from top-right to top-left outline[x + 1] = null; outline[x].append(x, y); outline[x + 1] = outline[x]; outline[x] = oAfterLowerRightCorner; outline[x].append(x, y); outline[x + 1].prepend(x + 1, y); } else { outline[x + 1] = outline[x]; outline[x] = null; outline[x + 1].prepend(x + 1, y); outline[x + 1].prepend(x + 1,y); xAfterLowerRightCorner = x + 1; oAfterLowerRightCorner = outline[x + 1]; } else { polygons.add(outline[x].getPolygon()); // MINUS (add inner hole) outline[x + 1] = null; outline[x] = (x == xAfterLowerRightCorner) ? oAfterLowerRightCorner : null; outline[x].prepend(outline[x + 1]); // merge for (int x1 = 0; x1 <= w; x1++) if (x1 != x + 1 && outline[x1] == outline[x + 1]) {
/** Merge with another Outline by adding it at the beginning. Thereafter, the other outline must not be used any more. */ public void prepend(Outline o) { int size = last - first; int oSize = o.last - o.first; if (size <= o.reserved - o.last && oSize > first) { // we don't have enough space in our own array but in that of 'o' System.arraycopy(x, first, o.x, o.last, size); // so append our own data to that of 'o' System.arraycopy(y, first, o.y, o.last, size); x = o.x; y = o.y; first = o.first; last = o.last + size; reserved = o.reserved; } else { // prepend to our own array needs(oSize, 0); first -= oSize; System.arraycopy(o.x, o.first, x, first, oSize); System.arraycopy(o.y, o.first, y, first, oSize); } }
/** Merge with another Outline by adding it at the end. Thereafter, the other outline must not be used any more. */ public void append(Outline o) { int size = last - first; int oSize = o.last - o.first; if (size <= o.first && oSize > reserved - last) { // we don't have enough space in our own array but in that of 'o' System.arraycopy(x, first, o.x, o.first - size, size); // so prepend our own data to that of 'o' System.arraycopy(y, first, o.y, o.first - size, size); x = o.x; y = o.y; first = o.first - size; last = o.last; reserved = o.reserved; } else { // append to our own array needs(0, oSize); System.arraycopy(o.x, o.first, x, last, oSize); System.arraycopy(o.y, o.first, y, last, oSize); last += oSize; } }
/** Merge with another Outline by adding it at the beginning. Thereafter, the other outline must not be used any more. */ public void prepend(Outline o) { int size = last - first; int oSize = o.last - o.first; if (size <= o.reserved - o.last && oSize > first) { // we don't have enough space in our own array but in that of 'o' System.arraycopy(x, first, o.x, o.last, size); // so append our own data to that of 'o' System.arraycopy(y, first, o.y, o.last, size); x = o.x; y = o.y; first = o.first; last = o.last + size; reserved = o.reserved; } else { // prepend to our own array needs(oSize, 0); first -= oSize; System.arraycopy(o.x, o.first, x, first, oSize); System.arraycopy(o.y, o.first, y, first, oSize); } }
/** Adds point x, y at the beginning of the list */ public void prepend(int x, int y) { if (last-first>=2 && collinear(this.x[first+1], this.y[first+1], this.x[first], this.y[first], x , y)) { this.x[first] = x; //replace previous point this.y[first] = y; } else { needs(1, 0); //new point first--; this.x[first] = x; this.y[first] = y; } }
/** Adds point x, y at the end of the list */ public void append(int x, int y) { if (last-first>=2 && collinear(this.x[last-2], this.y[last-2], this.x[last-1], this.y[last-1], x , y)) { this.x[last-1] = x; //replace previous point this.y[last-1] = y; } else { needs(0, 1); //new point this.x[last] = x; this.y[last] = y; last++; } }
/** Adds point x, y at the end of the list */ public void append(int x, int y) { if (last-first>=2 && collinear(this.x[last-2], this.y[last-2], this.x[last-1], this.y[last-1], x , y)) { this.x[last-1] = x; //replace previous point this.y[last-1] = y; } else { needs(0, 1); //new point this.x[last] = x; this.y[last] = y; last++; } }
/** Adds point x, y at the beginning of the list */ public void prepend(int x, int y) { if (last-first>=2 && collinear(this.x[first+1], this.y[first+1], this.x[first], this.y[first], x , y)) { this.x[first] = x; //replace previous point this.y[first] = y; } else { needs(1, 0); //new point first--; this.x[first] = x; this.y[first] = y; } }