bibliothek.gui.dock.station.screen.magnet
Class DefaultMagnetOperation

java.lang.Object
  extended by bibliothek.gui.dock.station.screen.magnet.DefaultMagnetOperation
All Implemented Interfaces:
MagnetOperation

public class DefaultMagnetOperation
extends Object
implements MagnetOperation

The DefaultMagnetOperation searches the nearest attracted ScreenDockWindow to a moved side and if that other window is nearer than a given threshold then the moved window is attracted.

Author:
Benjamin Sigg

Constructor Summary
DefaultMagnetOperation(int threshold)
          Creates a new operation
 
Method Summary
 void attract(MagnetController controller, MagnetRequest request)
          Called by controller after a ScreenDockWindow moved or changed its size (or both).
 void destroy()
          Called once the operation is no longer needed.
protected  void moved(MagnetController controller, MagnetRequest request)
          Called if a window was moved.
protected  void resized(MagnetController controller, MagnetRequest request)
          Called if a window was resized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMagnetOperation

public DefaultMagnetOperation(int threshold)
Creates a new operation

Parameters:
threshold - the maximum distance between two items in pixels allowing them to interact with each other
Method Detail

attract

public void attract(MagnetController controller,
                    MagnetRequest request)
Description copied from interface: MagnetOperation
Called by controller after a ScreenDockWindow moved or changed its size (or both). This method has to find out whether the window is attracted to another window and if so it must call one of the attract methods of request.

Specified by:
attract in interface MagnetOperation
Parameters:
controller - the caller of this method, may be used to find other ScreenDockWindows
request - detailed information about the event

destroy

public void destroy()
Description copied from interface: MagnetOperation
Called once the operation is no longer needed.

Specified by:
destroy in interface MagnetOperation

moved

protected void moved(MagnetController controller,
                     MagnetRequest request)
Called if a window was moved.

Parameters:
controller - the caller
request - information about the window that was moved

resized

protected void resized(MagnetController controller,
                       MagnetRequest request)
Called if a window was resized.

Parameters:
controller - the caller
request - information about the window that was resized