public void addPoint(float x, float y) {
if (npoints >= xpoints.length || npoints >= ypoints.length) {
int newLength = npoints * 2;
if (newLength < MIN_LENGTH) {
newLength = MIN_LENGTH;
} else if ((newLength & (newLength - 1)) != 0) {
newLength = Integer.highestOneBit(newLength);
}
float[] helper = new float[newLength];
System.arraycopy(xpoints, 0, helper, 0,
npoints);
xpoints = helper;
helper = new float[newLength];
System.arraycopy(ypoints, 0, helper, 0,
npoints);
ypoints = helper;
}
xpoints[npoints] = x;
ypoints[npoints] = y;
npoints++;
if (bounds != null) {
updateBounds(x, y);
}
}