/** * 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; }
/** * Constructs a new MultiRectArea consists of single rectangle */ public MultiRectArea(int x0, int y0, int x1, int y1) { rect = MultiRectAreaOp.createBuf(0); if (x1 >= x0 && y1 >= y0) { rect[0] = 5; rect[1] = x0; rect[2] = y0; rect[3] = x1; rect[4] = y1; } check(this, "MultiRectArea(Rectangle)"); //$NON-NLS-1$ }
/** * Constructs a new MultiRectArea consists of single rectangle */ public MultiRectArea(java.awt.Rectangle r) { rect = MultiRectAreaOp.createBuf(0); if (r != null && !r.isEmpty()) { rect[0] = 5; rect[1] = r.x; rect[2] = r.y; rect[3] = r.x + r.width - 1; rect[4] = r.y + r.height - 1; } check(this, "MultiRectArea(Rectangle)"); //$NON-NLS-1$ }
/** * Constructs a new MultiRectArea as a copy of another one */ public MultiRectArea(MultiRectArea mra) { if (mra == null) { rect = MultiRectAreaOp.createBuf(0); } else { rect = new int[mra.rect.Length]; java.lang.SystemJ.arraycopy(mra.rect, 0, rect, 0, mra.rect.Length); check(this, "MultiRectArea(MRA)"); //$NON-NLS-1$ } }
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(); }
/** * Constructs a new empty MultiRectArea */ public MultiRectArea() { rect = MultiRectAreaOp.createBuf(0); }