mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
search for corresponding graphics device refactored
This commit is contained in:
@@ -299,20 +299,15 @@ public class DimensionService implements PersistentStateComponent<Element> {
|
||||
frame = WindowManager.getInstance().getFrame(project);
|
||||
}
|
||||
Rectangle screen = new Rectangle(0, 0, 0, 0);
|
||||
GraphicsDevice device = null;
|
||||
if (frame != null) {
|
||||
final Point topLeft = frame.getLocation();
|
||||
Point center = new Point(topLeft.x + frame.getWidth() / 2, topLeft.y + frame.getHeight() / 2);
|
||||
for (GraphicsDevice device : env.getScreenDevices()) {
|
||||
Rectangle bounds = device.getDefaultConfiguration().getBounds();
|
||||
if (bounds.contains(center)) {
|
||||
screen = bounds;
|
||||
break;
|
||||
}
|
||||
}
|
||||
device = ScreenUtil.getScreenDevice(frame.getBounds());
|
||||
}
|
||||
else {
|
||||
GraphicsConfiguration gc = env.getScreenDevices()[0].getDefaultConfiguration();
|
||||
screen = gc.getBounds();
|
||||
if (device == null) {
|
||||
device = env.getDefaultScreenDevice();
|
||||
}
|
||||
if (device != null) {
|
||||
screen = device.getDefaultConfiguration().getBounds();
|
||||
}
|
||||
String realKey = key + '.' + screen.x + '.' + screen.y + '.' + screen.width + '.' + screen.height;
|
||||
if (JBUI.isHiDPI()) {
|
||||
|
||||
@@ -131,6 +131,10 @@ public class ScreenUtil {
|
||||
return getScreenRectangle(p.x, p.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bounds a rectangle used to find corresponding graphics device
|
||||
* @return a graphics device that contains the biggest part of the specified rectangle
|
||||
*/
|
||||
public static GraphicsDevice getScreenDevice(Rectangle bounds) {
|
||||
GraphicsDevice candidate = null;
|
||||
int maxIntersection = 0;
|
||||
@@ -222,8 +226,7 @@ public class ScreenUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a device that is the closest to the specified point and
|
||||
* returns its visible area.
|
||||
* Returns a visible area for a graphics device that is the closest to the specified point.
|
||||
*
|
||||
* @param x the X coordinate of the specified point
|
||||
* @param y the Y coordinate of the specified point
|
||||
|
||||
Reference in New Issue
Block a user