Java Utililty Methods Rectangle Bounds

List of utility methods to do Rectangle Bounds

Description

The list of methods to do Rectangle Bounds are organized into topic(s).

Method

StringencodeBounds(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;
ElementexportBounds(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;
...
RectanglegetBounds(Shape s)
get Bounds
return (s instanceof Rectangle) ? (Rectangle) s : s.getBounds();
RectanglegetBoundsInAncestor(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;
RectanglegetCenteredBoundsOn(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);
RectanglegetLocalBounds(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);
RectanglegetLocalBounds(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;
RectanglegetRectangleListBounds(Vector vctRectangles)
Return a rectangle that encapsulates all rectangles in the Vector.
return getRectangleListBounds(vctRectangles.elements());
booleanisInCollision(Rectangle boundedBoxPlayer, Rectangle boundedBoxObject)
is In Collision
boolean collided = false;
if (boundedBoxObject.intersects(boundedBoxPlayer))
    collided = true;
return collided;
voidsetBounds(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);
...