public class MagnetController extends Object
ScreenDockStation uses one MagnetController to calculate attractions
between its children. The MagnetController makes use of a MagnetStrategy
and of several AttractorStrategys to modify the location and size of the currently
moved ScreenDockWindow.ScreenDockWindows have to call start(ScreenDockWindow) when they start
moving or resizing.| Constructor and Description |
|---|
MagnetController(ScreenDockStation station)
Creates a new
MagnetController. |
| Modifier and Type | Method and Description |
|---|---|
int |
distance(ScreenDockWindow windowA,
MagnetRequest.Side sideA,
ScreenDockWindow windowB,
MagnetRequest.Side sideB,
boolean initialBoundaries)
Calculates the distance between
sideA of windowA to sideB of windowB. |
ScreenDockWindow[] |
getAttracted(ScreenDockWindow window)
|
AttractorStrategy.Attraction |
getAttraction(Dockable moved,
Dockable fixed)
Tells whether
fixed and moved attract each other. |
AttractorStrategy |
getAttractorStrategy()
Gets the currently used
AttractorStrategy. |
DockController |
getController()
Gets the
DockController that is currently used by this MagnetController. |
ScreenDockWindow |
getCurrent()
Gets the window that is currently moved.
|
ScreenDockStation |
getStation()
Gets the
ScreenDockStation which is using this MagnetController. |
AttractorStrategy.Attraction |
getStickiness(Dockable moved,
Dockable fixed)
Tells whether
fixed and moved stick to each other. |
MagnetStrategy |
getStrategy()
Gets the
MagnetStrategy that is currently used by this controller. |
int |
getValue(Rectangle rectangle,
MagnetRequest.Side side)
Gets the location of the side
side of rectangle. |
int |
getValue(ScreenDockWindow window,
MagnetRequest.Side side,
boolean initialBoundaries)
Gets the location of the side
side of window. |
ScreenDockWindow[] |
getWindows()
Gets an array containing all the
ScreenDockWindows that are currently shown by the station. |
boolean |
intersectHorizontally(ScreenDockWindow windowA,
ScreenDockWindow windowB,
boolean initialBoundaries)
Tells whether the
y coordinate and the height of windowA and windowB
are such that they have at least one pixel at the same height. |
boolean |
intersectVertically(ScreenDockWindow windowA,
ScreenDockWindow windowB,
boolean initialBoundaries)
Tells whether the
x coordinate and the width of windowA and windowB
are such that they have at least one pixel at the same width. |
void |
setAttractorStrategy(AttractorStrategy strategy)
Sets the
AttractorStrategy to use. |
void |
setController(DockController controller)
Sets the
DockController which is to be used by this MagnetController. |
void |
setStrategy(MagnetStrategy strategy)
Sets the
MagnetStrategy that is to be used by this controller. |
MagnetizedOperation |
start(ScreenDockWindow window)
Starts a move or resize operation that involves
window. |
public MagnetController(ScreenDockStation station)
MagnetController.station - the station using this controller, not null@FrameworkOnly public void setController(DockController controller)
DockController which is to be used by this MagnetController.controller - the controller to use or nullpublic DockController getController()
DockController that is currently used by this MagnetController.nullpublic ScreenDockStation getStation()
ScreenDockStation which is using this MagnetController.nullpublic MagnetizedOperation start(ScreenDockWindow window)
window. Only
one operation can be running at the same time.window - the window which is moved or resizedwindow further
changes position or sizepublic AttractorStrategy.Attraction getAttraction(Dockable moved, Dockable fixed)
fixed and moved attract each other.moved - the dockable that has movedfixed - the dockable that has not movedAttractorStrategyspublic AttractorStrategy.Attraction getStickiness(Dockable moved, Dockable fixed)
fixed and moved stick to each other.moved - the dockable that has movedfixed - the dockable that has not movedAttractorStrategyspublic ScreenDockWindow getCurrent()
nullpublic ScreenDockWindow[] getWindows()
ScreenDockWindows that are currently shown by the station.public ScreenDockWindow[] getAttracted(ScreenDockWindow window)
window - the window that has moved and whose partners are searchednull, does not contain windowpublic int distance(ScreenDockWindow windowA, MagnetRequest.Side sideA, ScreenDockWindow windowB, MagnetRequest.Side sideB, boolean initialBoundaries)
sideA of windowA to sideB of windowB.
If either window is the current window, then its base boundaries
are used instead of its current boundaries.windowA - the first windowsideA - the side of the window to checkwindowB - the second windowsideB - the side of the second window to checkinitialBoundaries - if true, then the initial boundaries of window is usedIllegalArgumentException - if sideA and sideB are neither equal nor oppositepublic boolean intersectHorizontally(ScreenDockWindow windowA, ScreenDockWindow windowB, boolean initialBoundaries)
y coordinate and the height of windowA and windowB
are such that they have at least one pixel at the same height.windowA - the first windowwindowB - the second windowinitialBoundaries - if true, then the initial boundaries of window is usedtrue if both windows have at least one pixel on the same heightpublic boolean intersectVertically(ScreenDockWindow windowA, ScreenDockWindow windowB, boolean initialBoundaries)
x coordinate and the width of windowA and windowB
are such that they have at least one pixel at the same width.windowA - the first windowwindowB - the second windowinitialBoundaries - if true, then the initial boundaries of window is usedtrue if both windows have at least one pixel on the same widthpublic int getValue(ScreenDockWindow window, MagnetRequest.Side side, boolean initialBoundaries)
side of window. If window is the
current window, then its base boundaries are used
to calculate the coordinates, otherwise ScreenDockWindow.getWindowBounds() is used.window - some windowside - the side to readinitialBoundaries - if true, then the initial boundaries of window is usedsidepublic int getValue(Rectangle rectangle, MagnetRequest.Side side)
side of rectangle.rectangle - some rectangleside - the side to readsidepublic MagnetStrategy getStrategy()
MagnetStrategy that is currently used by this controller.null if no DockController is setpublic void setStrategy(MagnetStrategy strategy)
MagnetStrategy that is to be used by this controller.strategy - the strategy, a value of null reinstalls the default strategypublic AttractorStrategy getAttractorStrategy()
AttractorStrategy.Dockables attract each otherpublic void setAttractorStrategy(AttractorStrategy strategy)
AttractorStrategy to use.strategy - the strategy, a value of null reinstalls the default strategyCopyright © 2017 Docking Frames. All rights reserved.