Java Utililty Methods Rectangle

List of utility methods to do Rectangle

  1. HOME
  2. Java
  3. R
  4. Rectangle

Description

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

Method

void addTo(Insets i1, Insets i2)
add To
i2.top += i1.top;
i2.left += i1.left;
i2.bottom += i1.bottom;
i2.right += i1.right;
void alignComponentsBaseHorizontal(Component left, Component right)
align Components Base Horizontal
Rectangle leftBounds = left.getBounds();
Rectangle rightBounds = right.getBounds();
leftBounds.y = rightBounds.y + rightBounds.height - leftBounds.height;
left.setBounds(leftBounds);
boolean alignsVertically(Rectangle r1, Rectangle r2)
aligns Vertically
return r1.getMaxX() == r2.getMaxX() && r1.getMinX() == r2.getMinX();
void clip(int x, int y, int w, int h)
clip
cX = x;
cY = y;
cW = w;
cH = h;
clip.x = x;
clip.y = y;
clip.width = w;
clip.height = h;
...
Rectangle[] computeDifference(Rectangle rectA, Rectangle rectB)
Subtracts a rectangle from another and return the area as an array of rectangles.
if (rectA == null || rectB == null)
 return new Rectangle[0];
Rectangle[] r = new Rectangle[4];
int x1 = rectA.x;
int y1 = rectA.y;
int w1 = rectA.width;
int h1 = rectA.height;
int x2 = rectB.x;
...
Rectangle expand(final Rectangle rect, final int expansion)
Returns rectangle expanded in four directions for the specified value.
return expand(rect, expansion, expansion, expansion, expansion);
Rectangle expand(Rectangle rect, int amount)
expand
return new Rectangle(rect.x - amount, rect.y - amount, rect.width + amount * 2, rect.height + amount * 2);
void expand(Rectangle rectangle, int expansion)
expand
rectangle.x -= expansion;
rectangle.y -= expansion;
rectangle.width += expansion * 2;
rectangle.height += expansion * 2;
boolean firstSmallerThanSecond(java.awt.Rectangle first, java.awt.Rectangle second)
first Smaller Than Second
int areaFirst = (int) (first.getSize().getHeight() * first.getSize().getWidth());
int areaSecond = (int) (second.getSize().getHeight() * second.getSize().getWidth());
return areaFirst < areaSecond;
Rectangle flip(Dimension view, Rectangle rect, int direction)
flip
boolean flipHorizontal = (direction & 1) == 1;
boolean flipVertical = (direction & 2) == 2;
int x = flipHorizontal ? view.width - (rect.x + rect.width) : rect.x;
int y = flipVertical ? view.height - (rect.y + rect.height) : rect.y;
System.out.println(rect + " - " + new Rectangle(x, y, rect.width, rect.height));
return new Rectangle(x, y, rect.width, rect.height);


AltStyle によって変換されたページ (->オリジナル) /