Package org.openstreetmap.josm.gui.util
Class WindowGeometry
java.lang.Object
org.openstreetmap.josm.gui.util.WindowGeometry
This is a helper class for persisting the geometry of a JOSM window to the preference store
and for restoring it from the preference store.
- Since:
- 12678 (moved from
toolspackage, 2008
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException thrown by the WindowGeometry class if something goes wrong -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Dimensionthe sizestatic final BooleanPropertyWhether storing/restoring of geometries to/from preferences is enabledstatic final StringPreference key for theMainFramegeometryprivate Pointthe top left point -
Constructor Summary
ConstructorsConstructorDescriptionWindowGeometry(Point topLeft, Dimension extent) Creates a window geometry from a position and dimensionWindowGeometry(Rectangle rect) Creates a window geometry from a rectangleWindowGeometry(Window window) Creates a window geometry from the position and the size of a window.WindowGeometry(String preferenceKey) Creates a window geometry from the values kept in the preference store under the keypreferenceKeyWindowGeometry(String preferenceKey, WindowGeometry defaultGeometry) Creates a window geometry from the values kept in the preference store under the keypreferenceKey. -
Method Summary
Modifier and TypeMethodDescriptionvoidApplies this geometry to a window.static WindowGeometrycenterInWindow(Component reference, Dimension extent) Replies a window geometry object for a window with a specific size which is centered relative to the parent window of a reference component.static WindowGeometrycenterOnScreen(Dimension extent) Replies a window geometry object for a window with a specific size which is centered on screen, where main window isstatic WindowGeometrycenterOnScreen(Dimension extent, String preferenceKey) Replies a window geometry object for a window with a specific size which is centered on screen where the corresponding window is.booleanvoidFixes a window geometry to shift to the correct screen.static RectangleFind the size of the full virtual screen.static DimensiongetMaxDimensionOnScreen(JComponent component) Computes the maximum dimension for a component to fit in screen displayingcomponent.private RectangleReplies the size and position specified by the geometryprivate static RectangleFind the size and position of the screen for given coordinates.static RectanglegetScreenInfo(String preferenceKey) Find the size and position of the screen for given coordinates.getSize()Replies the size specified by the geometryReplies the top left point for the geometrystatic RectangleComputes the virtual bounds of graphics environment, as an union of all screen bounds.inthashCode()protected final voidinitFromPreferences(String preferenceKey) protected final voidprotected static booleanisBugInMaximumWindowBounds(Rectangle maxbounds) Determines if the bug affecting getMaximumWindowBounds() occurred.static WindowGeometrymainWindow(String preferenceKey, String arg, boolean maximize) Gets the geometry of the main windowprotected intparseField(String preferenceKey, String preferenceValue, String field) voidRemembers a window geometry under a specific preference keytoString()
-
Field Details
-
PREF_KEY_GUI_GEOMETRY
Preference key for theMainFramegeometry- See Also:
-
GUI_GEOMETRY_ENABLED
Whether storing/restoring of geometries to/from preferences is enabled -
topLeft
the top left point -
extent
the size
-
-
Constructor Details
-
WindowGeometry
Creates a window geometry from a position and dimension- Parameters:
topLeft- the top left pointextent- the extent
-
WindowGeometry
Creates a window geometry from a rectangle- Parameters:
rect- the position
-
WindowGeometry
Creates a window geometry from the position and the size of a window.- Parameters:
window- the window- Throws:
IllegalComponentStateException- if the window is not showing on the screen
-
WindowGeometry
Creates a window geometry from the values kept in the preference store under the keypreferenceKey- Parameters:
preferenceKey- the preference key- Throws:
WindowGeometry.WindowGeometryException- if no such key exist or if the preference value has an illegal format
-
WindowGeometry
Creates a window geometry from the values kept in the preference store under the keypreferenceKey. Falls back to thedefaultGeometryif something goes wrong.- Parameters:
preferenceKey- the preference keydefaultGeometry- the default geometry
-
-
Method Details
-
centerOnScreen
Replies a window geometry object for a window with a specific size which is centered on screen, where main window is- Parameters:
extent- the size- Returns:
- the geometry object
-
centerOnScreen
Replies a window geometry object for a window with a specific size which is centered on screen where the corresponding window is.- Parameters:
extent- the sizepreferenceKey- the key to get window size and position from, null value format for whole virtual screen- Returns:
- the geometry object
-
centerInWindow
Replies a window geometry object for a window with a specific size which is centered relative to the parent window of a reference component.- Parameters:
reference- the reference component.extent- the size- Returns:
- the geometry object
-
fixScreen
Fixes a window geometry to shift to the correct screen.- Parameters:
window- the window
-
parseField
protected int parseField(String preferenceKey, String preferenceValue, String field) throws WindowGeometry.WindowGeometryException -
initFromPreferences
protected final void initFromPreferences(String preferenceKey) throws WindowGeometry.WindowGeometryException -
initFromWindowGeometry
-
mainWindow
Gets the geometry of the main window- Parameters:
preferenceKey- The preference key to usearg- The command line geometry argumentsmaximize- If the user requested to maximize the window- Returns:
- The geometry for the main window
-
remember
Remembers a window geometry under a specific preference key- Parameters:
preferenceKey- the preference key
-
getTopLeft
Replies the top left point for the geometry- Returns:
- the top left point for the geometry
-
getSize
Replies the size specified by the geometry- Returns:
- the size specified by the geometry
-
getRectangle
Replies the size and position specified by the geometry- Returns:
- the size and position specified by the geometry
-
applySafe
Applies this geometry to a window. Makes sure that the window is not placed outside of the coordinate range of all available screens.- Parameters:
window- the window
-
isBugInMaximumWindowBounds
Determines if the bug affecting getMaximumWindowBounds() occurred.- Parameters:
maxbounds- result of getMaximumWindowBounds()- Returns:
trueif the bug happened,false otherwise- See Also:
-
getVirtualScreenBounds
Computes the virtual bounds of graphics environment, as an union of all screen bounds.- Returns:
- The virtual bounds of graphics environment, as an union of all screen bounds.
- Since:
- 6522
-
getMaxDimensionOnScreen
Computes the maximum dimension for a component to fit in screen displayingcomponent.- Parameters:
component- The component to get current screen info from. Must not benull- Returns:
- the maximum dimension for a component to fit in current screen
- Throws:
IllegalArgumentException- ifcomponentis null- Since:
- 7463
-
getScreenInfo
Find the size and position of the screen for given coordinates. Use first screen, when no coordinates are stored or null is passed.- Parameters:
preferenceKey- the key to get size and position from- Returns:
- bounds of the screen
-
getScreenInfo
Find the size and position of the screen for given coordinates. Use first screen, when no coordinates are stored or null is passed.- Parameters:
g- coordinates to check- Returns:
- bounds of the screen
-
getFullScreenInfo
Find the size of the full virtual screen.- Returns:
- size of the full virtual screen
-
hashCode
-
equals
-
toString
-