本文整理匯總了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;
}