Java Area Intersect intersects(Area lhs, Area rhs)

Here you can find the source of intersects(Area lhs, Area rhs)

Description

intersects

License

Open Source License

Declaration

public static boolean intersects(Area lhs, Area rhs) 

Method Source Code

//package com.java2s;
/*/*from w ww  .  j a v  a2  s.co  m*/
 * This software copyright by various authors including the RPTools.net
 * development team, and licensed under the LGPL Version 3 or, at your option,
 * any later version.
 * 
 * Portions of this software were originally covered under the Apache Software
 * License, Version 1.1 or Version 2.0.
 * 
 * See the file LICENSE elsewhere in this distribution for license details.
 */

import java.awt.geom.Area;

public class Main {
    public static boolean intersects(Area lhs, Area rhs) {
        if (lhs == null || lhs.isEmpty() || rhs == null || rhs.isEmpty()) {
            return false;
        }
        if (!lhs.getBounds().intersects(rhs.getBounds())) {
            return false;
        }
        Area newArea = new Area(lhs);
        newArea.intersect(rhs);
        return !newArea.isEmpty();
    }
}

Related

  1. intersection(Area a1, Area a2)
  2. intersects(Area a, Area b)