public class StackMerger extends Object implements Merger
StackDockStation
s and merges them into one.Constructor and Description |
---|
StackMerger() |
Modifier and Type | Method and Description |
---|---|
boolean |
canMerge(StationDropOperation operation,
DockStation parent,
DockStation child)
Checks whether
Merger.merge(StationDropOperation, DockStation, DockStation) will succeed or not. |
void |
merge(StationDropOperation operation,
DockStation parent,
DockStation child)
Moves all children of
child to parent , leaving child
empty. |
public boolean canMerge(StationDropOperation operation, DockStation parent, DockStation child)
Merger
Merger.merge(StationDropOperation, DockStation, DockStation)
will succeed or not. This
method will only be called if parent
would accept all children
of child
. This method may be called during "drop" and during "move" operations.canMerge
in interface Merger
operation
- the operation that would be executed, can be null
parent
- an existing stationchild
- a station that is dragged around and may be dropped onto parent
Merger.merge(StationDropOperation, DockStation, DockStation)
will succeedpublic void merge(StationDropOperation operation, DockStation parent, DockStation child)
Merger
child
to parent
, leaving child
empty. This method is only called if canMerge
returned true
and if the accept
-methods allow the operation.child
is not parent
, then child
will be removed
from its parent. Otherwise the child remains, allowing this Merger
to reuse it.