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