com.javadocking.util
Class DockingUtil

java.lang.Object
  extended by com.javadocking.util.DockingUtil

public class DockingUtil
extends java.lang.Object

This class contains a collection of static utility methods for docking.

Author:
Heidi Rakels.

Method Summary
static boolean contains(LeafDock leafDock, Dockable dockabe)
          Determines if the given dockable is docked in the given leaf dock.
static boolean containsDock(Dock rootDock, Dock dock)
          Tries to find the dock in the dock tree with the given dock as root.
static boolean containsRootDock(DockModel dockModel, Dock rootDock)
          Determines if the given dock is a root dock of the dock model.
static Dockable createDockable(Dock dock)
           Creates one dockable with the dockables of a dock.
static java.awt.Dimension getCompositeDockablePreferredSize(CompositeDockable compositeDockable, int dockingMode)
          Computes the preferred size of a composite dockable.
static java.awt.Dimension getDockablePreferredSize(Dockable dockable, int dockingMode)
           Computes the preferred size of a composite dockable.
static Dock getFloatChildDock(Dock dock)
          Searches the ancestor of the given dock that is the child of the root FloatDock.
static java.lang.String getFloatRootDockKey(java.awt.Window owner)
          Gets the key of the root dock that is a FloatDock of the given owner window in the dock model.
static Dock getRootDock(Dock dock)
          Gets the root dock of the dock tree that contains the given dock.
static java.lang.String getRootDockKey(Dock rootDock)
          Gets the key of the given root dock in the dock model of the docking manager.
static java.awt.Window getWindowOwner(java.lang.String rootDockKey)
          Gets the owner window that owns the root dock with the specified key.
static void removeEmptyChildren(CompositeDock compositeDock)
          Removes the empty child docks from the tree with the given dock as root.
static Dockable retrieveDockableOfDockModel(java.lang.String dockableID)
          Gets the dockable with the given ID, that is docked in a dock of the DockModel or that is visualized in a visualizer of the dock model.
static void retrieveDockables(Dockable rootDockable, java.util.List dockables)
          Retrieves all the leaf dockables of the dockable tree with the given dockable as root dockable.
static void retrieveDockables(Dock rootDock, java.util.List dockables)
          Retrieves the dockables that are contained by all the docks that are in the dock tree with the given dock as root dock.
static Dock searchDock(Dock rootDock, Dockable dockable)
          Tries to find the dock that contains the given dockable in the dock tree with the given dock as root.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

containsRootDock

public static boolean containsRootDock(DockModel dockModel,
                                       Dock rootDock)
Determines if the given dock is a root dock of the dock model.

Parameters:
dockModel - The dock model.
rootDock - The dock.
Returns:
True if the given dock is a root dock of the dock model, false otherwise.

contains

public static boolean contains(LeafDock leafDock,
                               Dockable dockabe)
Determines if the given dockable is docked in the given leaf dock.

Parameters:
leafDock - The leaf dock.
dockabe - The dockable. May be a CompositeDockable, even a deeper nested.
Returns:
True if the given dockable is docked in this leaf dock, false otherwise. If the given dockable is a composite dockable, all of its child dockables have to be docked in the leaf dock, otherwise false is returned.

getFloatRootDockKey

public static java.lang.String getFloatRootDockKey(java.awt.Window owner)
Gets the key of the root dock that is a FloatDock of the given owner window in the dock model.

Parameters:
owner - The owner of the float dock in the dock model model.
Returns:
The root dock that is a float dock of the given owner window. If there is no float root dock for the given owner, null is returned.

retrieveDockableOfDockModel

public static Dockable retrieveDockableOfDockModel(java.lang.String dockableID)
Gets the dockable with the given ID, that is docked in a dock of the DockModel or that is visualized in a visualizer of the dock model.

Parameters:
dockableID - The ID of the dockable.
Returns:
The dockable with the given ID, that is docked in a dock of the dock model. Null if there is no dockable with the given ID.

removeEmptyChildren

public static void removeEmptyChildren(CompositeDock compositeDock)
Removes the empty child docks from the tree with the given dock as root. The empty children of deeper child docks are also removed. The dock has only children if it is a CompositeDock.

Parameters:
compositeDock - The dock from which the empty children will be removed.

searchDock

public static Dock searchDock(Dock rootDock,
                              Dockable dockable)
Tries to find the dock that contains the given dockable in the dock tree with the given dock as root.

Parameters:
rootDock - The root dock of the tree of docks where the dockable will be searched.
dockable - The dockable that is searched.
Returns:
The dock in the dock tree in which the given dockable is docked, if it exists, null otherwise.

retrieveDockables

public static void retrieveDockables(Dock rootDock,
                                     java.util.List dockables)
Retrieves the dockables that are contained by all the docks that are in the dock tree with the given dock as root dock. It adds this dockables to the given list with dockables.

Parameters:
rootDock - The root dock of the dock tree.
dockables - The list to which all the dockables are added.

retrieveDockables

public static void retrieveDockables(Dockable rootDockable,
                                     java.util.List dockables)
Retrieves all the leaf dockables of the dockable tree with the given dockable as root dockable. The retrieved dockables are added to the given list. The composite dockables are not added to the list.

Parameters:
rootDockable - The root dockable of the dockable tree.
dockables - The list to which all the leaf dockables are added.

getRootDock

public static Dock getRootDock(Dock dock)
Gets the root dock of the dock tree that contains the given dock.

Parameters:
dock - The given dock.
Returns:
The root dock of the dock tree that contains the given dock. If the parent of the given dock is null, the dock itself is returned.

getFloatChildDock

public static Dock getFloatChildDock(Dock dock)
Searches the ancestor of the given dock that is the child of the root FloatDock. If the root dock of the given dock is not a float dock, null is returned.

Parameters:
dock - The given dock.
Returns:
If the root dock of the given dock is not a float dock, null is returned. Otherwise, if the given dock is a child dock of the root dock, the given dock is returned. Otherwise, the ancestor of the given dock that is the child of the float dock is returned.

createDockable

public static Dockable createDockable(Dock dock)

Creates one dockable with the dockables of a dock.

there are the following possible results:

Parameters:
dock - The dock for which a dockable is created.
Returns:
One dockable that contains the dockables of the given dock.

getDockablePreferredSize

public static java.awt.Dimension getDockablePreferredSize(Dockable dockable,
                                                          int dockingMode)

Computes the preferred size of a composite dockable.

When the dockable is a composite dockable this size depends on the docking mode.

Parameters:
dockable - The dockable whose preferred size is computed.
dockingMode - This should be DockingMode.TAB, DockingMode.GRID, DockingMode.HORIZONTAL_LINE or DockingMode.VERTICAL_LINE.
Returns:
The preferred size of a dockable.

getCompositeDockablePreferredSize

public static java.awt.Dimension getCompositeDockablePreferredSize(CompositeDockable compositeDockable,
                                                                   int dockingMode)
Computes the preferred size of a composite dockable. This size depends on the docking mode.

Parameters:
compositeDockable - The composite dockable whose preferred size is computed.
dockingMode - This should be DockingMode.TAB, DockingMode.GRID, DockingMode.HORIZONTAL_LINE or DockingMode.VERTICAL_LINE.
Returns:
The preferred size of a composite dockable.

getRootDockKey

public static java.lang.String getRootDockKey(Dock rootDock)
Gets the key of the given root dock in the dock model of the docking manager. Can be null, when the dock is used by a visualizer.

Parameters:
rootDock - A root dock of the dock model for which the key is searched.
Returns:
The key of the given root dock in the given dock model.
Throws:
java.lang.IllegalArgumentException - If the given dock is not a root dock.

getWindowOwner

public static java.awt.Window getWindowOwner(java.lang.String rootDockKey)
Gets the owner window that owns the root dock with the specified key.

Parameters:
rootDockKey - The key of the root dock for which the owner is retrieved.
Returns:
The owner window that owns the root dock with the specified key. Null when the key is not a key of a root dock.

containsDock

public static boolean containsDock(Dock rootDock,
                                   Dock dock)
Tries to find the dock in the dock tree with the given dock as root.

Parameters:
rootDock - The root dock of the tree of docks where the dock will be searched.
dock - The dock that is searched.
Returns:
True if it exists in the dock tree, false otherwise.