@Override public Rectangle2 clone() { return new Rectangle2(this); }
@Override public Rectangle2 clone() { return new Rectangle2(this); }
public AtlasNode(final int width, final int height) { localRectangle = new Rectangle2(0, 0, width, height); }
/** * @return An instance of Rectangle2 that is intended for temporary use in calculations and so forth. Multiple calls * to the method should return instances of this class that are not currently in use. */ public final static Rectangle2 fetchTempInstance() { if (MathConstants.useMathPools) { return Rectangle2.RECTANGLE_POOL.fetch(); } else { return new Rectangle2(); } }
/** * @return An instance of Rectangle2 that is intended for temporary use in calculations and so forth. Multiple calls * to the method should return instances of this class that are not currently in use. */ public final static Rectangle2 fetchTempInstance() { if (MathConstants.useMathPools) { return Rectangle2.RECTANGLE_POOL.fetch(); } else { return new Rectangle2(); } }
public AtlasNode insert(final int width, final int height) { return rootNode.insert(new Rectangle2(0, 0, width, height)); }
private int getSumOfAllWidths(final List<Spatial> content) { int sum = 0; if (content != null) { final Rectangle2 store = new Rectangle2(); for (final Spatial spat : content) { if (spat instanceof UIComponent) { final Rectangle2 rect = ((UIComponent) spat).getRelativeMinComponentBounds(store); sum += rect.getWidth(); } } } return sum; }
public static Rectangle2 intersect(final ReadOnlyRectangle2 src1, final ReadOnlyRectangle2 src2, final Rectangle2 store) { Rectangle2 rVal = store; if (rVal == null) { rVal = new Rectangle2(); } rVal.set(src1); return rVal.intersect(src2, rVal); }
public static Rectangle2 intersect(final ReadOnlyRectangle2 src1, final ReadOnlyRectangle2 src2, final Rectangle2 store) { Rectangle2 rVal = store; if (rVal == null) { rVal = new Rectangle2(); } rVal.set(src1); return rVal.intersect(src2, rVal); }
private int getSumOfAllHeights(final List<Spatial> content) { int sum = 0; if (content != null) { final Rectangle2 store = new Rectangle2(); for (final Spatial spat : content) { if (spat instanceof UIComponent) { final Rectangle2 rect = ((UIComponent) spat).getRelativeMinComponentBounds(store); sum += rect.getHeight(); } } } return sum; }
private int getSumOfAllHeights(final List<Spatial> content) { int sum = 0; if (content != null) { final Rectangle2 store = new Rectangle2(); for (final Spatial spat : content) { if (spat instanceof UIComponent) { final Rectangle2 rect = ((UIComponent) spat).getRelativeMinComponentBounds(store); sum += rect.getHeight(); } } } return sum; }
private int getSumOfAllWidths(final List<Spatial> content) { int sum = 0; if (content != null) { final Rectangle2 store = new Rectangle2(); for (final Spatial spat : content) { if (spat instanceof UIComponent) { final Rectangle2 rect = ((UIComponent) spat).getRelativeMinComponentBounds(store); sum += rect.getWidth(); } } } return sum; } }
/** * * @param store * the object to store our results in. If null, a new Rectangle2 is created and returned. * @return the current bounds of this component, in the coordinate space of its parent. */ public Rectangle2 getRelativeComponentBounds(final Rectangle2 store) { Rectangle2 rVal = store; if (rVal == null) { rVal = new Rectangle2(); } final int height = getLocalComponentHeight(); final int width = getLocalComponentWidth(); return getRelativeComponentBounds(rVal, width, height); }
/** * * @param store * the object to store our results in. If null, a new Rectangle2 is created and returned. * @return */ public Rectangle2 getRelativeMaxComponentBounds(final Rectangle2 store) { Rectangle2 rVal = store; if (rVal == null) { rVal = new Rectangle2(); } final int height = getMaximumLocalComponentHeight(); final int width = getMaximumLocalComponentWidth(); return getRelativeComponentBounds(rVal, width, height); }
/** * * @param store * the object to store our results in. If null, a new Rectangle2 is created and returned. * @return */ public Rectangle2 getRelativeMinComponentBounds(final Rectangle2 store) { Rectangle2 rVal = store; if (rVal == null) { rVal = new Rectangle2(); } final int height = getMinimumLocalComponentHeight(); final int width = getMinimumLocalComponentWidth(); return getRelativeComponentBounds(rVal, width, height); }
/** * * @param store * the object to store our results in. If null, a new Rectangle2 is created and returned. * @return */ public Rectangle2 getRelativeMaxComponentBounds(final Rectangle2 store) { Rectangle2 rVal = store; if (rVal == null) { rVal = new Rectangle2(); } final int height = getMaximumLocalComponentHeight(); final int width = getMaximumLocalComponentWidth(); return getRelativeComponentBounds(rVal, width, height); }
public Rectangle2 intersect(final ReadOnlyRectangle2 other, final Rectangle2 store) { Rectangle2 rVal = store; if (rVal == null) { rVal = new Rectangle2(); } final int x1 = Math.max(getX(), other.getX()); final int y1 = Math.max(getY(), other.getY()); final int x2 = Math.min(getX() + getWidth(), other.getX() + other.getWidth()); final int y2 = Math.min(getY() + getHeight(), other.getY() + other.getHeight()); rVal.set(x1, y1, x2 - x1, y2 - y1); return rVal; }
public Rectangle2 intersect(final ReadOnlyRectangle2 other, final Rectangle2 store) { Rectangle2 rVal = store; if (rVal == null) { rVal = new Rectangle2(); } final int x1 = Math.max(getX(), other.getX()); final int y1 = Math.max(getY(), other.getY()); final int x2 = Math.min(getX() + getWidth(), other.getX() + other.getWidth()); final int y2 = Math.min(getY() + getHeight(), other.getY() + other.getHeight()); rVal.set(x1, y1, x2 - x1, y2 - y1); return rVal; }
@Test public void testSimpleHash() { // Just a simple sanity check. final Rectangle2 rect1 = new Rectangle2(1, 2, 0, 0); final Rectangle2 rect2 = new Rectangle2(1, 2, 0, 0); final Rectangle2 rect3 = new Rectangle2(2, 2, 0, 0); assertTrue(rect1.hashCode() == rect2.hashCode()); assertTrue(rect1.hashCode() != rect3.hashCode()); }
@Test public void testClone() { final Rectangle2 rect1 = new Rectangle2(); final Rectangle2 rect2 = rect1.clone(); assertEquals(rect1, rect2); assertNotSame(rect1, rect2); }