BreadcrumbItemDropDown.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:Eclipse-Postfix-Code-Completion 作者:
/**
 * Returns the monitor whose client area contains the given point. If no monitor contains the
 * point, returns the monitor that is closest to the point.
 * <p>
 * Copied from <code>org.eclipse.jface.window.Window.getClosestMonitor(Display, Point)</code>
 * </p>
 *
 * @param display the display showing the monitors
 * @param point point to find (display coordinates)
 * @return the monitor closest to the given point
 */
private static Monitor getClosestMonitor(Display display, Point point) {
    int closest= Integer.MAX_VALUE;

    Monitor[] monitors= display.getMonitors();
    Monitor result= monitors[0];

    for (int i= 0; i < monitors.length; i++) {
        Monitor current= monitors[i];

        Rectangle clientArea= current.getClientArea();

        if (clientArea.contains(point))
            return current;

        int distance= Geometry.distanceSquared(Geometry.centerPoint(clientArea), point);
        if (distance < closest) {
            closest= distance;
            result= current;
        }
    }

    return result;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号