@Test public void testIntersects() throws Exception { Viewport a = new Viewport(30, 100, 3, 3); Viewport copy = new Viewport(a); assertTrue("inside", a.intersects(new Viewport(31, 101, 1, 1))); assertTrue("overlap east", a.intersects(new Viewport(31, 102, 1, 2))); assertTrue("overlap west", a.intersects(new Viewport(31, 99, 1, 2))); assertTrue("overlap north", a.intersects(new Viewport(32, 101, 2, 1))); assertTrue("overlap south", a.intersects(new Viewport(29, 101, 2, 1))); assertEquals("no mutation", copy, a); }
public boolean intersects(int x, int y, int width, int height) { return this.width > 0 && this.height > 0 && width > 0 && height > 0 && this.x < (x + width) && x < (this.x + this.width) && this.y < (y + height) && y < (this.y + this.height); }
Viewport { public boolean intersects(int x, int y, int width, int height) { return this.width > 0 && this.height > 0 && width > 0 && height > 0 && this.x < (x + width) && x < (this.x + this.width) && this.y < (y + height) && y < (this.y + this.height); } }
Viewport { public boolean intersects(int x, int y, int width, int height) { return this.width > 0 && this.height > 0 && width > 0 && height > 0 && this.x < (x + width) && x < (this.x + this.width) && this.y < (y + height) && y < (this.y + this.height); } Viewport();  Viewport(int x, int y, int width, int height);  Viewport(Viewport viewport); }
Viewport { public boolean intersects(int x, int y, int width, int height) { return this.width > 0 && this.height > 0 && width > 0 && height > 0 && this.x < (x + width) && x < (this.x + this.width) && this.y < (y + height) && y < (this.y + this.height); } Viewport();  Viewport(int x, int y, int width, int height);  Viewport(Viewport viewport); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Viewport set(int x, int y, int width, int height); Viewport set(Viewport viewport); Viewport setEmpty(); boolean isEmpty(); boolean intersects(int x, int y, int width, int height); @SuppressWarnings("UnnecessaryLocalVariable") boolean intersects(Viewport viewport); boolean intersect(int x, int y, int width, int height); @SuppressWarnings("UnnecessaryLocalVariable") boolean intersect(Viewport viewport); boolean contains(int x, int y); }
Viewport { public boolean intersects(int x, int y, int width, int height) { return this.width > 0 && this.height > 0 && width > 0 && height > 0 && this.x < (x + width) && x < (this.x + this.width) && this.y < (y + height) && y < (this.y + this.height); } Viewport();  Viewport(int x, int y, int width, int height);  Viewport(Viewport viewport); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Viewport set(int x, int y, int width, int height); Viewport set(Viewport viewport); Viewport setEmpty(); boolean isEmpty(); boolean intersects(int x, int y, int width, int height); @SuppressWarnings("UnnecessaryLocalVariable") boolean intersects(Viewport viewport); boolean intersect(int x, int y, int width, int height); @SuppressWarnings("UnnecessaryLocalVariable") boolean intersect(Viewport viewport); boolean contains(int x, int y); public int x; public int y; public int width; public int height; }