com.javadocking.dock
Class SplitDock

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.javadocking.dock.SplitDock
All Implemented Interfaces:
CompositeDock, Dock, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class SplitDock
extends javax.swing.JPanel
implements CompositeDock

This is a composite dock that can contain zero, one, or two child docks. It can not contain dockables. When dockables are added, child docks are created, and the dockables are added to the child docks.

Information on using split docks is in How to Use Composite Docks in The Sanaware Developer Guide.

When there is only one child dock, this dock is located in the center of this dock. When there are 2 child docks, there is one at the top and one at the bottom, or there is one at the left and one at the right. The child docks are put in a split pane created with the component factory of the docking manager DockingManager.getComponentFactory() with the method SwComponentFactory.createJSplitPane().

The positions for child docks of this dock are one-dimensional. The possible child docks and their first position values are:

A dockable can only be added if it has as one of its docking modes:

It can only be added in a position that corresponds with one of its docking modes.

If the mouse is inside a priority rectangle, the dockable can be docked with priority (see Priority.CAN_DOCK_WITH_PRIORITY). When the mouse is inside the panel of this dock, but outside the priority rectangles, the dockable can be docked, but without priority (see Priority.CAN_DOCK). When the dock is empty, the only priority rectangle is in the middle of the dock. When there is already a child dock, there are 4 priority rectangles at the 4 borders of the panel of this dock.

When this dock contains no child docks, it is empty. When this dock contains two child docks, it is full.

When this dock is empty, and a first dockable is added, a child dock is created with the factory retrieved by getChildDockFactory(). The dockable is added to the child dock. The child dock is put in the center of this panel.

When there is already one child dock in the center, and a new dockable is added, again a child dock is created with the factory retrieved by getChildDockFactory(). The dockable is added to the child dock. But now for both child docks a split dock is created with the factory retrieved by getCompositeChildDockFactory(). The child docks are added to these new docks, and these new docks are put at the left and the right side of the split of the split pane. These new docks are now the child docks of this split dock.

Author:
Heidi Rakels.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.javadocking.dock.CompositeDock
CHILD_DOCK_PREFIX
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SplitDock()
          Constructs a split dock with a LeafDockFactory as child dock factory and a SplitDockFactory as factory for the composite child docks.
SplitDock(DockFactory childDockFactory)
          Constructs a split dock with the given child dock factory.
SplitDock(DockFactory childDockFactory, CompositeDockFactory splitChildDockFactory)
          Constructs a split dock with the given child dock factories.
 
Method Summary
 void addChildDock(Dock dockToAdd, Position position)
           Adds the given dock as child dock at the given position.
 boolean addDockable(Dockable dockableToAdd, java.awt.Point relativeLocation, java.awt.Point dockableOffset)
           Adds a dockable to this dock.
 void addDockingListener(DockingListener listener)
          Adds a listener for DockingEvents of this dock.
protected  boolean canAddDockableWithPriority(Dockable dockable, java.awt.Point relativeLocation)
          Determines if the given dockable can be added to this dock with priority.
 void clearGhosts()
          Clears the ghost child docks from this dock.
 void emptyChild(Dock emptyChildDock)
          Is called when the specified child dock is empty.
 Dock getChildDock(int index)
          Gets the child dock with the specified index.
 int getChildDockCount()
          Gets the number of child docks of this dock.
 DockFactory getChildDockFactory()
          Gets the dock factory that creates the leaf child docks (LeafDock) for this dock.
 Position getChildDockPosition(Dock childDock)
          Gets the position, where the child dock is docked in this dock.
protected  int getChildDockWidth(int preferredWidth, int existingPreferredWidth, int totalWidth, int position)
          Computes the width for a component that will be added.
 CompositeDockFactory getCompositeChildDockFactory()
          Gets the dock factory that creates the split child docks for this dock.
 int getDividerLocation()
          Gets the divider location of the split pane.
protected  int getDockPosition(java.awt.Point relativeLocation, Dockable newDockable)
           Gets the position where the dockable should be docked in the dock given the mouse position.
 int getDockPriority(Dockable dockable, java.awt.Point relativeLocation)
           Determines if the dockable can be added.
 CompositeDock getParentDock()
          Gets the parent dock of this dock.
protected  void getPriorityRectangle(java.awt.Rectangle rectangle, int position)
           Gets the relative rectangle in this dock in which docking has priority.
 void ghostChild(Dock childDock)
          Makes the given empty child dock invisible.
 boolean isEmpty()
          Determines if this dock doesn't have any dockables docked in it, or doesn't have any child docks docked in it.
 boolean isFull()
          Determines if any more dockables can be added to this dock.
 boolean isRemoveLastEmptyChild()
          Determines if the last child dock that is empty, has to be removed.
 void loadProperties(java.lang.String prefix, java.util.Properties properties, java.util.Map childDocks, java.util.Map dockablesMap, java.awt.Window owner)
           Loads the properties for this dock.
 void removeDockingListener(DockingListener listener)
          Removes a listener for docking events of this dock.
 int retrieveDockingRectangle(Dockable dockable, java.awt.Point relativeLocation, java.awt.Point dockableOffset, java.awt.Rectangle rectangle)
           Sets the given rectangle to the position and size of the graphical content component of the dockable, when it will be docked in this dock.
 void saveProperties(java.lang.String prefix, java.util.Properties properties, java.util.Map childDockIds)
           Saves the properties of this dock in the given properties object.
 void setChildDockFactory(DockFactory childDockFactory)
          Sets the dock factory that creates the leaf child docks (LeafDock) for this dock.
 void setCompositeChildDockFactory(CompositeDockFactory splitDockFactory)
          Sets the dock factory that creates the split child docks for this dock.
 void setDividerLocation(int dividerLocation)
          Sets the divider location of the split pane, if there is a split pane in the dock.
 void setParentDock(CompositeDock parentDock)
          Sets the specified dock as new parent dock of this dock.
 void setRemoveLastEmptyChild(boolean removeLasTemptyChild)
          Sets if the last child dock that is empty, has to be removed.
 void setSingleChildDock(Dock dock)
          Sets the given dock as single child dock of this dock.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SplitDock

public SplitDock()
Constructs a split dock with a LeafDockFactory as child dock factory and a SplitDockFactory as factory for the composite child docks.


SplitDock

public SplitDock(DockFactory childDockFactory)
Constructs a split dock with the given child dock factory.

Parameters:
childDockFactory - The factory for creating child docks.

SplitDock

public SplitDock(DockFactory childDockFactory,
                 CompositeDockFactory splitChildDockFactory)
Constructs a split dock with the given child dock factories.

Parameters:
childDockFactory - The factory for creating child docks.
splitChildDockFactory - The factory for creating composite child docks.
Method Detail

getDockPriority

public int getDockPriority(Dockable dockable,
                           java.awt.Point relativeLocation)

Determines if the dockable can be added.

The dockable can be added, if:

There are also some optimizations done. We want to prevent that dockables are removed from this dock and added to this dock again at the same position. In that case Priority.CANNOT_DOCK is returned.

Specified by:
getDockPriority in interface Dock
Parameters:
dockable - The dockable that will be added.
relativeLocation - The location where the dockable will be added.
Returns:
The integer that determines the priority for adding the dockable. If the dockable cannot be added, CANNOT_DOCK is returned. The higher the integer, the higher the priority for docking the dockable in this dock.

retrieveDockingRectangle

public int retrieveDockingRectangle(Dockable dockable,
                                    java.awt.Point relativeLocation,
                                    java.awt.Point dockableOffset,
                                    java.awt.Rectangle rectangle)
Description copied from interface: Dock

Sets the given rectangle to the position and size of the graphical content component of the dockable, when it will be docked in this dock.

Determines if the dockable can be added to this dock. If the dockable cannot be added, it returns Priority.CANNOT_DOCK and the given rectangle is not changed.

Specified by:
retrieveDockingRectangle in interface Dock
Parameters:
dockable - The dockable that will be added.
relativeLocation - The location where the dockable will be added.
dockableOffset - The mouse location where the dragging started, relatively to the previous dock of the dockable.
rectangle - This rectangle will be set to the location and size of the graphical component of the dockable when it will be docked in this dock. The rectangle is relative to this dock.
Returns:
If the dockable cannot be added, Priority.CANNOT_DOCK is returned, otherwise a positive integer.

addDockable

public boolean addDockable(Dockable dockableToAdd,
                           java.awt.Point relativeLocation,
                           java.awt.Point dockableOffset)
Description copied from interface: Dock

Adds a dockable to this dock.

First it determines if the dockable can be added with Dock.getDockPriority(Dockable, Point). If this method returns CANNOT_DOCK, the dockable is not added.

Specified by:
addDockable in interface Dock
Parameters:
dockableToAdd - The dockable that will be added.
relativeLocation - The location where the dockable will be added.
dockableOffset - The mouse location where the dragging started, relatively to the previous dock of the dockable.
Returns:
True if the dockable was added to this dock, false otherwise.

isEmpty

public boolean isEmpty()
Description copied from interface: Dock
Determines if this dock doesn't have any dockables docked in it, or doesn't have any child docks docked in it.

Specified by:
isEmpty in interface Dock
Returns:
True if this dock doesn't have any dockables docked in it, or doesn't have any child docks docked in it, false otherwise.

isFull

public boolean isFull()
Description copied from interface: Dock
Determines if any more dockables can be added to this dock.

Specified by:
isFull in interface Dock
Returns:
True if any more dockables can be added to this dock, false otherwise.

getParentDock

public CompositeDock getParentDock()
Description copied from interface: Dock
Gets the parent dock of this dock.

Specified by:
getParentDock in interface Dock
Returns:
The parent dock of this dock.

setParentDock

public void setParentDock(CompositeDock parentDock)
Description copied from interface: Dock
Sets the specified dock as new parent dock of this dock.

Specified by:
setParentDock in interface Dock
Parameters:
parentDock - The parent dock of this dock.

saveProperties

public void saveProperties(java.lang.String prefix,
                           java.util.Properties properties,
                           java.util.Map childDockIds)
Description copied from interface: Dock

Saves the properties of this dock in the given properties object.

The property names for this dock should start with the given prefix.

Specified by:
saveProperties in interface Dock
Parameters:
prefix - The prefix for the property names.
properties - The properties object to which the properties should be added.
childDockIds - A mapping between the child docks that are already saved and the keys that are used for the save.
  • map key: a child dock that is already saved (Dock).
  • map value: the key that is used for saving the dock (java.lang.String).

loadProperties

public void loadProperties(java.lang.String prefix,
                           java.util.Properties properties,
                           java.util.Map childDocks,
                           java.util.Map dockablesMap,
                           java.awt.Window owner)
                    throws java.io.IOException
Description copied from interface: Dock

Loads the properties for this dock. The properties can be found in the given properties object. The property names for this dock start with the given prefix.

The dockables that should be docked in this dock are added to this dock. They can be found in the given dockables mapping. The docks that should be docked inside this dock are added to this dock. They can be found in the given childDocks mapping.

This method should be called after the empty constructor to create the content of the dock. Don't call this method for a dock that already has a content.

Specified by:
loadProperties in interface Dock
Parameters:
prefix - The prefix of the names of the properties that have been intended for this dock.
properties - The properties object that contains the properties for this dock. It can contain also properties for other objects, but they will have another prefix.
childDocks - A mapping between the dock keys of the child docks that are already loaded and the docks.
  • map key: the key that is used for saving the dock (java.lang.String).
  • map value: a child dock that is already loaded (Dock).
dockablesMap - A mapping that contains the available dockables.
  • map key: the ID of the dockable (java.lang.String).
  • map value: the dockable (Dockable).
owner - The owner window of the dock in the dock model (DockModel).
Throws:
java.io.IOException - If an error occures while decoding the properties.

addDockingListener

public void addDockingListener(DockingListener listener)
Description copied from interface: Dock
Adds a listener for DockingEvents of this dock. The listener will be informed before and after adding, moving or removing dockables or child docks from this dock.

Specified by:
addDockingListener in interface Dock
Parameters:
listener - A docking listener that will be notified when a dockable or child dock is added, moved, or removed.

removeDockingListener

public void removeDockingListener(DockingListener listener)
Description copied from interface: Dock
Removes a listener for docking events of this dock.

Specified by:
removeDockingListener in interface Dock
Parameters:
listener - The docking listener to remove.

getChildDockCount

public int getChildDockCount()
Description copied from interface: CompositeDock
Gets the number of child docks of this dock.

Specified by:
getChildDockCount in interface CompositeDock
Returns:
The number of child docks of this dock.

getChildDock

public Dock getChildDock(int index)
                  throws java.lang.IndexOutOfBoundsException
Description copied from interface: CompositeDock
Gets the child dock with the specified index.

Specified by:
getChildDock in interface CompositeDock
Parameters:
index - The index of the child dock.
Returns:
The child dock with the specified index.
Throws:
java.lang.IndexOutOfBoundsException - If the index is out of range (index < 0 || index >= getChildDockCount()).

getChildDockPosition

public Position getChildDockPosition(Dock childDock)
                              throws java.lang.IllegalArgumentException
Description copied from interface: CompositeDock
Gets the position, where the child dock is docked in this dock.

Specified by:
getChildDockPosition in interface CompositeDock
Parameters:
childDock - The dockable that is docked in this dock.
Returns:
The position where the child dock is docked in this dock. Not null.
Throws:
java.lang.IllegalArgumentException - If the given dock is not docked in this dock.

emptyChild

public void emptyChild(Dock emptyChildDock)
Description copied from interface: CompositeDock
Is called when the specified child dock is empty. Normally this child dock will be removed.

Specified by:
emptyChild in interface CompositeDock
Parameters:
emptyChildDock - The child dock that is empty.

ghostChild

public void ghostChild(Dock childDock)
Description copied from interface: CompositeDock
Makes the given empty child dock invisible. It may not be removed, because there are still listeners attached to the child dock, that are currently dragging the dockable. The dock is becoming a ghost. It is still there, but it is invisible.

Specified by:
ghostChild in interface CompositeDock
Parameters:
childDock - The child dock that is empty, but not may be removed.

clearGhosts

public void clearGhosts()
Description copied from interface: CompositeDock
Clears the ghost child docks from this dock. The ghost child docks are removed.

Specified by:
clearGhosts in interface CompositeDock

addChildDock

public void addChildDock(Dock dockToAdd,
                         Position position)
                  throws java.lang.IllegalStateException
Description copied from interface: CompositeDock

Adds the given dock as child dock at the given position.

If there is already a dock at the given position, the child is added at the first free position. If the given position is illegal, then the dock is added at the first free position.

Specified by:
addChildDock in interface CompositeDock
Parameters:
dockToAdd - The new child dock for this dock.
position - The position for the child dock.
Throws:
java.lang.IllegalStateException - If the dock is full.

getChildDockFactory

public DockFactory getChildDockFactory()
Gets the dock factory that creates the leaf child docks (LeafDock) for this dock.

Specified by:
getChildDockFactory in interface CompositeDock
Returns:
The dock factory that creates the leaf child docks for this dock.

setChildDockFactory

public void setChildDockFactory(DockFactory childDockFactory)
Sets the dock factory that creates the leaf child docks (LeafDock) for this dock.

Specified by:
setChildDockFactory in interface CompositeDock
Parameters:
childDockFactory - The dock factory that creates the leaf child docks for this dock.
Throws:
java.lang.IllegalArgumentException - When the child dock factory is null.

isRemoveLastEmptyChild

public boolean isRemoveLastEmptyChild()
Determines if the last child dock that is empty, has to be removed.

Returns:
True when the last child dock that is empty, has to be removed.

setRemoveLastEmptyChild

public void setRemoveLastEmptyChild(boolean removeLasTemptyChild)
Sets if the last child dock that is empty, has to be removed.

Parameters:
removeLasTemptyChild - True when the last child dock that is empty, has to be removed.

getCompositeChildDockFactory

public CompositeDockFactory getCompositeChildDockFactory()
Gets the dock factory that creates the split child docks for this dock. This dock factory should create a SplitDock when it is used with the modes DockingMode.LEFT, DockingMode.RIGHT, DockingMode.TOP or DockingMode.BOTTOM.

Returns:
The dock factory that creates the split child docks for this dock.

setCompositeChildDockFactory

public void setCompositeChildDockFactory(CompositeDockFactory splitDockFactory)
Sets the dock factory that creates the split child docks for this dock.

Parameters:
splitDockFactory - The dock factory that creates the split child docks for this dock.
Throws:
java.lang.IllegalArgumentException - When the child dock factory is null.

setDividerLocation

public void setDividerLocation(int dividerLocation)
Sets the divider location of the split pane, if there is a split pane in the dock.

Parameters:
dividerLocation - the divider location of the split pane.

getDividerLocation

public int getDividerLocation()
Gets the divider location of the split pane. If there is no split pane in the dock, 0 is returned.

Returns:
The divider location of the split pane.

setSingleChildDock

public void setSingleChildDock(Dock dock)
Sets the given dock as single child dock of this dock. This may only be called when this dock is empty.

Parameters:
dock - The single child dock for this dock.
Throws:
java.lang.IllegalStateException - If this dock is not empty.

getPriorityRectangle

protected void getPriorityRectangle(java.awt.Rectangle rectangle,
                                    int position)

Gets the relative rectangle in this dock in which docking has priority. The given rectangle gets the size and position of this priority rectangle.

For the positions Position.LEFT, Position.RIGHT, Position.TOP, and Position.BOTTOM the rectangle is at the correspondent border of this dock.

Parameters:
rectangle - Gets the size and position of the calculated priority rectangle.
position - The position of the priority rectangle. There are 5 possibilities:

canAddDockableWithPriority

protected boolean canAddDockableWithPriority(Dockable dockable,
                                             java.awt.Point relativeLocation)
Determines if the given dockable can be added to this dock with priority.

Parameters:
dockable - The dockable that may be added to this dock.
relativeLocation - The location of the mouse relative to this dock.
Returns:
True if the given dockable can be added to this dock with priority, false otherwise.

getDockPosition

protected int getDockPosition(java.awt.Point relativeLocation,
                              Dockable newDockable)

Gets the position where the dockable should be docked in the dock given the mouse position.

There are 5 possible return values:

Parameters:
relativeLocation - The mouse location, where the dockable will be added.
Returns:
The position where the dockable should be docked in the dock.

getChildDockWidth

protected int getChildDockWidth(int preferredWidth,
                                int existingPreferredWidth,
                                int totalWidth,
                                int position)
Computes the width for a component that will be added. There is already one component. The total width has to be shared by the 2 components.

Parameters:
preferredWidth - The preferred width or height of the component that will be added.
existingPreferredWidth - The preferred width or height of the existing component.
totalWidth - The total width or height that is available.
position - The position where the new component will come. This can be Position.LEFT,Position.RIGHT, Position.TOP or Position.BOTTOM.
Returns:
The new width for the component that will be added.