SwingFX v1.0

net.java.swingfx.jdraggable
Class DefaultDraggableManager

java.lang.Object
  extended bynet.java.swingfx.jdraggable.DefaultDraggableManager
All Implemented Interfaces:
ContainerListener, DraggableManager, EventListener

public class DefaultDraggableManager
extends Object
implements DraggableManager

A default implementation of the DraggableManager interface. This implementation provides the basic functionality to enable Component 's which implement the Draggable interface to actually be dragged when a user selects and drags a component. Depending on the DragPolicy that is set, not all components must implement the Draggable interface. This implementation only supports one component to be dragged at a time.

Another idea for an implementation of DraggableManager is one which registers a JLayeredPane as the "Draggable Container" such that when a component is dragged, it's depth (or Z-Order) within the "Draggable Container" is changed such that it is on top of the other components.

Since:
v0.1
$Header: /cvs/swingfx/docs/api/net/java/swingfx/jdraggable/DefaultDraggableManager.html,v 1.1 2005/06/23 00:24:38 codecraig Exp $
Author:
craig

Field Summary
 
Fields inherited from interface net.java.swingfx.jdraggable.DraggableManager
STATE_DRAGGING, STATE_STILL, STATE_UNKNOWN
 
Constructor Summary
DefaultDraggableManager()
          Creates a new DraggableManager with no "Draggable Container" registered
DefaultDraggableManager(Container draggableContainer)
          Creates a new DraggableManager and registers draggableContainer as the "Draggable Container"
 
Method Summary
 void componentAdded(ContainerEvent e)
           
 void componentRemoved(ContainerEvent e)
           
 boolean dragging()
          Called while the Component is being dragged
 Container getDraggableContainer()
          Returns the Container which registered itself as the "Draggable Container" with this DraggableManager
 DragPolicy getDragPolicy()
          Returns the DragPolicy which this manager obides by
 byte getState(Draggable draggableComponent)
          Returns the state of the current Draggable component which this manager is handling
 void registerDraggableContainer(Container draggableContainer)
          Registers the given Container as the "Draggable Container"
 void setDragPolicy(DragPolicy dragPolicy)
          Set the policy for which components are eligible for dragging
 void setNullifyLayout(boolean nullifyLayout)
          Sets whether the "draggable container" layout manager should be set to null once a component is dragged, or not.
 boolean shouldNullifyLayout()
          Returns the "nullify layout" value
 boolean startDrag(Component componentToDrag)
          Called before a Component is actually dragged
 boolean stopDrag()
          Called when a Component has stopped being dragged
 void unregisterDraggableContainer(Container draggableContainer)
          Un-Registers the given Container from being the "Draggable Container"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDraggableManager

public DefaultDraggableManager()
Creates a new DraggableManager with no "Draggable Container" registered

See Also:
DefaultDraggableManager(Container), registerDraggableContainer(Container)

DefaultDraggableManager

public DefaultDraggableManager(Container draggableContainer)
Creates a new DraggableManager and registers draggableContainer as the "Draggable Container"

Parameters:
draggableContainer - the "Draggable Container" to register
Throws:
IllegalArgumentException - if draggableContainer is null
See Also:
DefaultDraggableManager(), registerDraggableContainer(Container)
Method Detail

setNullifyLayout

public void setNullifyLayout(boolean nullifyLayout)
Description copied from interface: DraggableManager
Sets whether the "draggable container" layout manager should be set to null once a component is dragged, or not.
By not setting the layout manager to null, the components may lose their "dragged" position if the container is resized.
By default this value is true

Specified by:
setNullifyLayout in interface DraggableManager
Parameters:
nullifyLayout - true to nullify the layout manager, false otherwise

shouldNullifyLayout

public boolean shouldNullifyLayout()
Description copied from interface: DraggableManager
Returns the "nullify layout" value

Specified by:
shouldNullifyLayout in interface DraggableManager
Returns:
true to nullify the layout manager of the "draggable container", false otherwise

startDrag

public boolean startDrag(Component componentToDrag)
Description copied from interface: DraggableManager
Called before a Component is actually dragged

Specified by:
startDrag in interface DraggableManager
Parameters:
componentToDrag - the component which was chosen to be dragged
Returns:
true if the "drag" can continue, false otherwise

dragging

public boolean dragging()
Description copied from interface: DraggableManager
Called while the Component is being dragged

Specified by:
dragging in interface DraggableManager
Returns:
true if the dragging can continue, false otherwise

stopDrag

public boolean stopDrag()
Description copied from interface: DraggableManager
Called when a Component has stopped being dragged

Specified by:
stopDrag in interface DraggableManager
Returns:
true if no errors occurred when the drag completed, false otherwise

getDraggableContainer

public Container getDraggableContainer()
Returns the Container which registered itself as the "Draggable Container" with this DraggableManager

Specified by:
getDraggableContainer in interface DraggableManager
Returns:
the "Draggable Container" or null if not Container has been registered as the "Draggable Container"

getState

public byte getState(Draggable draggableComponent)
Returns the state of the current Draggable component which this manager is handling

Specified by:
getState in interface DraggableManager
Parameters:
draggableComponent - the Draggable whose state is of interest
Returns:
the state of the current Draggable component
See Also:
DraggableManager.getState(net.java.swingfx.jdraggable.Draggable)

registerDraggableContainer

public void registerDraggableContainer(Container draggableContainer)
Registers the given Container as the "Draggable Container"

Specified by:
registerDraggableContainer in interface DraggableManager
Parameters:
draggableContainer - the Container whose Draggable components should be able to be dragged
Throws:
IllegalArgumentException - if a Container has already been registered
See Also:
DraggableManager.registerDraggableContainer(java.awt.Container)

unregisterDraggableContainer

public void unregisterDraggableContainer(Container draggableContainer)
Un-Registers the given Container from being the "Draggable Container"

Specified by:
unregisterDraggableContainer in interface DraggableManager
Parameters:
draggableContainer - the Container to unregister
Throws:
IllegalArgumentException - if the given container is not the same as the already registered container
IllegalStateException - if no container is currently registered
See Also:
DraggableManager.unregisterDraggableContainer(Container)

getDragPolicy

public DragPolicy getDragPolicy()
Returns the DragPolicy which this manager obides by

Specified by:
getDragPolicy in interface DraggableManager
Returns:
the DragPolicy for this manager. If no policy has been set the default policy is used.
See Also:
DraggableManager.getDragPolicy(), setDragPolicy(DragPolicy), DragPolicy.DEFAULT

setDragPolicy

public void setDragPolicy(DragPolicy dragPolicy)
Description copied from interface: DraggableManager
Set the policy for which components are eligible for dragging

Specified by:
setDragPolicy in interface DraggableManager
Parameters:
dragPolicy - the policy to set
See Also:
DraggableManager.getDragPolicy(), DragPolicy

componentAdded

public void componentAdded(ContainerEvent e)
Specified by:
componentAdded in interface ContainerListener

componentRemoved

public void componentRemoved(ContainerEvent e)
Specified by:
componentRemoved in interface ContainerListener

SwingFX v1.0

SwingFX

Copyright 2005 Romain Guy and Craig Wickesser
All Rights Reserved.