List of utility methods to do Rectangle Bounds
String | encodeBounds(Rectangle rBounds) * Encode the bounds of a component into a comma separated list * that is appropriate for storing in a Properties object. return "" + rBounds.x + "," + rBounds.y + "," + rBounds.width + "," + rBounds.height; |
Element | exportBounds(Frame theFame, Document doc) Extracts the bounds information from a given Frame and returns the XML representation thereof. Element ret = doc.createElement("Bounds"); ret.setAttribute("Maximized", String.valueOf(((theFame.getExtendedState() & Frame.MAXIMIZED_BOTH) != 0))); Rectangle bounds = theFame.getBounds(); ret.setAttribute("X", String.valueOf((int) bounds.getX())); ret.setAttribute("Y", String.valueOf((int) bounds.getY())); ret.setAttribute("Width", String.valueOf((int) bounds.getWidth())); ret.setAttribute("Height", String.valueOf((int) bounds.getHeight())); return ret; ... |
Rectangle | getBounds(Shape s) get Bounds return (s instanceof Rectangle) ? (Rectangle) s : s.getBounds(); |
Rectangle | getBoundsInAncestor(Container ancestor, final Component comp, Rectangle bounds) get Bounds In Ancestor bounds = comp.getBounds(bounds); Container parent = comp.getParent(); while (parent != null && parent != ancestor) { bounds.translate(parent.getX(), parent.getY()); parent = parent.getParent(); return bounds; |
Rectangle | getCenteredBoundsOn(Rectangle srcBounds, int width, int height) get Centered Bounds On return new Rectangle(srcBounds.x + (srcBounds.width - width) / 2, srcBounds.y + (srcBounds.height - height) / 2, width, height); |
Rectangle | getLocalBounds(Component aComponent) Calculates the bounds of a component in the component's own coordinate space. Rectangle bounds = aComponent.getBounds(); return new Rectangle(0, 0, bounds.width, bounds.height); |
Rectangle | getLocalBounds(Rectangle bounds, Container c) This returns the "local" bounds of a component. if (bounds == null) bounds = new Rectangle(); Insets insets = c.getInsets(); bounds.setBounds(0, 0, c.getWidth() - (insets.left + insets.right), c.getHeight() - (insets.top + insets.bottom)); return bounds; |
Rectangle | getRectangleListBounds(Vector vctRectangles) Return a rectangle that encapsulates all rectangles in the Vector. return getRectangleListBounds(vctRectangles.elements());
|
boolean | isInCollision(Rectangle boundedBoxPlayer, Rectangle boundedBoxObject) is In Collision boolean collided = false; if (boundedBoxObject.intersects(boundedBoxPlayer)) collided = true; return collided; |
void | setBounds(Container container, Component component, Rectangle bounds) set Bounds if (container.getComponentOrientation().isLeftToRight()) { component.setBounds(bounds); else { Rectangle r = new Rectangle(bounds); int w = container.getWidth(); r.x = (w - (bounds.x + bounds.width)); component.setBounds(r); ... |