本文整理汇总了Java中org.eclipse.swt.graphics.Rectangle.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.contains方法的具体用法?Java Rectangle.contains怎么用?Java Rectangle.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.Rectangle
的用法示例。
在下文中一共展示了Rectangle.contains方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClosestMonitor
import org.eclipse.swt.graphics.Rectangle; //导入方法依赖的package包/类
/**
* 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.
*
* @param toSearch
* point to find (display coordinates).
* @param toFind
* point to find (display coordinates).
* @return the monitor closest to the given point.
*/
private static Monitor getClosestMonitor(final Display toSearch, final Point toFind) {
int closest = Integer.MAX_VALUE;
final Monitor[] monitors = toSearch.getMonitors();
Monitor result = monitors[0];
for (int index = 0; index < monitors.length; index++) {
final Monitor current = monitors[index];
final Rectangle clientArea = current.getClientArea();
if (clientArea.contains(toFind)) {
return current;
}
final int distance = Geometry.distanceSquared(Geometry.centerPoint(clientArea), toFind);
if (distance < closest) {
closest = distance;
result = current;
}
}
return result;
}
示例2: handleEvent
import org.eclipse.swt.graphics.Rectangle; //导入方法依赖的package包/类
@Override
public void handleEvent(Event event) {
String[] propertyNames = event.getPropertyNames();
//System.out.println(event.getProperty(propertyNames[0]));
IStyledTextGazeResponse response = (IStyledTextGazeResponse)event.getProperty(propertyNames[0]);
Rectangle mBounds = ITrace.getDefault().getRootShell().getBounds();
int screenX = (int) (response.getGaze().getX() * mBounds.width);
int screenY = (int) (response.getGaze().getY() * mBounds.height);
//Rectangle monitorBounds = ITrace.getDefault().monitorBounds;
if(styledText.isDisposed()) return;
Rectangle editorBounds = styledText.getBounds();
Point screenPos = styledText.toDisplay(0, 0);
editorBounds.x = screenPos.x - mBounds.x;
editorBounds.y = screenPos.y - mBounds.y;
if(editorBounds.contains(screenX, screenY)){
int relativeX = screenX-editorBounds.x;
int relativeY = screenY-editorBounds.y;
update(response.getLine()-1,response.getCol(), relativeX, relativeY);
}
}
示例3: cellMouseTrigger
import org.eclipse.swt.graphics.Rectangle; //导入方法依赖的package包/类
@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
if (event.eventType == TableCellMouseEvent.EVENT_MOUSEMOVE
|| event.eventType == TableRowMouseEvent.EVENT_MOUSEDOWN) {
TableRow row = event.cell.getTableRow();
if (row == null) {
return;
}
Object data = row.getData(ID_EXPANDOHITAREA);
if (data instanceof Rectangle) {
Rectangle hitArea = (Rectangle) data;
boolean inExpando = hitArea.contains(event.x, event.y);
if (event.eventType == TableCellMouseEvent.EVENT_MOUSEMOVE) {
((TableCellCore) event.cell).setCursorID(inExpando ? SWT.CURSOR_HAND
: SWT.CURSOR_ARROW);
} else if (inExpando) { // mousedown
if (row instanceof TableRowCore) {
TableRowCore rowCore = (TableRowCore) row;
rowCore.setExpanded(!rowCore.isExpanded());
}
}
}
}
}
示例4: handleGaze
import org.eclipse.swt.graphics.Rectangle; //导入方法依赖的package包/类
/**
* Finds the control under the specified screen coordinates and calls its
* gaze handler on the localized point. Returns the gaze response or null if
* the gaze is not handled.
*/
private IGazeResponse handleGaze(int screenX, int screenY, Gaze gaze){
Queue<Control[]> childrenQueue = new LinkedList<Control[]>();
childrenQueue.add(rootShell.getChildren());
Rectangle monitorBounds = rootShell.getMonitor().getBounds();
while (!childrenQueue.isEmpty()) {
for (Control child : childrenQueue.remove()) {
Rectangle childScreenBounds = child.getBounds();
Point screenPos = child.toDisplay(0, 0);
childScreenBounds.x = screenPos.x - monitorBounds.x;
childScreenBounds.y = screenPos.y - monitorBounds.y;
if (childScreenBounds.contains(screenX, screenY)) {
if (child instanceof Composite) {
Control[] nextChildren =
((Composite) child).getChildren();
if (nextChildren.length > 0 && nextChildren[0] != null) {
childrenQueue.add(nextChildren);
}
}
IGazeHandler handler =
(IGazeHandler) child
.getData(HandlerBindManager.KEY_HANDLER);
if (child.isVisible() && handler != null) {
return handler.handleGaze(screenX, screenY,
screenX - childScreenBounds.x, screenY
- childScreenBounds.y, gaze);
}
}
}
}
return null;
}
示例5: getToolTip
import org.eclipse.swt.graphics.Rectangle; //导入方法依赖的package包/类
/**
* @return
*
* @since 3.1.1.1
*/
private String getToolTip(Point mousePos_RelativeToItem) {
MdiEntryVitalityImage[] vitalityImages = mdiEntry.getVitalityImages();
for (int i = 0; i < vitalityImages.length; i++) {
SideBarVitalityImageSWT vitalityImage = (SideBarVitalityImageSWT) vitalityImages[i];
if (vitalityImage == null) {
continue;
}
String indicatorToolTip = vitalityImage.getToolTip();
if (indicatorToolTip == null || !vitalityImage.isVisible()) {
continue;
}
Rectangle hitArea = vitalityImage.getHitArea();
if (hitArea == null) {
continue;
}
if (hitArea.contains(mousePos_RelativeToItem)) {
return indicatorToolTip;
}
}
if (mdiEntry.getViewTitleInfo() != null) {
String tt = (String) mdiEntry.getViewTitleInfo().getTitleInfoProperty(ViewTitleInfo.TITLE_INDICATOR_TEXT_TOOLTIP);
return tt;
}
return null;
}
示例6: containsPoints
import org.eclipse.swt.graphics.Rectangle; //导入方法依赖的package包/类
private boolean containsPoints(Rectangle box){
for(Point p: points){
if(p != null && box != null && !box.contains(p)) return false;
}
return true;
}