bibliothek.gui.dock.station.screen.magnet
Interface MagnetRequest


public interface MagnetRequest

Describes the movement of a ScreenDockWindow. Also offers methods to define attractions.

Author:
Benjamin Sigg

Nested Class Summary
static class MagnetRequest.Side
          Describes one side of a ScreenDockWindow.
 
Method Summary
 void directAttraction(Rectangle bounds)
          Directly changes the size and location of the window to match bounds.
Note that the current BoundaryRestriction may modify bounds
 Rectangle getBounds()
          Gets the boundaries the window would have if there would be no outside influences (like magnetism) to the boundaries.
 Rectangle getInitialBounds(ScreenDockWindow window)
          Gets the boundaries of window when this request was created.
 Rectangle getResultBounds()
          Gets the boundaries the window would actually have if the operation would end right now.
 ScreenDockWindow getWindow()
          Gets the window that has changed.
 boolean is(MagnetRequest.Side side)
          Calls isWest(), isEast(), isNorth() or isSouth() depending on side.
 boolean isEast()
          Tells whether the location of the east side of the window changed.
 boolean isMoved()
          Tells whether the entire window was moved.
 boolean isNorth()
          Tells whether the location of the north side of the window changed.
 boolean isResized()
          Tells whether the window changed its size.
 boolean isSouth()
          Tells whether the location of the south side of the window changed.
 boolean isWest()
          Tells whether the location of the west side of the window changed.
 void movingAttraction(ScreenDockWindow neighbor, MagnetRequest.Side windowSide, MagnetRequest.Side neighborSide)
          Moves the window such that its side windowSide is at the same location as the side neighborSide from neighbor.
 void resizingAttraction(ScreenDockWindow neighbor, MagnetRequest.Side windowSide, MagnetRequest.Side neighborSide)
          Resizes the window such that its side windowSide is at the same location as the side neighborSide from neighbor.
 

Method Detail

getWindow

ScreenDockWindow getWindow()
Gets the window that has changed.

Returns:
the modified window

getBounds

Rectangle getBounds()
Gets the boundaries the window would have if there would be no outside influences (like magnetism) to the boundaries.

Returns:
the unmodified boundaries, not null
See Also:
getResultBounds()

getResultBounds

Rectangle getResultBounds()
Gets the boundaries the window would actually have if the operation would end right now.

Returns:
the modified boundaries, not null
See Also:
getBounds()

getInitialBounds

Rectangle getInitialBounds(ScreenDockWindow window)
Gets the boundaries of window when this request was created.

Parameters:
window - some window
Returns:
the initial boundaries of window
Throws:
IllegalArgumentException - if window is not known to this request

isMoved

boolean isMoved()
Tells whether the entire window was moved. A window either is moved, resized or nothing happened.

Returns:
true if the entire window was moved
See Also:
isResized()

isResized

boolean isResized()
Tells whether the window changed its size. A window either is moved, resized or nothing happened.

Returns:
true if the window was resized
See Also:
isMoved()

isNorth

boolean isNorth()
Tells whether the location of the north side of the window changed. This may be due to a movement of the entire window or because the window was resized.

Returns:
true if the north side changed its position

isSouth

boolean isSouth()
Tells whether the location of the south side of the window changed. This may be due to a movement of the entire window or because the window was resized.

Returns:
true if the south side changed its position

isEast

boolean isEast()
Tells whether the location of the east side of the window changed. This may be due to a movement of the entire window or because the window was resized.

Returns:
true if the east side changed its position

isWest

boolean isWest()
Tells whether the location of the west side of the window changed. This may be due to a movement of the entire window or because the window was resized.

Returns:
true if the west side changed its position

is

boolean is(MagnetRequest.Side side)
Calls isWest(), isEast(), isNorth() or isSouth() depending on side.

Parameters:
side - the side to ask whether it changed
Returns:
true if the side changed its position

resizingAttraction

void resizingAttraction(ScreenDockWindow neighbor,
                        MagnetRequest.Side windowSide,
                        MagnetRequest.Side neighborSide)
Resizes the window such that its side windowSide is at the same location as the side neighborSide from neighbor.

Parameters:
neighbor - the window to which window is attracted
windowSide - the side of the window which has to be moved
neighborSide - the side of neighbor which has to be matched
Throws:
IllegalArgumentException - if neighbor is null or is the window itself, if either windowSide or neighborSide is null, if windowSide and neighborSide are not the same and not the opposite (e.g. north and west)

movingAttraction

void movingAttraction(ScreenDockWindow neighbor,
                      MagnetRequest.Side windowSide,
                      MagnetRequest.Side neighborSide)
Moves the window such that its side windowSide is at the same location as the side neighborSide from neighbor.

Parameters:
neighbor - the window to which window is attracted
windowSide - the side of the window which has to be moved
neighborSide - the side of neighbor which has to be matched
Throws:
IllegalArgumentException - if neighbor is null or is the window itself, if either windowSide or neighborSide is null, if windowSide and neighborSide are not the same and not the opposite (e.g. north and west)

directAttraction

void directAttraction(Rectangle bounds)
Directly changes the size and location of the window to match bounds.
Note that the current BoundaryRestriction may modify bounds

Parameters:
bounds - the new boundaries to use