public int getX() { return _bounds.getX(); }
public int getMinX() { return _bounds.getX() - _bounds.getWidth() / 2; }
public int getMaxX() { return _bounds.getX() + _bounds.getWidth() / 2; }
private void localCopyBuffer(final ByteBuffer dataAsFloatBuffer, final Rectangle2 rectangle, final int xFrom, final int yFrom, final int xTo, final int yTo) { final int componentsTarget = useAlpha ? 4 : 3; final int sourceIndex = ((yFrom + rectangle.getY()) * atlasWidth + xFrom + rectangle.getX()) * componentsTarget; final int targetIndex = ((yTo + rectangle.getY()) * atlasWidth + xTo + rectangle.getX()) * componentsTarget; fillDataBuffer(dataAsFloatBuffer, dataAsFloatBuffer, sourceIndex, targetIndex, useAlpha); }
private void setDataPixel(final Rectangle2 rectangle, final int width, final int height, final ByteBuffer lightData, final ByteBuffer dataAsFloatBuffer, final int y, final int x, final boolean sourceAlpha) { final int componentsSource = sourceAlpha ? 4 : 3; final int componentsTarget = useAlpha ? 4 : 3; final int sourceIndex = (y * width + x) * componentsSource; final int targetIndex = ((y + rectangle.getY() + 1) * atlasWidth + x + rectangle.getX() + 1) * componentsTarget; fillDataBuffer(lightData, dataAsFloatBuffer, sourceIndex, targetIndex, sourceAlpha); }
private void setColor(final ByteBuffer dataAsFloatBuffer, final Rectangle2 rectangle, final int x, final int y, final ReadOnlyColorRGBA color) { final int componentsTarget = useAlpha ? 4 : 3; final int targetIndex = ((y + rectangle.getY()) * atlasWidth + x + rectangle.getX()) * componentsTarget; setColor(dataAsFloatBuffer, targetIndex, color, useAlpha); }
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; }
protected void addTiles(final Rectangle2 bounds, final Set<Tile> store) { for (int i = 0; i <= clipmapLevels; i++) { final double scale = 1.0 / (tileSize * MathUtils.pow2(i)); final int minX = (int) MathUtils.floor(bounds.getX() * scale); final int minY = (int) MathUtils.floor(bounds.getY() * scale); final int maxX = (int) MathUtils.floor((bounds.getX() + bounds.getWidth() - 1) * scale); final int maxY = (int) MathUtils.floor((bounds.getY() + bounds.getHeight() - 1) * scale); Tile tile; for (int y = minY; y <= maxY; y++) { for (int x = minX; x <= maxX; x++) { tile = new Tile(x, y); synchronized (store) { store.add(tile); } } } } }
protected void addTiles(final Rectangle2 bounds, final Set<Tile> store) { for (int i = 0; i <= clipmapLevels; i++) { final double scale = 1.0 / (tileSize * MathUtils.pow2(i)); final int minX = (int) MathUtils.floor(bounds.getX() * scale); final int minY = (int) MathUtils.floor(bounds.getY() * scale); final int maxX = (int) MathUtils.floor((bounds.getX() + bounds.getWidth() - 1) * scale); final int maxY = (int) MathUtils.floor((bounds.getY() + bounds.getHeight() - 1) * scale); Tile tile; for (int y = minY; y <= maxY; y++) { for (int x = minX; x <= maxX; x++) { tile = new Tile(x, y); synchronized (store) { store.add(tile); } } } } }
/** * Centers this component on the location of the given component. * * @param comp * the component to center on. */ public void centerOn(final UIComponent comp) { final Rectangle2 rectA = comp.getRelativeComponentBounds(null); final Rectangle2 rectB = getRelativeComponentBounds(null); int x = (rectA.getWidth() - rectB.getWidth()) / 2; int y = (rectA.getHeight() - rectB.getHeight()) / 2; x += comp.getHudX() - rectA.getX() + rectB.getX(); y += comp.getHudY() - rectA.getY() + rectB.getY(); setHudXY(x, y); }
final int posX = Math.round(dep.getTranslation().getXf()) + rect.getWidth() - rect.getX(); final int negX = Math.round(dep.getTranslation().getXf()) - rect.getX(); final int posY = Math.round(dep.getTranslation().getYf()) + rect.getHeight() - rect.getY(); final int negY = Math.round(dep.getTranslation().getYf()) - rect.getY();
/** * Centers this frame on the location of the given component. * * @param comp * the component to center on. */ public void setLocationRelativeTo(final UIComponent comp) { final Rectangle2 rectA = comp.getRelativeComponentBounds(null); final Rectangle2 rectB = getRelativeComponentBounds(null); int x = (rectA.getWidth() - rectB.getWidth()) / 2; int y = (rectA.getHeight() - rectB.getHeight()) / 2; x += comp.getHudX() - rectA.getX() + rectB.getX(); y += comp.getHudY() - rectA.getY() + rectB.getY(); setHudXY(x, y); updateGeometricState(0); }
/** * Centers this frame on the view of the camera * * @param cam * the camera to center on. */ public void centerOn(final UIHud hud) { final Rectangle2 rectA = getRelativeComponentBounds(null); int x = (hud.getWidth() - rectA.getWidth()) / 2; int y = (hud.getHeight() - rectA.getHeight()) / 2; x -= rectA.getX(); y -= rectA.getY(); setHudXY(x, y); }
/** * @param o * the object to compare for equality * @return true if this rectangle and the provided rectangle have the same origin and dimensions */ @Override public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof ReadOnlyRectangle2)) { return false; } final ReadOnlyRectangle2 comp = (ReadOnlyRectangle2) o; return comp.getX() == getX() && comp.getY() == getY() && comp.getWidth() == getWidth() && comp.getHeight() == getHeight(); }
/** * @param o * the object to compare for equality * @return true if this rectangle and the provided rectangle have the same origin and dimensions */ @Override public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof ReadOnlyRectangle2)) { return false; } final ReadOnlyRectangle2 comp = (ReadOnlyRectangle2) o; return comp.getX() == getX() && comp.getY() == getY() && comp.getWidth() == getWidth() && comp.getHeight() == getHeight(); }
/** * Centers this frame on the view of the camera * * @param cam * the camera to center on. */ public void setLocationRelativeTo(final Camera cam) { final Rectangle2 rectA = getRelativeComponentBounds(null); int x = (cam.getWidth() - rectA.getWidth()) / 2; int y = (cam.getHeight() - rectA.getHeight()) / 2; x -= rectA.getX(); y -= rectA.getY(); setHudXY(x, y); updateGeometricState(0); }
} else { setClippingEnabled(rendRecord, true); GL11C.glScissor(init.getX(), init.getY(), init.getWidth(), init.getHeight());
} else { setClippingEnabled(rendRecord, true); GL11.glScissor(init.getX(), init.getY(), init.getWidth(), init.getHeight());
@Test public void testIntersect() { final Rectangle2 rect1 = new Rectangle2(0, 0, 10, 10); final Rectangle2 rect2 = new Rectangle2(5, 5, 10, 10); Rectangle2 intersection = rect1.intersect(rect2, Rectangle2.fetchTempInstance()); assertTrue(5 == intersection.getX()); assertTrue(5 == intersection.getY()); assertTrue(5 == intersection.getWidth()); assertTrue(5 == intersection.getHeight()); Rectangle2.releaseTempInstance(intersection); assertNotNull(rect1.intersect(rect2, null)); intersection = Rectangle2.intersect(rect1, rect2, Rectangle2.fetchTempInstance()); assertTrue(5 == intersection.getX()); assertTrue(5 == intersection.getY()); assertTrue(5 == intersection.getWidth()); assertTrue(5 == intersection.getHeight()); Rectangle2.releaseTempInstance(intersection); assertNotNull(Rectangle2.intersect(rect1, rect2, null)); } }