org.eclipse.jface.util.Geometry.getDistanceFromEdge()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.eclipse.jface.util.Geometry.getDistanceFromEdge()方法的一些代码示例,展示了Geometry.getDistanceFromEdge()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.getDistanceFromEdge()方法的具体详情如下:
包路径:org.eclipse.jface.util.Geometry
类名称:Geometry
方法名:getDistanceFromEdge

Geometry.getDistanceFromEdge介绍

[英]Returns the distance of the given point from a particular side of the given rectangle. Returns negative values for points outside the rectangle.
[中]返回给定点到给定矩形特定边的距离。为矩形外的点返回负值。

代码示例

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * Returns the edge of the given rectangle is closest to the given
 * point.
 *
 * @param boundary rectangle to test
 * @param toTest point to compare
 * @return one of SWT.LEFT, SWT.RIGHT, SWT.TOP, or SWT.BOTTOM
 *
 * @since 3.0
 */
public static int getClosestSide(Rectangle boundary, Point toTest) {
  int[] sides = new int[] { SWT.LEFT, SWT.RIGHT, SWT.TOP, SWT.BOTTOM };
  int closestSide = SWT.LEFT;
  int closestDistance = Integer.MAX_VALUE;
  for (int idx = 0; idx < sides.length; idx++) {
    int side = sides[idx];
    int distance = getDistanceFromEdge(boundary, toTest, side);
    if (distance < closestDistance) {
      closestDistance = distance;
      closestSide = side;
    }
  }
  return closestSide;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

/**
 * Returns the edge of the given rectangle is closest to the given
 * point.
 *
 * @param boundary rectangle to test
 * @param toTest point to compare
 * @return one of SWT.LEFT, SWT.RIGHT, SWT.TOP, or SWT.BOTTOM
 *
 * @since 3.0
 */
public static int getClosestSide(Rectangle boundary, Point toTest) {
  int[] sides = new int[] { SWT.LEFT, SWT.RIGHT, SWT.TOP, SWT.BOTTOM };
  int closestSide = SWT.LEFT;
  int closestDistance = Integer.MAX_VALUE;
  for (int side : sides) {
    int distance = getDistanceFromEdge(boundary, toTest, side);
    if (distance < closestDistance) {
      closestDistance = distance;
      closestSide = side;
    }
  }
  return closestSide;
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

/**
 * Returns the edge of the given rectangle is closest to the given
 * point.
 * 
 * @param boundary rectangle to test
 * @param toTest point to compare
 * @return one of SWT.LEFT, SWT.RIGHT, SWT.TOP, or SWT.BOTTOM
 * 
 * @since 1.0
 */
public static int getClosestSide(Rectangle boundary, Point toTest) {
  int[] sides = new int[] { SWT.LEFT, SWT.RIGHT, SWT.TOP, SWT.BOTTOM };
  int closestSide = SWT.LEFT;
  int closestDistance = Integer.MAX_VALUE;
  for (int idx = 0; idx < sides.length; idx++) {
    int side = sides[idx];
    int distance = getDistanceFromEdge(boundary, toTest, side);
    if (distance < closestDistance) {
      closestDistance = distance;
      closestSide = side;
    }
  }
  return closestSide;
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

/**
 * Returns the distance from the point to the nearest edge of the given
 * rectangle. Returns negative values if the point lies outside the rectangle.
 * 
 * @param boundary rectangle to test
 * @param toTest point to test
 * @return the distance between the given point and the nearest edge of the rectangle.
 * Returns positive values for points inside the rectangle and negative values for points
 * outside the rectangle.
 * @since 1.0
 */
public static int getDistanceFrom(Rectangle boundary, Point toTest) {
  int side = getClosestSide(boundary, toTest);
  return getDistanceFromEdge(boundary, toTest, side);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

/**
 * Returns the distance from the point to the nearest edge of the given
 * rectangle. Returns negative values if the point lies outside the rectangle.
 *
 * @param boundary rectangle to test
 * @param toTest point to test
 * @return the distance between the given point and the nearest edge of the rectangle.
 * Returns positive values for points inside the rectangle and negative values for points
 * outside the rectangle.
 * @since 3.1
 */
public static int getDistanceFrom(Rectangle boundary, Point toTest) {
  int side = getClosestSide(boundary, toTest);
  return getDistanceFromEdge(boundary, toTest, side);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * Returns the distance from the point to the nearest edge of the given
 * rectangle. Returns negative values if the point lies outside the rectangle.
 *
 * @param boundary rectangle to test
 * @param toTest point to test
 * @return the distance between the given point and the nearest edge of the rectangle.
 * Returns positive values for points inside the rectangle and negative values for points
 * outside the rectangle.
 * @since 3.1
 */
public static int getDistanceFrom(Rectangle boundary, Point toTest) {
  int side = getClosestSide(boundary, toTest);
  return getDistanceFromEdge(boundary, toTest, side);
}

相关文章