/**
* Given the desired position of the shell, this method returns an adjusted position such that the window is no
* larger than its monitor, and does not extend beyond the edge of the monitor. This is used for computing the
* initial window position via the parent shell, clients can use this as a utility method if they want to limit the
* region in which the window may be moved.
*
* @param shell
* the shell which shell bounds is being calculated.
* @param preferredSize
* the preferred position of the window.
* @return a rectangle as close as possible to preferredSize that does not extend outside the monitor.
*/
public static Rectangle getConstrainedShellBounds(final Shell shell, final Point preferredSize) {
final Point location = getInitialLocation(shell, preferredSize);
final Rectangle result = new Rectangle(location.x, location.y, preferredSize.x, preferredSize.y);
final Monitor monitor = getClosestMonitor(shell.getDisplay(), Geometry.centerPoint(result));
final Rectangle bounds = monitor.getClientArea();
if (result.height > bounds.height) {
result.height = bounds.height;
}
if (result.width > bounds.width) {
result.width = bounds.width;
}
result.x = Math.max(bounds.x, Math.min(result.x, bounds.x
+ bounds.width - result.width));
result.y = Math.max(bounds.y, Math.min(result.y, bounds.y
+ bounds.height - result.height));
return result;
}
java类org.eclipse.swt.widgets.Monitor的实例源码
UIUtils.java 文件源码
项目:n4js
阅读 41
收藏 0
点赞 0
评论 0
UIUtils.java 文件源码
项目:n4js
阅读 32
收藏 0
点赞 0
评论 0
/**
* Returns the initial location to use for the shell. The default implementation centers the shell horizontally (1/2
* of the difference to the left and 1/2 to the right) and vertically (1/3 above and 2/3 below) relative to the
* active workbench windows shell, or display bounds if there is no parent shell.
*
* @param shell
* the shell which initial location has to be calculated.
* @param initialSize
* the initial size of the shell, as returned by <code>getInitialSize</code>.
* @return the initial location of the shell
*/
public static Point getInitialLocation(final Shell shell, final Point initialSize) {
final Composite parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if (parent != null) {
monitor = parent.getMonitor();
}
final Rectangle monitorBounds = monitor.getClientArea();
Point centerPoint;
if (parent != null) {
centerPoint = Geometry.centerPoint(parent.getBounds());
} else {
centerPoint = Geometry.centerPoint(monitorBounds);
}
return new Point(centerPoint.x - (initialSize.x / 2), Math.max(
monitorBounds.y, Math.min(centerPoint.y
- (initialSize.y * 2 / 3), monitorBounds.y
+ monitorBounds.height - initialSize.y)));
}
UIUtils.java 文件源码
项目:n4js
阅读 33
收藏 0
点赞 0
评论 0
/**
* 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;
}
SelectConfigurationDialog.java 文件源码
项目:egradle
阅读 21
收藏 0
点赞 0
评论 0
private Point calculateCenterOnCurrentDisplay(Point initialSize) {
if (shell==null || shell.isDisposed()){
return new Point(0,0);
}
/* fall back implemenrtation for unpersisted location */
Composite parent = getParent();
Monitor monitor = null;
if (parent == null) {
monitor = shell.getDisplay().getPrimaryMonitor();
} else {
monitor = parent.getMonitor();
}
Rectangle monitorBounds = monitor.getClientArea();
Point centerPoint;
if (parent != null) {
centerPoint = Geometry.centerPoint(parent.getBounds());
} else {
centerPoint = Geometry.centerPoint(monitorBounds);
}
return new Point(centerPoint.x - (initialSize.x / 2), Math.max(monitorBounds.y, Math
.min(centerPoint.y - (initialSize.y * 2 / 3), monitorBounds.y + monitorBounds.height - initialSize.y)));
}
FXCanvasScrollApp.java 文件源码
项目:openjfx-8u-dev-tests
阅读 28
收藏 0
点赞 0
评论 0
protected FXCanvasScrollApp() {
shell = new Shell();
shell.setText(this.getClass().getSimpleName());
shell.setLayout(new FillLayout());
ScrolledComposite scrollPane = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
FXCanvas fxCanvas = new FXCanvas(scrollPane, SWT.BORDER);
fxCanvas.setScene(createScene(SCROLL_CONTAINER_ID));
scrollPane.setContent(fxCanvas);
scrollPane.setExpandHorizontal(true);
scrollPane.setExpandVertical(true);
fxCanvas.pack();
scrollPane.setMinSize(fxCanvas.getSize());
shell.pack();
Monitor monitor = shell.getMonitor();
Rectangle monitorRect = monitor.getClientArea();
Rectangle shellRect = shell.getBounds();
shellRect.x = Math.max(0, (monitorRect.width - shellRect.width) / 2);
shellRect.y = Math.max(0, (monitorRect.height - shellRect.height) / 2);
shell.setBounds(shellRect);
shell.open();
}
FXCanvasBrowserApp.java 文件源码
项目:openjfx-8u-dev-tests
阅读 28
收藏 0
点赞 0
评论 0
protected FXCanvasBrowserApp() {
shell = new Shell();
shell.setText(this.getClass().getSimpleName());
shell.setLayout(new FillLayout());
FXCanvas fxCanvas = new FXCanvas(shell, SWT.BORDER);
browser = new WebView();
browser.getEngine().getLoadWorker().stateProperty().addListener(
new ChangeListener<State>() {
public void changed(ObservableValue ov, State oldState, State newState) {
if (newState == State.SUCCEEDED) {
successLabel.setText(SUCCESS_MESSAGE);
}
}
});
fxCanvas.setScene(createScene());
shell.pack();
Monitor monitor = shell.getMonitor();
Rectangle monitorRect = monitor.getClientArea();
Rectangle shellRect = shell.getBounds();
shellRect.x = Math.max(0, (monitorRect.width - shellRect.width) / 2);
shellRect.y = Math.max(0, (monitorRect.height - shellRect.height) / 2);
shell.setBounds(shellRect);
shell.open();
}
LoginDialog.java 文件源码
项目:bts
阅读 48
收藏 0
点赞 0
评论 0
@Override
protected Control createDialogArea(Composite parent)
{
parent.setBackgroundMode(SWT.INHERIT_DEFAULT);
parent.setBackground(BTSUIConstants.VIEW_BACKGROUND_DESELECTED_COLOR);
Composite control = createContentArea(parent);
control.setData("org.eclipse.e4.ui.css.id", "LoginDialog");
Rectangle controlRect = control.getBounds();
// looks strange in multi monitor environments
// Rectangle displayBounds = shell.getDisplay().getBounds();
shell.getDisplay();
Monitor primary = Display.getDefault().getPrimaryMonitor();
Rectangle displayBounds = primary.getBounds();
int x = (displayBounds.width - controlRect.width) / 2;
int y = (displayBounds.height - controlRect.height) / 2;
shell.setBounds(x, y, controlRect.width, controlRect.height);
return control;
}
StandardWidgetToolkit.java 文件源码
项目:oauth2-useragent
阅读 21
收藏 0
点赞 0
评论 0
public StandardWidgetToolkit(String... commandLineArgs) {
this.swtRunnableFactory = RUNNABLE_FACTORY_OVERRIDE != null ? RUNNABLE_FACTORY_OVERRIDE : this;
this.commandLineArgs = commandLineArgs;
display = new Display();
shell = new Shell(display);
shell.setText("OAuth 2.0 Authorization Request");
shell.setLayout(new FillLayout());
Monitor monitor = display.getPrimaryMonitor();
Rectangle bounds = monitor.getBounds();
Dimension size = new Dimension((int) (bounds.width * 0.25), (int) (bounds.height * 0.55));
shell.setSize(size.width, size.height);
shell.setLocation((bounds.width - size.width) / 2, (bounds.height - size.height) / 2);
Browser browser = new org.eclipse.swt.browser.Browser(shell, SWT.ON_TOP);
swtInterceptingBrowser = new SwtInterceptingBrowser(browser, display, shell);
}
FeatureManagementDialog.java 文件源码
项目:VariantSync
阅读 22
收藏 0
点赞 0
评论 0
private void initShell() {
shell = new Shell(Display.getCurrent(), SWT.APPLICATION_MODAL
| SWT.SHEET);
shell.setText("Feature-Expression Management Dialog");
shell.setImage(VariantSyncPlugin.getDefault()
.getImageDescriptor("icons/featureExpression.png")
.createImage());
shell.setSize(500, 485);
GridLayout shellLayout = new GridLayout();
shellLayout.marginWidth = 0;
shellLayout.marginHeight = 0;
shell.setLayout(shellLayout);
Monitor primary = shell.getDisplay().getPrimaryMonitor();
Rectangle bounds = primary.getBounds();
Rectangle rect = shell.getBounds();
int x = bounds.x + (bounds.width - rect.width) / 2;
int y = bounds.y + (bounds.height - rect.height) / 2;
shell.setLocation(x, y);
}
BreadcrumbItemDropDown.java 文件源码
项目:gwt-eclipse-plugin
阅读 27
收藏 0
点赞 0
评论 0
/**
* 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.
* <p>
* Copied from
* <code>org.eclipse.jface.window.Window.getClosestMonitor(Display, Point)</code>
* </p>
*
* @param display the display showing the monitors
* @param point point to find (display coordinates)
* @return the monitor closest to the given point
*/
private static Monitor getClosestMonitor(Display display, Point point) {
int closest = Integer.MAX_VALUE;
Monitor[] monitors = display.getMonitors();
Monitor result = monitors[0];
for (int i = 0; i < monitors.length; i++) {
Monitor current = monitors[i];
Rectangle clientArea = current.getClientArea();
if (clientArea.contains(point))
return current;
int distance = Geometry.distanceSquared(Geometry.centerPoint(clientArea),
point);
if (distance < closest) {
closest = distance;
result = current;
}
}
return result;
}
GamlSearchField.java 文件源码
项目:gama
阅读 25
收藏 0
点赞 0
评论 0
/**
* This method was copy/pasted from JFace.
*/
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 idx = 0; idx < monitors.length; idx++) {
final Monitor current = monitors[idx];
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;
}
GamlSearchField.java 文件源码
项目:gama
阅读 23
收藏 0
点赞 0
评论 0
/**
* This method was copy/pasted from JFace.
*/
private Rectangle getConstrainedShellBounds(final Display display, final Rectangle preferredSize) {
final Rectangle result =
new Rectangle(preferredSize.x, preferredSize.y, preferredSize.width, preferredSize.height);
final Point topLeft = new Point(preferredSize.x, preferredSize.y);
final Monitor mon = getClosestMonitor(display, topLeft);
final Rectangle bounds = mon.getClientArea();
if (result.height > bounds.height) {
result.height = bounds.height;
}
if (result.width > bounds.width) {
result.width = bounds.width;
}
result.x = Math.max(bounds.x, Math.min(result.x, bounds.x + bounds.width - result.width));
result.y = Math.max(bounds.y, Math.min(result.y, bounds.y + bounds.height - result.height));
return result;
}
AnimatedToolTipShell.java 文件源码
项目:mytourbook
阅读 23
收藏 0
点赞 0
评论 0
private Rectangle getDisplayBounds(final Point location) {
Rectangle displayBounds;
final Monitor[] allMonitors = _ownerControl.getDisplay().getMonitors();
if (allMonitors.length > 1) {
// By default present in the monitor of the control
displayBounds = _ownerControl.getMonitor().getBounds();
final Point p = new Point(location.x, location.y);
// Search on which monitor the event occurred
Rectangle tmp;
for (final Monitor element : allMonitors) {
tmp = element.getBounds();
if (tmp.contains(p)) {
displayBounds = tmp;
break;
}
}
} else {
displayBounds = _ownerControl.getDisplay().getBounds();
}
return displayBounds;
}
AdvancedSlideoutShell.java 文件源码
项目:mytourbook
阅读 25
收藏 0
点赞 0
评论 0
private Rectangle getDisplayBounds(final Point location) {
Rectangle displayBounds;
final Monitor[] allMonitors = _ownerControl.getDisplay().getMonitors();
if (allMonitors.length > 1) {
// By default present in the monitor of the control
displayBounds = _ownerControl.getMonitor().getBounds();
final Point p = new Point(location.x, location.y);
// Search on which monitor the event occurred
Rectangle tmp;
for (final Monitor element : allMonitors) {
tmp = element.getBounds();
if (tmp.contains(p)) {
displayBounds = tmp;
break;
}
}
} else {
displayBounds = _ownerControl.getDisplay().getBounds();
}
return displayBounds;
}
AnimatedToolTipShell2.java 文件源码
项目:mytourbook
阅读 21
收藏 0
点赞 0
评论 0
private Rectangle getDisplayBounds(final Point location) {
Rectangle displayBounds;
final Monitor[] allMonitors = _ownerControl.getDisplay().getMonitors();
if (allMonitors.length > 1) {
// By default present in the monitor of the control
displayBounds = _ownerControl.getMonitor().getBounds();
final Point p = new Point(location.x, location.y);
// Search on which monitor the event occurred
Rectangle tmp;
for (final Monitor element : allMonitors) {
tmp = element.getBounds();
if (tmp.contains(p)) {
displayBounds = tmp;
break;
}
}
} else {
displayBounds = _ownerControl.getDisplay().getBounds();
}
return displayBounds;
}
UI.java 文件源码
项目:mytourbook
阅读 31
收藏 0
点赞 0
评论 0
public static Rectangle getDisplayBounds(final Control composite, final Point location) {
Rectangle displayBounds;
final Monitor[] allMonitors = composite.getDisplay().getMonitors();
if (allMonitors.length > 1) {
// By default present in the monitor of the control
displayBounds = composite.getMonitor().getBounds();
final Point p = new Point(location.x, location.y);
// Search on which monitor the event occurred
Rectangle tmp;
for (final Monitor element : allMonitors) {
tmp = element.getBounds();
if (tmp.contains(p)) {
displayBounds = tmp;
break;
}
}
} else {
displayBounds = composite.getDisplay().getBounds();
}
return displayBounds;
}
BreadcrumbItemDropDown.java 文件源码
项目:Eclipse-Postfix-Code-Completion
阅读 30
收藏 0
点赞 0
评论 0
/**
* 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.
* <p>
* Copied from <code>org.eclipse.jface.window.Window.getClosestMonitor(Display, Point)</code>
* </p>
*
* @param display the display showing the monitors
* @param point point to find (display coordinates)
* @return the monitor closest to the given point
*/
private static Monitor getClosestMonitor(Display display, Point point) {
int closest= Integer.MAX_VALUE;
Monitor[] monitors= display.getMonitors();
Monitor result= monitors[0];
for (int i= 0; i < monitors.length; i++) {
Monitor current= monitors[i];
Rectangle clientArea= current.getClientArea();
if (clientArea.contains(point))
return current;
int distance= Geometry.distanceSquared(Geometry.centerPoint(clientArea), point);
if (distance < closest) {
closest= distance;
result= current;
}
}
return result;
}
Window.java 文件源码
项目:gef-gwt
阅读 31
收藏 0
点赞 0
评论 0
/**
* Returns the initial location to use for the shell. The default
* implementation centers the shell horizontally (1/2 of the difference to
* the left and 1/2 to the right) and vertically (1/3 above and 2/3 below)
* relative to the parent shell, or display bounds if there is no parent
* shell.
*
* @param initialSize
* the initial size of the shell, as returned by
* <code>getInitialSize</code>.
* @return the initial location of the shell
*/
protected Point getInitialLocation(Point initialSize) {
Composite parent = shell.getParent();
Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if (parent != null) {
monitor = parent.getMonitor();
}
Rectangle monitorBounds = monitor.getClientArea();
Point centerPoint;
if (parent != null) {
centerPoint = Geometry.centerPoint(parent.getBounds());
} else {
centerPoint = Geometry.centerPoint(monitorBounds);
}
return new Point(centerPoint.x - (initialSize.x / 2), Math.max(
monitorBounds.y, Math.min(centerPoint.y
- (initialSize.y * 2 / 3), monitorBounds.y
+ monitorBounds.height - initialSize.y)));
}
Window.java 文件源码
项目:gef-gwt
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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. If this is ever made public, it should be moved into a separate
* utility class.
*
* @param toSearch
* point to find (display coordinates)
* @param toFind
* point to find (display coordinates)
* @return the montor closest to the given point
*/
private static Monitor getClosestMonitor(Display toSearch, Point toFind) {
int closest = Integer.MAX_VALUE;
Monitor[] monitors = toSearch.getMonitors();
Monitor result = monitors[0];
for (int idx = 0; idx < monitors.length; idx++) {
Monitor current = monitors[idx];
Rectangle clientArea = current.getClientArea();
if (clientArea.contains(toFind)) {
return current;
}
int distance = Geometry.distanceSquared(Geometry
.centerPoint(clientArea), toFind);
if (distance < closest) {
closest = distance;
result = current;
}
}
return result;
}
Window.java 文件源码
项目:gef-gwt
阅读 29
收藏 0
点赞 0
评论 0
/**
* Given the desired position of the window, this method returns an adjusted
* position such that the window is no larger than its monitor, and does not
* extend beyond the edge of the monitor. This is used for computing the
* initial window position, and subclasses can use this as a utility method
* if they want to limit the region in which the window may be moved.
*
* @param preferredSize
* the preferred position of the window
* @return a rectangle as close as possible to preferredSize that does not
* extend outside the monitor
*
* @since 3.0
*/
protected Rectangle getConstrainedShellBounds(Rectangle preferredSize) {
Rectangle result = new Rectangle(preferredSize.x, preferredSize.y,
preferredSize.width, preferredSize.height);
Monitor mon = getClosestMonitor(getShell().getDisplay(), Geometry
.centerPoint(result));
Rectangle bounds = mon.getClientArea();
if (result.height > bounds.height) {
result.height = bounds.height;
}
if (result.width > bounds.width) {
result.width = bounds.width;
}
result.x = Math.max(bounds.x, Math.min(result.x, bounds.x
+ bounds.width - result.width));
result.y = Math.max(bounds.y, Math.min(result.y, bounds.y
+ bounds.height - result.height));
return result;
}
BreadcrumbItemDropDown.java 文件源码
项目:Eclipse-Postfix-Code-Completion-Juno38
阅读 34
收藏 0
点赞 0
评论 0
/**
* 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.
* <p>
* Copied from <code>org.eclipse.jface.window.Window.getClosestMonitor(Display, Point)</code>
* </p>
*
* @param display the display showing the monitors
* @param point point to find (display coordinates)
* @return the monitor closest to the given point
*/
private static Monitor getClosestMonitor(Display display, Point point) {
int closest= Integer.MAX_VALUE;
Monitor[] monitors= display.getMonitors();
Monitor result= monitors[0];
for (int i= 0; i < monitors.length; i++) {
Monitor current= monitors[i];
Rectangle clientArea= current.getClientArea();
if (clientArea.contains(point))
return current;
int distance= Geometry.distanceSquared(Geometry.centerPoint(clientArea), point);
if (distance < closest) {
closest= distance;
result= current;
}
}
return result;
}
ShortcutPopup.java 文件源码
项目:show-shortcuts
阅读 30
收藏 0
点赞 0
评论 0
private Point getDefaultLocation(Point initialSize, int offsetRight, int offsetTop) {
Composite parent = getShell().getParent();
Monitor monitor = getShell().getDisplay().getPrimaryMonitor();
if (parent != null) {
monitor = parent.getMonitor();
}
Rectangle monitorBounds = monitor.getClientArea();
Point topRight;
if (parent != null) {
Rectangle parentBounds = parent.getBounds();
topRight = new Point(parentBounds.x + parentBounds.width, parentBounds.y);
} else {
topRight = new Point(monitorBounds.x + monitorBounds.width, monitorBounds.y);
}
return new Point(topRight.x - (initialSize.x + offsetRight), //
Math.max(monitorBounds.y, Math.min(topRight.y + offsetTop, monitorBounds.y + monitorBounds.height - initialSize.y)));
}
FactoryExample.java 文件源码
项目:MAS
阅读 23
收藏 0
点赞 0
评论 0
public static void main(String[] args) {
final long endTime = args != null && args.length >= 1 ? Long
.parseLong(args[0]) : Long.MAX_VALUE;
final Display d = new Display();
@Nullable
Monitor sec = null;
for (final Monitor m : d.getMonitors()) {
if (d.getPrimaryMonitor() != m) {
sec = m;
break;
}
}
System.out.println(sec);
run(endTime, d, sec, null);
}
WindowProperty.java 文件源码
项目:geokettle-2.0
阅读 41
收藏 0
点赞 0
评论 0
/**
* This method is needed in the case where the display has multiple monitors, but
* they do not form a uniform rectangle. In this case, it is possible for Geometry.moveInside()
* to not detect that the window is partially or completely clipped.
* We check to make sure at least the upper left portion of the rectangle is visible to give the
* user the ability to reposition the dialog in this rare case.
* @param constrainee
* @param display
* @return
*/
private boolean isClippedByUnalignedMonitors(Rectangle constrainee, Display display)
{
boolean isClipped;
Monitor[] monitors = display.getMonitors();
if (monitors.length > 0)
{
// Loop searches for a monitor proving false
isClipped = true;
for (Monitor monitor : monitors)
{
if (monitor.getClientArea().contains(constrainee.x + 10, constrainee.y + 10))
{
isClipped = false;
break;
}
}
}
else
{
isClipped = false;
}
return isClipped;
}
WindowProperty.java 文件源码
项目:read-open-source-code
阅读 31
收藏 0
点赞 0
评论 0
/**
* This method is needed in the case where the display has multiple monitors, but
* they do not form a uniform rectangle. In this case, it is possible for Geometry.moveInside()
* to not detect that the window is partially or completely clipped.
* We check to make sure at least the upper left portion of the rectangle is visible to give the
* user the ability to reposition the dialog in this rare case.
* @param constrainee
* @param display
* @return
*/
private boolean isClippedByUnalignedMonitors(Rectangle constrainee, Display display)
{
boolean isClipped;
Monitor[] monitors = display.getMonitors();
if (monitors.length > 0)
{
// Loop searches for a monitor proving false
isClipped = true;
for (Monitor monitor : monitors)
{
if (monitor.getClientArea().contains(constrainee.x + 10, constrainee.y + 10))
{
isClipped = false;
break;
}
}
}
else
{
isClipped = false;
}
return isClipped;
}
MainWindow.java 文件源码
项目:jisocreator
阅读 40
收藏 0
点赞 0
评论 0
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText("JIsoCreator");
shell.setSize(800, 600);
shell.setImage(ImageUtils.getInstance().loadImage("iso.png"));
Monitor primary = Display.getCurrent().getPrimaryMonitor();
Rectangle bounds = primary.getBounds();
Rectangle rect = shell.getBounds();
int x = bounds.x + ((bounds.width - rect.width) / 2);
int y = bounds.y + ((bounds.height - rect.height) / 2);
shell.setLocation(x, y);
}
WindowProperty.java 文件源码
项目:kettle-4.4.0-stable
阅读 24
收藏 0
点赞 0
评论 0
/**
* This method is needed in the case where the display has multiple monitors, but
* they do not form a uniform rectangle. In this case, it is possible for Geometry.moveInside()
* to not detect that the window is partially or completely clipped.
* We check to make sure at least the upper left portion of the rectangle is visible to give the
* user the ability to reposition the dialog in this rare case.
* @param constrainee
* @param display
* @return
*/
private boolean isClippedByUnalignedMonitors(Rectangle constrainee, Display display)
{
boolean isClipped;
Monitor[] monitors = display.getMonitors();
if (monitors.length > 0)
{
// Loop searches for a monitor proving false
isClipped = true;
for (Monitor monitor : monitors)
{
if (monitor.getClientArea().contains(constrainee.x + 10, constrainee.y + 10))
{
isClipped = false;
break;
}
}
}
else
{
isClipped = false;
}
return isClipped;
}
WindowProperty.java 文件源码
项目:kettle-trunk
阅读 37
收藏 0
点赞 0
评论 0
/**
* This method is needed in the case where the display has multiple monitors, but
* they do not form a uniform rectangle. In this case, it is possible for Geometry.moveInside()
* to not detect that the window is partially or completely clipped.
* We check to make sure at least the upper left portion of the rectangle is visible to give the
* user the ability to reposition the dialog in this rare case.
* @param constrainee
* @param display
* @return
*/
private boolean isClippedByUnalignedMonitors(Rectangle constrainee, Display display)
{
boolean isClipped;
Monitor[] monitors = display.getMonitors();
if (monitors.length > 0)
{
// Loop searches for a monitor proving false
isClipped = true;
for (Monitor monitor : monitors)
{
if (monitor.getClientArea().contains(constrainee.x + 10, constrainee.y + 10))
{
isClipped = false;
break;
}
}
}
else
{
isClipped = false;
}
return isClipped;
}
ScreenUtils.java 文件源码
项目:Sammelbox
阅读 46
收藏 0
点赞 0
评论 0
public static Rectangle getPrimaryScreenClientArea(Display display) {
Monitor primaryMonitorBySwt = display.getPrimaryMonitor();
Rectangle primaryMonitorClientAreaBySwt = primaryMonitorBySwt.getClientArea();
GraphicsDevice[]screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
for (GraphicsDevice screen : screens) {
if (isPrimaryMonitor(screen)) {
// Cut off any excess area such as OS task-bars.
Rectangle primaryScreenBoundsByJava = new Rectangle(
screen.getDefaultConfiguration().getBounds().x,
screen.getDefaultConfiguration().getBounds().y,
screen.getDefaultConfiguration().getBounds().width,
screen.getDefaultConfiguration().getBounds().height);
return primaryMonitorClientAreaBySwt.intersection(primaryScreenBoundsByJava);
}
}
// No primary screen has been found by java, use SWT to get clientArea of PrimaryScreen as fallback.
return primaryMonitorClientAreaBySwt;
}
MainSplash.java 文件源码
项目:arx
阅读 29
收藏 0
点赞 0
评论 0
/**
* Creates a new instance.
*
* @param display
* @param monitor
*/
public MainSplash(Display display, Monitor monitor) {
this.version = Resources.getVersion();
this.splash = Resources.getSplash(display);
this.shell = new Shell(SWT.ON_TOP | (isMac() ? 0 : SWT.NO_TRIM));
this.shell.setImages(Resources.getIconSet(display));
this.shell.setSize(splash.getBounds().width, splash.getBounds().height);
// Center
SWTUtil.center(shell, monitor);
// Paint
shell.addPaintListener(new PaintListener(){
public void paintControl(PaintEvent arg0) {
paint(arg0.gc);
}
});
}