Java Rectangle Intersect intersection(Rectangle rectangle, Rectangle rectangle1, Rectangle rectangle2)

Here you can find the source of intersection(Rectangle rectangle, Rectangle rectangle1, Rectangle rectangle2)

Description

intersection

License

Apache License

Declaration

public static void intersection(Rectangle rectangle, Rectangle rectangle1, Rectangle rectangle2) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.awt.Rectangle;

public class Main {
    public static void intersection(Rectangle rectangle, Rectangle rectangle1, Rectangle rectangle2) {
        int i = rectangle.x;
        int j = rectangle.y;
        int k = rectangle1.x;
        int l = rectangle1.y;
        int i1 = i;
        i1 += rectangle.width;/*w w w.j  a v  a  2  s.c o  m*/
        int j1 = j;
        j1 += rectangle.height;
        int k1 = k;
        k1 += rectangle1.width;
        int l1 = l;
        l1 += rectangle1.height;
        if (i < k)
            i = k;
        if (j < l)
            j = l;
        if (i1 > k1)
            i1 = k1;
        if (j1 > l1)
            j1 = l1;
        i1 -= i;
        j1 -= j;
        if (i1 < 0x80000000)
            i1 = 0x80000000;
        if (j1 < 0x80000000)
            j1 = 0x80000000;
        rectangle2.setBounds(i, j, i1, j1);
    }
}

Related

  1. getMaxIntersection(List targetRects, Rectangle rect)
  2. intersect(Rectangle r1, Rectangle r2, Rectangle result)
  3. intersect(Rectangle rect1, Rectangle rect2)
  4. intersection(Line2D.Double line, Rectangle2D.Double bounds)
  5. intersection(Rectangle r1, Rectangle r2, Rectangle out)
  6. intersectRect(double x1, double y1, double w1, double h1, double x2, double y2, double w2, double h2)
  7. intersects(double oldx, double oldy, double oldwidth, double oldheight, double oldx2, double oldy2, double oldwidth2, double oldheight2)
  8. intersects(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
  9. intersects(final float x, final float y, final float z, final int sx, final int sy, final int sz)