本文整理了Java中org.eclipse.jface.util.Geometry.getClosestSide()
方法的一些代码示例,展示了Geometry.getClosestSide()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.getClosestSide()
方法的具体详情如下:
包路径:org.eclipse.jface.util.Geometry
类名称:Geometry
方法名:getClosestSide
[英]Returns the edge of the given rectangle is closest to the given point.
[中]
代码示例来源: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);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
/**
* Returns the relative position of the given point (in display coordinates)
* with respect to the given control. Returns one of SWT.LEFT, SWT.RIGHT, SWT.CENTER, SWT.TOP,
* or SWT.BOTTOM if the point is on the control or SWT.DEFAULT if the point is not on the control.
*
* @param control control to perform hit detection on
* @param toTest point to test, in display coordinates
* @return
*/
public static int getRelativePosition(Control c, Point toTest) {
Point p = c.toControl(toTest);
Point e = c.getSize();
if (p.x > e.x || p.y > e.y || p.x < 0 || p.y < 0) {
return SWT.DEFAULT;
}
// first determine whether mouse position is in center of part
int hmargin = Math.min(e.x / 3, MARGIN);
int vmargin = Math.min(e.y / 3, MARGIN);
Rectangle inner = new Rectangle(hmargin, vmargin, e.x - (hmargin * 2),
e.y - (vmargin * 2));
if (inner.contains(p)) {
return SWT.CENTER;
}
return Geometry.getClosestSide(inner, p);
}
内容来源于网络,如有侵权,请联系作者删除!