/** 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); } }
/** 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; } }
/** 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 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++; } }