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

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

public class DefaultMagnetStrategy
extends Object
implements MagnetStrategy

The DefaultMagnetStrategy is based on the DefaultMagnetOperation. It 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
DefaultMagnetStrategy()
           
 
Method Summary
 int getThreshold()
          Tells how many pixels two sides can be appart and still attract each other.
 void install(MagnetController controller)
          Informs this MagnetStrategy that it will be used by controller.
 void setThreshold(int threshold)
          Sets how many pixels two sides can be appart and still attract each other.
 MagnetOperation start(MagnetController controller, MagnetRequest request)
          Called by controller after a ScreenDockWindow moved or changed its size (or both).
 void uninstall(MagnetController controller)
          Informs this MagnetStrategy that it is no longer used by controller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMagnetStrategy

public DefaultMagnetStrategy()
Method Detail

setThreshold

public void setThreshold(int threshold)
Sets how many pixels two sides can be appart and still attract each other.

Parameters:
threshold - the maximal distance, at least 1

getThreshold

public int getThreshold()
Tells how many pixels two sides can be appart and still attract each other.

Returns:
the maximal distance, at least 1

install

public void install(MagnetController controller)
Description copied from interface: MagnetStrategy
Informs this MagnetStrategy that it will be used by controller.

Specified by:
install in interface MagnetStrategy
Parameters:
controller - the controller using this strategy, not null

uninstall

public void uninstall(MagnetController controller)
Description copied from interface: MagnetStrategy
Informs this MagnetStrategy that it is no longer used by controller.

Specified by:
uninstall in interface MagnetStrategy
Parameters:
controller - the controller which no longer uses this strategy

start

public MagnetOperation start(MagnetController controller,
                             MagnetRequest request)
Description copied from interface: MagnetStrategy
Called by controller after a ScreenDockWindow moved or changed its size (or both). This method creates a new MagnetOperation which is tied to request. The MagnetOperation will then find out which Dockable is attracted to which other Dockable.

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