Methods Summary |
---|
public void | add(org.apache.harmony.awt.gl.MultiRectArea mra)Union with another MultiRectArea object
setRect(union(this, mra).rect, false);
invalidate();
|
public void | add(java.awt.Rectangle rect)Union with Rectangle object
setRect(union(this, new MultiRectArea(rect)).rect, false);
invalidate();
|
public void | addRect(int x1, int y1, int x2, int y2)Add rectangle to the buffer without any checking
int i = rect[0];
rect = MultiRectAreaOp.checkBufSize(rect, 4);
rect[i++] = x1;
rect[i++] = y1;
rect[i++] = x2;
rect[i++] = y2;
|
static org.apache.harmony.awt.gl.MultiRectArea | check(org.apache.harmony.awt.gl.MultiRectArea mra, java.lang.String msg)Checks validation of MultiRectArea object
if (CHECK && mra != null) {
if (MultiRectArea.checkValidation(mra.getRectangles(), mra.sorted) != -1) {
// awt.4C=Invalid MultiRectArea in method {0}
new RuntimeException(Messages.getString("awt.4C", msg)); //$NON-NLS-1$
}
}
return mra;
|
public static int | checkValidation(java.awt.Rectangle[] r, boolean sorted)Checks validation of MultiRectArea object
// Check width and height
for(int i = 0; i < r.length; i++) {
if (r[i].width <= 0 || r[i].height <= 0) {
return i;
}
}
// Check order
if (sorted) {
for(int i = 1; i < r.length; i++) {
if (r[i - 1].y > r[i].y) {
return i;
}
if (r[i - 1].y == r[i].y) {
if (r[i - 1].x > r[i].x) {
return i;
}
}
}
}
// Check override
for(int i = 0; i < r.length; i++) {
for(int j = i + 1; j < r.length; j++) {
if (r[i].intersects(r[j])) {
return i;
}
}
}
return -1;
|
public boolean | contains(double x, double y)Tests does point lie inside MultiRectArea object
for(int i = 1; i < rect[0]; i+= 4) {
if (rect[i] <= x && x <= rect[i + 2] && rect[i + 1] <= y && y <= rect[i + 3]) {
return true;
}
}
return false;
|
public boolean | contains(java.awt.geom.Point2D p)Tests does Point2D lie inside MultiRectArea object
return contains(p.getX(), p.getY());
|
public boolean | contains(double x, double y, double w, double h)Tests does rectangle lie inside MultiRectArea object
throw new RuntimeException("Not implemented"); //$NON-NLS-1$
|
public boolean | contains(java.awt.geom.Rectangle2D r)Tests does Rectangle2D lie inside MultiRectArea object
throw new RuntimeException("Not implemented"); //$NON-NLS-1$
|
public boolean | equals(java.lang.Object obj)Tests equals with another object
if (obj == this) {
return true;
}
if (obj instanceof MultiRectArea) {
MultiRectArea mra = (MultiRectArea) obj;
for(int i = 0; i < rect[0]; i++) {
if (rect[i] != mra.rect[i]) {
return false;
}
}
return true;
}
return false;
|
public java.awt.Rectangle | getBounds()Returns bounds of MultiRectArea object
if (bounds != null) {
return bounds;
}
if (isEmpty()) {
return bounds = new Rectangle();
}
int x1 = rect[1];
int y1 = rect[2];
int x2 = rect[3];
int y2 = rect[4];
for(int i = 5; i < rect[0]; i += 4) {
int rx1 = rect[i + 0];
int ry1 = rect[i + 1];
int rx2 = rect[i + 2];
int ry2 = rect[i + 3];
if (rx1 < x1) {
x1 = rx1;
}
if (rx2 > x2) {
x2 = rx2;
}
if (ry1 < y1) {
y1 = ry1;
}
if (ry2 > y2) {
y2 = ry2;
}
}
return bounds = new Rectangle(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
|
public java.awt.geom.Rectangle2D | getBounds2D()Returns Bounds2D
return getBounds();
|
public java.awt.geom.PathIterator | getPathIterator(java.awt.geom.AffineTransform t, double flatness)Returns path iterator
return new Iterator(this, t);
|
public java.awt.geom.PathIterator | getPathIterator(java.awt.geom.AffineTransform t)Returns path iterator
return new Iterator(this, t);
|
public int | getRectCount()Recturn rectangle count in the buffer
return (rect[0] - 1) / 4;
|
public java.awt.Rectangle[] | getRectangles()Returns Rectangle array
if (rectangles != null) {
return rectangles;
}
rectangles = new Rectangle[(rect[0] - 1) / 4];
int j = 0;
for(int i = 1; i < rect[0]; i += 4) {
rectangles[j++] = new Rectangle(
rect[i],
rect[i + 1],
rect[i + 2] - rect[i] + 1,
rect[i + 3] - rect[i + 1] + 1);
}
return rectangles;
|
public void | intersect(org.apache.harmony.awt.gl.MultiRectArea mra)Intersect with another MultiRectArea object
setRect(intersect(this, mra).rect, false);
invalidate();
|
public void | intersect(java.awt.Rectangle rect)Intersect with Rectangle object
setRect(intersect(this, new MultiRectArea(rect)).rect, false);
invalidate();
|
public static org.apache.harmony.awt.gl.MultiRectArea | intersect(org.apache.harmony.awt.gl.MultiRectArea src1, org.apache.harmony.awt.gl.MultiRectArea src2)Union two MutliRectareArea objects
MultiRectArea res = check(MultiRectAreaOp.Intersection.getResult(src1, src2), "intersect(MRA,MRA)"); //$NON-NLS-1$
return res;
|
public boolean | intersects(double x, double y, double w, double h)Tests does rectangle intersect MultiRectArea object
Rectangle r = new Rectangle();
r.setRect(x, y, w, h);
return intersects(r);
|
public boolean | intersects(java.awt.geom.Rectangle2D r)Tests does Rectangle2D intersect MultiRectArea object
if (r == null || r.isEmpty()) {
return false;
}
for(int i = 1; i < rect[0]; i+= 4) {
if (r.intersects(rect[i], rect[i+1], rect[i + 2]-rect[i]+1, rect[i + 3]-rect[i + 1]+1)) {
return true;
}
}
return false;
|
void | invalidate()
bounds = null;
rectangles = null;
|
public boolean | isEmpty()Tests is MultiRectArea empty
return rect[0] == 1;
|
public static void | print(org.apache.harmony.awt.gl.MultiRectArea mra, java.lang.String msg)Print MultiRectArea object to output stream
if (mra == null) {
System.out.println(msg + "=null"); //$NON-NLS-1$
} else {
Rectangle[] rects = mra.getRectangles();
System.out.println(msg + "(" + rects.length + ")"); //$NON-NLS-1$ //$NON-NLS-2$
for (Rectangle element : rects) {
System.out.println(
element.x + "," + //$NON-NLS-1$
element.y + "," + //$NON-NLS-1$
(element.x + element.width - 1) + "," + //$NON-NLS-1$
(element.y + element.height - 1));
}
}
|
void | resort()Sort rectangle buffer
int[] buf = new int[4];
for(int i = 1; i < rect[0]; i += 4) {
int k = i;
int x1 = rect[k];
int y1 = rect[k + 1];
for(int j = i + 4; j < rect[0]; j += 4) {
int x2 = rect[j];
int y2 = rect[j + 1];
if (y1 > y2 || (y1 == y2 && x1 > x2)) {
x1 = x2;
y1 = y2;
k = j;
}
}
if (k != i) {
System.arraycopy(rect, i, buf, 0, 4);
System.arraycopy(rect, k, rect, i, 4);
System.arraycopy(buf, 0, rect, k, 4);
}
}
invalidate();
|
protected void | setRect(int[] buf, boolean copy)Assigns rectangle from another buffer
if (copy) {
rect = new int[buf.length];
System.arraycopy(buf, 0, rect, 0, buf.length);
} else {
rect = buf;
}
invalidate();
|
public void | substract(org.apache.harmony.awt.gl.MultiRectArea mra)Subtract another MultiRectArea object
setRect(subtract(this, mra).rect, false);
invalidate();
|
public void | substract(java.awt.Rectangle rect)Subtract rectangle object
setRect(subtract(this, new MultiRectArea(rect)).rect, false);
|
public static org.apache.harmony.awt.gl.MultiRectArea | subtract(org.apache.harmony.awt.gl.MultiRectArea src1, org.apache.harmony.awt.gl.MultiRectArea src2)Subtract two MultiRectArea objects
MultiRectArea res = check(MultiRectAreaOp.Subtraction.getResult(src1, src2), "subtract(MRA,MRA)"); //$NON-NLS-1$
return res;
|
public java.lang.String | toString()Returns MultiRectArea object converted to string
int cnt = getRectCount();
StringBuffer sb = new StringBuffer((cnt << 5) + 128);
sb.append(getClass().getName()).append(" ["); //$NON-NLS-1$
for(int i = 1; i < rect[0]; i += 4) {
sb.append(i > 1 ? ", [" : "[").append(rect[i]).append(", ").append(rect[i + 1]). //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
append(", ").append(rect[i + 2] - rect[i] + 1).append(", "). //$NON-NLS-1$ //$NON-NLS-2$
append(rect[i + 3] - rect[i + 1] + 1).append("]"); //$NON-NLS-1$
}
return sb.append("]").toString(); //$NON-NLS-1$
|
public void | translate(int x, int y)Translate MultiRectArea object by (x, y)
for(int i = 1; i < rect[0];) {
rect[i++] += x;
rect[i++] += y;
rect[i++] += x;
rect[i++] += y;
}
if (bounds != null && !bounds.isEmpty()) {
bounds.translate(x, y);
}
if (rectangles != null) {
for (Rectangle element : rectangles) {
element.translate(x, y);
}
}
|
public static org.apache.harmony.awt.gl.MultiRectArea | union(org.apache.harmony.awt.gl.MultiRectArea src1, org.apache.harmony.awt.gl.MultiRectArea src2)Intersect two MultiRectArea objects
MultiRectArea res = check(new MultiRectAreaOp.Union().getResult(src1, src2), "union(MRA,MRA)"); //$NON-NLS-1$
return res;
|