public class DefaultMagnetStrategy extends Object implements MagnetStrategy
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.Constructor and Description |
---|
DefaultMagnetStrategy() |
Modifier and Type | Method and Description |
---|---|
int |
getThreshold()
Tells how many pixels two sides can be apart 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 apart 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 . |
public void setThreshold(int threshold)
threshold
- the maximal distance, at least 1public int getThreshold()
public void install(MagnetController controller)
MagnetStrategy
MagnetStrategy
that it will be used by controller
.install
in interface MagnetStrategy
controller
- the controller using this strategy, not null
public void uninstall(MagnetController controller)
MagnetStrategy
MagnetStrategy
that it is no longer used by controller
.uninstall
in interface MagnetStrategy
controller
- the controller which no longer uses this strategypublic MagnetOperation start(MagnetController controller, MagnetRequest request)
MagnetStrategy
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
.start
in interface MagnetStrategy
controller
- the caller of this method, may be used to find other ScreenDockWindow
srequest
- detailed information about the event