⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swtrectangleutil.java

📁 JPowerGraph is a Java library for creating directed graphs for SWT. It supports graph movement, sele
💻 JAVA
字号:
package net.sourceforge.jpowergraph.pane;

import org.eclipse.swt.graphics.Rectangle;

/**
 * @author Mick Kerrigan
 *
 * Created on 29-Jul-2005
 * Committed by $Author: morcen $
 *
 * $Source: /cvsroot/jpowergraph/swt/src/net/sourceforge/jpowergraph/pane/SWTRectangleUtil.java,v $,
 * @version $Revision: 1.1 $ $Date: 2005/08/09 12:49:25 $
 */
public class SWTRectangleUtil {

    public static boolean contains(Rectangle r1, Rectangle r2) {
        int w = r2.width;
        int h = r2.height;
        if ((w | h | r1.width | r1.height) < 0) {
            // At least one of the dimensions is negative...
            return false;
        }
        // Note: if any dimension is zero, tests below must return false...
        int x = r2.x;
        int y = r2.y;
        if (r1.x < x || r1.y < y) {
            return false;
        }
        w += x;
        r1.width += r1.x;
        if (r1.width <= r1.x) {
            // X+W overflowed or W was zero, return false if...
            // either original w or W was zero or
            // x+w did not overflow or
            // the overflowed x+w is smaller than the overflowed X+W
            if (w >= x || r1.width > w)
                return false;
        }
        else {
            // X+W did not overflow and W was not zero, return false if...
            // original w was zero or
            // x+w did not overflow and x+w is smaller than X+W
            if (w >= x && r1.width > w)
                return false;
        }
        h += y;
        r1.height += r1.y;
        if (r1.height <= r1.y) {
            if (h >= y || r1.height > h)
                return false;
        }
        else {
            if (h >= y && r1.height > h)
                return false;
        }
        return true;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -