Changeset 7463 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-08-30T01:59:31+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r7012 r7463 6 6 import java.awt.Component; 7 7 import java.awt.Dimension; 8 import java.awt.GraphicsConfiguration; 8 9 import java.awt.GraphicsDevice; 9 10 import java.awt.GraphicsEnvironment; 11 import java.awt.Insets; 10 12 import java.awt.Point; 11 13 import java.awt.Rectangle; … … 14 16 import java.util.regex.Matcher; 15 17 import java.util.regex.Pattern; 18 19 import javax.swing.JComponent; 16 20 17 21 import org.openstreetmap.josm.Main; … … 367 371 } 368 372 return virtualBounds; 373 } 374 375 /** 376 * Computes the maximum dimension for a component to fit in screen displaying {@code component}. 377 * @param component The component to get current screen info from. Must not be {@code null} 378 * @return the maximum dimension for a component to fit in current screen 379 * @throws IllegalArgumentException if {@code component} is null 380 * @since 7463 381 */ 382 public static Dimension getMaxDimensionOnScreen(JComponent component) { 383 CheckParameterUtil.ensureParameterNotNull(component, "component"); 384 // Compute max dimension of current screen 385 Dimension result = new Dimension(); 386 GraphicsConfiguration gc = component.getGraphicsConfiguration(); 387 if (gc == null && Main.parent != null) { 388 gc = Main.parent.getGraphicsConfiguration(); 389 } 390 if (gc != null) { 391 // Max displayable dimension (max screen dimension - insets) 392 Rectangle bounds = gc.getBounds(); 393 Insets insets = component.getToolkit().getScreenInsets(gc); 394 result.width = bounds.width - insets.left - insets.right; 395 result.height = bounds.height - insets.top - insets.bottom; 396 } 397 return result; 369 398 } 370 399
Note: See TracChangeset
for help on using the changeset viewer.