Java Rectangle Intersect intersects(final Rectangle elementRect, final Rectangle viewportRect)

Here you can find the source of intersects(final Rectangle elementRect, final Rectangle viewportRect)

Description

intersects

License

Open Source License

Declaration

private static boolean intersects(final Rectangle elementRect, final Rectangle viewportRect) 

Method Source Code

//package com.java2s;

import java.awt.*;

public class Main {
    private static boolean intersects(final Rectangle elementRect, final Rectangle viewportRect) {
        // check the location of the top of the element
        if ((elementRect.y < viewportRect.y) || (elementRect.y > viewportRect.y + viewportRect.height)) {
            return false;
        }//from www. j a  v a  2  s  .  c  om

        // check the location of the bottom of the element
        if ((elementRect.y + elementRect.height < viewportRect.y)
                || (elementRect.y + elementRect.height > viewportRect.y + viewportRect.height)) {
            return false;
        }

        return true;
    }
}

Related

  1. intersection(Rectangle rectangle, Rectangle rectangle1, Rectangle rectangle2)
  2. intersectRect(double x1, double y1, double w1, double h1, double x2, double y2, double w2, double h2)
  3. intersects(double oldx, double oldy, double oldwidth, double oldheight, double oldx2, double oldy2, double oldwidth2, double oldheight2)
  4. intersects(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
  5. intersects(final float x, final float y, final float z, final int sx, final int sy, final int sz)
  6. intersects(final Rectangle2D a, final Rectangle2D b)
  7. intersects(float cx, float cy, float radius, float left, float top, float right, float bottom)
  8. intersects(Point p1, Point p2, Rectangle rect)
  9. intersects(Rectangle aRectangle, Line2D aLine)