Package slash.navigation.gui
Class WindowBounds
java.lang.Object
slash.navigation.gui.WindowBounds
Restores and persists the size and location of a
Window through
Preferences, and enforces a minimum size so a window can never be
shrunk small enough to become un-findable. SimpleDialog (dialogs)
uses this for the full restore/persist/min-clamp cycle; SingleFrameApplication
(the main frame) keeps its own restore/persist logic and shares only the
crop(java.lang.String, int, int, int) clamping helper with it. Keys are namespaced by keyPrefix
(empty for the single main frame, "dialogName-" for dialogs).- Author:
- Christian Pesch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PointcomputeLocation(int savedX, int savedY, int width, int height, Rectangle bounds, Insets insets) Pure location computation: the stored x/y cropped so the window of the given size stays on the usable screen.static DimensioncomputeSize(int savedWidth, int savedHeight, Rectangle bounds, Insets insets) Pure size computation: the stored width/height cropped to the usable screen.static intClampspositioninto [minimum;maximum], leaving the "unset" sentinel -1 untouched so callers can distinguish "no stored value".voidInstalls listeners that persist size and location live as the user resizes/moves, matching the main frame's behaviour.voidvoidputSize()voidRestores size and location onto the window.
-
Constructor Details
-
WindowBounds
-
-
Method Details
-
crop
Clampspositioninto [minimum;maximum], leaving the "unset" sentinel -1 untouched so callers can distinguish "no stored value". -
computeSize
public static Dimension computeSize(int savedWidth, int savedHeight, Rectangle bounds, Insets insets) Pure size computation: the stored width/height cropped to the usable screen. Returns null when there is no usable stored size (keep the packed size), preserving the historicwidth > 120 && height > 60guard. -
computeLocation
public static Point computeLocation(int savedX, int savedY, int width, int height, Rectangle bounds, Insets insets) Pure location computation: the stored x/y cropped so the window of the given size stays on the usable screen. Returns null when unset. -
restore
Restores size and location onto the window. The caller must have packed the window first, so its current size is the packed preferred size — that becomes the minimum (every component stays visible), floored by the absolute minimum. A stored size is applied on top, clamped to the minimum; a stored location is applied, else the window is centered onlocationRelativeTo. -
installLivePersistence
public void installLivePersistence()Installs listeners that persist size and location live as the user resizes/moves, matching the main frame's behaviour. -
putLocation
public void putLocation() -
putSize
public void putSize()
-