当前位置: 首页>>代码示例>>Java>>正文


Java Display.getMonitors方法代码示例

本文整理汇总了Java中org.eclipse.swt.widgets.Display.getMonitors方法的典型用法代码示例。如果您正苦于以下问题:Java Display.getMonitors方法的具体用法?Java Display.getMonitors怎么用?Java Display.getMonitors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.widgets.Display的用法示例。


在下文中一共展示了Display.getMonitors方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClosestMonitor

import org.eclipse.swt.widgets.Display; //导入方法依赖的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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:35,代码来源:UIUtils.java

示例2: configureShell

import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
@Override
public void configureShell(Shell newShell) {
	super.configureShell(newShell);
	newShell.setText("Limit chars logs");
	newShell.setSize(nWidth, nHeight);

	int nLeft = 0;
	int nTop = 0;

	Display display = newShell.getDisplay();

	Point pt = display.getCursorLocation();
	Monitor[] monitors = display.getMonitors();

	for (int i = 0; i < monitors.length; i++) {
		if (monitors[i].getBounds().contains(pt)) {
			Rectangle rect = monitors[i].getClientArea();

			if (rect.x < 0)
				nLeft = ((rect.width - nWidth) / 2) + rect.x;
			else
				nLeft = (rect.width - nWidth) / 2;

			if (rect.y < 0)
				nTop = ((rect.height - nHeight) / 2) + rect.y;
			else
				nTop = (rect.height - nHeight) / 2;

			break;
		}
	}

	newShell.setBounds(nLeft, nTop, nWidth, nHeight);
	
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:36,代码来源:LimitCharsLogsPreferenceDialog.java

示例3: configureShell

import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
@Override
public void configureShell(Shell newShell) {
	super.configureShell(newShell);
	newShell.setText("Parameters availables");
	newShell.setSize(nWidth, nHeight);

	int nLeft = 0;
	int nTop = 0;

	Display display = newShell.getDisplay();

	Point pt = display.getCursorLocation();
	Monitor[] monitors = display.getMonitors();

	for (int i = 0; i < monitors.length; i++) {
		if (monitors[i].getBounds().contains(pt)) {
			Rectangle rect = monitors[i].getClientArea();

			if (rect.x < 0)
				nLeft = ((rect.width - nWidth) / 2) + rect.x;
			else
				nLeft = (rect.width - nWidth) / 2;

			if (rect.y < 0)
				nTop = ((rect.height - nHeight) / 2) + rect.y;
			else
				nTop = (rect.height - nHeight) / 2;

			break;
		}
	}

	newShell.setBounds(nLeft, nTop, nWidth, nHeight);
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:35,代码来源:CouchVariablesDialog.java

示例4: configureShell

import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
@Override
	public void configureShell(Shell newShell) {
		super.configureShell(newShell);
		
		newShell.setText(dialogTitle);	
		
		int nLeft = 0;
		int nTop = 0;
		 
		Display display = newShell.getDisplay();

//		// mods jmc 22/10/2013
//		nWidth = newShell.getSize().x;
//		nHeight = newShell.getSize().y;
		
		Point pt = display.getCursorLocation();
	    Monitor [] monitors = display.getMonitors();

	    for (int i= 0; i<monitors.length; i++) {
	          if (monitors[i].getBounds().contains(pt)) {
	             Rectangle rect = monitors[i].getClientArea();
	             
	             if (rect.x < 0)
	         		nLeft = ((rect.width - nWidth) / 2) + rect.x;
	             else
	         		nLeft = (rect.width - nWidth) / 2;

	             if (rect.y < 0)
	         		nTop = ((rect.height - nHeight) / 2) + rect.y;
	             else
	         		nTop = (rect.height - nHeight) / 2;
	             
	             break;
	          }
	    }

	    newShell.setBounds(nLeft, nTop, nWidth, nHeight);
	}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:39,代码来源:MyAbstractDialog.java

示例5: configureShell

import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
@Override
public void configureShell(Shell newShell) {
	super.configureShell(newShell);
	newShell.setText("Engine Log settings");
	newShell.setSize(nWidth, nHeight);

	int nLeft = 0;
	int nTop = 0;

	Display display = newShell.getDisplay();

	Point pt = display.getCursorLocation();
	Monitor[] monitors = display.getMonitors();

	for (int i = 0; i < monitors.length; i++) {
		if (monitors[i].getBounds().contains(pt)) {
			Rectangle rect = monitors[i].getClientArea();

			if (rect.x < 0)
				nLeft = ((rect.width - nWidth) / 2) + rect.x;
			else
				nLeft = (rect.width - nWidth) / 2;

			if (rect.y < 0)
				nTop = ((rect.height - nHeight) / 2) + rect.y;
			else
				nTop = (rect.height - nHeight) / 2;

			break;
		}
	}

	newShell.setBounds(nLeft, nTop, nWidth, nHeight);
	
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:36,代码来源:EnginePreferenceDialog.java

示例6: performPostDialogCreation

import org.eclipse.swt.widgets.Display; //导入方法依赖的package包/类
@Override
public void performPostDialogCreation() {
	// mods jmc 26/07/2013
			
	int nWidth;
	int nHeight;
	int nLeft = 0;
	int nTop = 0;
	 
	Shell newShell = this.parentDialog.getShell();

	// mods jmc 22/10/2013
	nWidth = (int) (0.50 * newShell.getSize().x);
	nHeight = (int) (0.60 * newShell.getSize().y);
	Display display = newShell.getDisplay();
	
	Point pt = display.getCursorLocation();
    Monitor [] monitors = display.getMonitors();

    for (int i= 0; i<monitors.length; i++) {
          if (monitors[i].getBounds().contains(pt)) {
             Rectangle rect = monitors[i].getClientArea();
             
             if (rect.x < 0)
         		nLeft = ((rect.width - nWidth) / 2) + rect.x;
             else
         		nLeft = (rect.width - nWidth) / 2;

             if (rect.y < 0)
         		nTop = ((rect.height - nHeight) / 2) + rect.y;
             else
         		nTop = (rect.height - nHeight) / 2;
             
             break;
          }
    }

    newShell.setBounds(nLeft, nTop, nWidth, nHeight);
	
	super.performPostDialogCreation();
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:42,代码来源:SqlQueryEditorComposite.java


注:本文中的org.eclipse.swt.widgets.Display.getMonitors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。