Changeset 5514 in josm for trunk/src/org
- Timestamp:
- 2012-09-17T17:59:41+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r5481 r5514 790 790 private void handleComponentEvent(ComponentEvent e) { 791 791 Component c = e.getComponent(); 792 if (c instanceof JFrame && c.isVisible() && Main.windowState == JFrame.NORMAL) { 793 Main.geometry = new WindowGeometry((JFrame) c); 792 if (c instanceof JFrame && c.isVisible()) { 793 if(Main.windowState == JFrame.NORMAL) { 794 Main.geometry = new WindowGeometry((JFrame) c); 795 } else { 796 Main.geometry.fixScreen((JFrame) c); 797 } 794 798 } 795 799 } -
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r5504 r5514 82 82 /** 83 83 * Exception thrown by the WindowGeometry class if something goes wrong 84 *85 84 */ 86 85 static public class WindowGeometryException extends Exception { … … 100 99 101 100 /** 101 * Creates a window geometry from a position and dimension 102 102 * 103 103 * @param topLeft the top left point … … 110 110 111 111 /** 112 * 112 * Creates a window geometry from a rectangle 113 * 113 114 * @param rect the position 114 115 */ … … 125 126 public WindowGeometry(Window window) { 126 127 this(window.getLocationOnScreen(), window.getSize()); 128 } 129 130 /** 131 * Fixes a window geometry to shift to the correct screen. 132 * 133 * @param window the window 134 */ 135 public void fixScreen(Window window) { 136 Rectangle oldScreen = getScreenInfo(getRectangle()); 137 Rectangle newScreen = getScreenInfo(new Rectangle(window.getLocationOnScreen(), window.getSize())); 138 if(oldScreen.x != newScreen.x) { 139 this.topLeft.x += newScreen.x - oldScreen.x; 140 } 141 if(oldScreen.y != newScreen.y) { 142 this.topLeft.y += newScreen.y - oldScreen.y; 143 } 127 144 } 128 145 … … 250 267 251 268 /** 252 * Replies the size spe zified by the geometry253 * 254 * @return the size spe zified by the geometry269 * Replies the size specified by the geometry 270 * 271 * @return the size specified by the geometry 255 272 */ 256 273 public Dimension getSize() { … … 258 275 } 259 276 277 /** 278 * Replies the size and position specified by the geometry 279 * 280 * @return the size and position specified by the geometry 281 */ 260 282 private Rectangle getRectangle() { 261 283 return new Rectangle(topLeft, extent); … … 278 300 GraphicsDevice gd = gs[j]; 279 301 if (gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) { 280 302 virtualBounds = virtualBounds.union(gd.getDefaultConfiguration().getBounds()); 281 303 } 282 304 } … … 303 325 * 304 326 * @param preferenceKey the key to get size and position from 327 * @return bounds of the screen 305 328 */ 306 329 public static Rectangle getScreenInfo(String preferenceKey) { … … 308 331 /* default: something on screen 1 */ 309 332 new WindowGeometry(new Point(0,0), new Dimension(10,10))).getRectangle(); 333 return getScreenInfo(g); 334 } 335 336 /** 337 * Find the size and position of the screen for given coordinates. Use first screen, 338 * when no coordinates are stored or null is passed. 339 * 340 * @param g coordinates to check 341 * @return bounds of the screen 342 */ 343 private static Rectangle getScreenInfo(Rectangle g) { 310 344 GraphicsEnvironment ge = GraphicsEnvironment 311 345 .getLocalGraphicsEnvironment(); … … 351 385 /** 352 386 * Find the size of the full virtual screen. 387 * @return size of the full virtual screen 353 388 */ 354 389 public static Rectangle getFullScreenInfo() {
Note:
See TracChangeset
for help on using the changeset viewer.