/** * Add rectangle to the buffer without any checking */ public void addRect(int x1, int y1, int x2, int y2) { int i = rect[0]; rect = MultiRectAreaOp.checkBufSize(rect, 4); rect[i++] = x1; rect[i++] = y1; rect[i++] = x2; rect[i++] = y2; }
public void addLine(int[] points, int pointCount) { int bottomIndex = 0; int pointIndex = 0; int rectIndex = 0; int pointX1 = 0; int pointX2 = 0; int bottomX1 = 0; int bottomX2 = 0; bool appendRect = false; bool deleteRect = false; int lastCount = bottomCount; while (bottomIndex < lastCount || pointIndex < pointCount) { appendRect = false; deleteRect = false; if (bottomIndex < lastCount) { rectIndex = bottom[bottomIndex]; bottomX1 = rect[rectIndex]; bottomX2 = rect[rectIndex + 2]; } else { appendRect = true; } if (pointIndex < pointCount) { pointX1 = points[pointIndex]; pointX2 = points[pointIndex + 1]; } else { deleteRect = true; } if (!deleteRect && !appendRect) { if (pointX1 == bottomX1 && pointX2 == bottomX2) { rect[rectIndex + 3] = rect[rectIndex + 3] + 1; pointIndex += 2; bottomIndex++; continue; } deleteRect = pointX2 >= bottomX1; appendRect = pointX1 <= bottomX2; } if (deleteRect) { if (bottomIndex < bottomCount - 1) { java.lang.SystemJ.arraycopy(bottom, bottomIndex + 1, bottom, bottomIndex, bottomCount - bottomIndex - 1); rectIndex -= 4; } bottomCount--; lastCount--; } if (appendRect) { int i = rect[0]; bottom[bottomCount++] = i; rect = MultiRectAreaOp.checkBufSize(rect, 4); rect[i++] = pointX1; rect[i++] = lineY; rect[i++] = pointX2; rect[i++] = lineY; pointIndex += 2; } } lineY++; invalidate(); }