Changeset 4571 in josm
- Timestamp:
- 2011-11-03T18:35:07+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r4246 r4571 456 456 if(visible) { 457 457 new WindowGeometry(rememberSizePref, 458 defaultWindowGeometry).applySafe (this);458 defaultWindowGeometry).applySafeMultiScreen(this); 459 459 } else { 460 460 new WindowGeometry(this).remember(rememberSizePref); -
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r3083 r4571 6 6 import java.awt.Component; 7 7 import java.awt.Dimension; 8 import java.awt.GraphicsConfiguration; 9 import java.awt.GraphicsDevice; 10 import java.awt.GraphicsEnvironment; 8 11 import java.awt.Point; 12 import java.awt.Rectangle; 9 13 import java.awt.Toolkit; 10 14 import java.awt.Window; … … 102 106 String v = ""; 103 107 try { 104 Pattern p = Pattern.compile(field + "=( \\d+)",Pattern.CASE_INSENSITIVE);108 Pattern p = Pattern.compile(field + "=(-?\\d+)",Pattern.CASE_INSENSITIVE); 105 109 Matcher m = p.matcher(preferenceValue); 106 110 if (!m.find()) … … 214 218 public void applySafe(Window window) { 215 219 Point p = new Point(topLeft); 216 if (p.x > Toolkit.getDefaultToolkit().getScreenSize().width - 10) {220 if (p.x < 0 || p.x > Toolkit.getDefaultToolkit().getScreenSize().width - 10) { 217 221 p.x = 0; 218 222 } 219 if (p.y >Toolkit.getDefaultToolkit().getScreenSize().height - 10) {223 if (p.y < 0 || p.y > Toolkit.getDefaultToolkit().getScreenSize().height - 10) { 220 224 p.y = 0; 221 225 } … … 223 227 window.setSize(extent); 224 228 } 229 230 /** 231 * Applies this geometry to a window. Makes sure that the window is not 232 * placed outside of the coordinate range of all available screens. 233 * 234 * @param window the window 235 */ 236 public void applySafeMultiScreen(Window window) { 237 Point p = new Point(topLeft); 238 239 Rectangle virtualBounds = new Rectangle(); 240 GraphicsEnvironment ge = GraphicsEnvironment 241 .getLocalGraphicsEnvironment(); 242 GraphicsDevice[] gs = ge.getScreenDevices(); 243 for (int j = 0; j < gs.length; j++) { 244 GraphicsDevice gd = gs[j]; 245 GraphicsConfiguration[] gc = gd.getConfigurations(); 246 for (int i = 0; i < gc.length; i++) { 247 virtualBounds = virtualBounds.union(gc[i].getBounds()); 248 } 249 } 250 251 if (p.x < virtualBounds.x) { 252 p.x = virtualBounds.x; 253 } else if (p.x > virtualBounds.x + virtualBounds.width - extent.width) { 254 p.x = virtualBounds.x + virtualBounds.width - extent.width; 255 } 256 257 if (p.y < virtualBounds.y) { 258 p.y = virtualBounds.y; 259 } else if (p.y > virtualBounds.y + virtualBounds.height - extent.height) { 260 p.y = virtualBounds.y + virtualBounds.height - extent.height; 261 } 262 263 window.setLocation(p); 264 window.setSize(extent); 265 } 225 266 }
Note:
See TracChangeset
for help on using the changeset viewer.