public class WindowGeometry extends Object
Modifier and Type | Class and Description |
---|---|
static class |
WindowGeometry.WindowGeometryException
Exception thrown by the WindowGeometry class if something goes wrong
|
Modifier and Type | Field and Description |
---|---|
private Dimension |
extent
the size
|
private Point |
topLeft
the top left point
|
Constructor and Description |
---|
WindowGeometry(Point topLeft,
Dimension extent)
Creates a window geometry from a position and dimension
|
WindowGeometry(Rectangle rect)
Creates a window geometry from a rectangle
|
WindowGeometry(String preferenceKey)
Creates a window geometry from the values kept in the preference store under the
key
preferenceKey |
WindowGeometry(String preferenceKey,
WindowGeometry defaultGeometry)
Creates a window geometry from the values kept in the preference store under the
key
preferenceKey . |
WindowGeometry(Window window)
Creates a window geometry from the position and the size of a window.
|
Modifier and Type | Method and Description |
---|---|
void |
applySafe(Window window)
Applies this geometry to a window.
|
static WindowGeometry |
centerInWindow(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 WindowGeometry |
centerOnScreen(Dimension extent)
Replies a window geometry object for a window with a specific size which is
centered on screen, where main window is
|
static WindowGeometry |
centerOnScreen(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.
|
void |
fixScreen(Window window)
Fixes a window geometry to shift to the correct screen.
|
static Rectangle |
getFullScreenInfo()
Find the size of the full virtual screen.
|
static Dimension |
getMaxDimensionOnScreen(JComponent component)
Computes the maximum dimension for a component to fit in screen displaying
component . |
private Rectangle |
getRectangle()
Replies the size and position specified by the geometry
|
private static Rectangle |
getScreenInfo(Rectangle g)
Find the size and position of the screen for given coordinates.
|
static Rectangle |
getScreenInfo(String preferenceKey)
Find the size and position of the screen for given coordinates.
|
Dimension |
getSize()
Replies the size specified by the geometry
|
Point |
getTopLeft()
Replies the top left point for the geometry
|
static Rectangle |
getVirtualScreenBounds()
Computes the virtual bounds of graphics environment, as an union of all screen bounds.
|
protected void |
initFromPreferences(String preferenceKey) |
protected void |
initFromWindowGeometry(WindowGeometry other) |
protected static boolean |
isBugInMaximumWindowBounds(Rectangle maxbounds)
Determines if the bug affecting getMaximumWindowBounds() occured.
|
static WindowGeometry |
mainWindow(String preferenceKey,
String arg,
boolean maximize) |
protected int |
parseField(String preferenceKey,
String preferenceValue,
String field) |
void |
remember(String preferenceKey)
Remembers a window geometry under a specific preference key
|
String |
toString() |
public WindowGeometry(Point topLeft, Dimension extent)
topLeft
- the top left pointextent
- the extentpublic WindowGeometry(Rectangle rect)
rect
- the positionpublic WindowGeometry(Window window)
window
- the windowpublic WindowGeometry(String preferenceKey) throws WindowGeometry.WindowGeometryException
preferenceKey
preferenceKey
- the preference keyWindowGeometry.WindowGeometryException
- if no such key exist or if the preference value has
an illegal formatpublic WindowGeometry(String preferenceKey, WindowGeometry defaultGeometry)
preferenceKey
. Falls back to the defaultGeometry
if
something goes wrong.preferenceKey
- the preference keydefaultGeometry
- the default geometrypublic static WindowGeometry centerOnScreen(Dimension extent)
extent
- the sizepublic static WindowGeometry centerOnScreen(Dimension extent, String preferenceKey)
extent
- the sizepreferenceKey
- the key to get window size and position from, null value format
for whole virtual screenpublic static WindowGeometry centerInWindow(Component reference, Dimension extent)
reference
- the reference component.extent
- the sizepublic void fixScreen(Window window)
window
- the windowprotected int parseField(String preferenceKey, String preferenceValue, String field) throws WindowGeometry.WindowGeometryException
protected final void initFromPreferences(String preferenceKey) throws WindowGeometry.WindowGeometryException
protected final void initFromWindowGeometry(WindowGeometry other)
public static WindowGeometry mainWindow(String preferenceKey, String arg, boolean maximize)
public void remember(String preferenceKey)
preferenceKey
- the preference keypublic Point getTopLeft()
public Dimension getSize()
private Rectangle getRectangle()
public void applySafe(Window window)
window
- the windowprotected static boolean isBugInMaximumWindowBounds(Rectangle maxbounds)
maxbounds
- result of getMaximumWindowBounds()true
if the bug happened, false otherwise
public static Rectangle getVirtualScreenBounds()
public static Dimension getMaxDimensionOnScreen(JComponent component)
component
.component
- The component to get current screen info from. Must not be null
IllegalArgumentException
- if component
is nullpublic static Rectangle getScreenInfo(String preferenceKey)
preferenceKey
- the key to get size and position fromprivate static Rectangle getScreenInfo(Rectangle g)
g
- coordinates to checkpublic static Rectangle getFullScreenInfo()