bibliothek.gui.dock.station.layer
Class OrderedLayerCollection

java.lang.Object
  extended by bibliothek.gui.dock.station.layer.OrderedLayerCollection

public class OrderedLayerCollection
extends Object

The OrderedLayerCollection is a helper class that allows order a set DockStations according to the rules defined in DockStationDropLayer.

Author:
Benjamin Sigg

Constructor Summary
OrderedLayerCollection()
           
 
Method Summary
 void add(DockStation station)
          Adds an additional station which is to be ordered.
protected  int compare(DockStationDropLayer a, DockStationDropLayer b)
          Works like Comparator.compare(Object, Object), compares a to b.
 List<DockStation> sort(int x, int y)
          Sorts the current set of DockStations currently known to this collection.
protected  List<DockStationDropLayer> sort(List<DockStationDropLayer> layers)
          Creates a new ordered list containing all items of layer, the new list is built by an algorithm that is resistent against inconstant ordering.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderedLayerCollection

public OrderedLayerCollection()
Method Detail

add

public void add(DockStation station)
Adds an additional station which is to be ordered.

Parameters:
station - the additional station

sort

public List<DockStation> sort(int x,
                              int y)
Sorts the current set of DockStations currently known to this collection.

Parameters:
x - the x-coordinate of the mouse on the screen
y - the y-coordinate of the mouse on the screen
Returns:
the ordered stations, where the first station is the station with the highest priority

sort

protected List<DockStationDropLayer> sort(List<DockStationDropLayer> layers)
Creates a new ordered list containing all items of layer, the new list is built by an algorithm that is resistent against inconstant ordering.

Parameters:
layers - the layers to order
Returns:
the ordered layers

compare

protected int compare(DockStationDropLayer a,
                      DockStationDropLayer b)
Works like Comparator.compare(Object, Object), compares a to b.

Parameters:
a - the first object to compare
b - the second object to compare
Returns:
a value less/equal/greater to 0 depending on whether a is less/equal/greater than b.