## com.bbn.openmap.tools.dnd
Class DefaultDnDCatcher

    java.lang.Object
      java.awt.dnd.DragGestureRecognizer
          java.awt.dnd.MouseDragGestureRecognizer
              com.bbn.openmap.tools.dnd.DnDListener
                  com.bbn.openmap.tools.dnd.DefaultDnDCatcher

All Implemented Interfaces:
  java.awt.event.ActionListener, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.awt.dnd.DragSourceListener, java.awt.dnd.DropTargetListener, java.util.EventListener, LayerListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, ProjectionListener, java.beans.PropertyChangeListener, java.io.Serializable

Direct Known Subclasses:
  BeanBoxDnDCatcher

public class DefaultDnDCatcher
extends DnDListener
implements java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.beans.PropertyChangeListener, java.io.Serializable, ProjectionListener, LayerListener, java.awt.event.ActionListener

DefaultDnDCatcher manages Drag and Drop events on the map. Drag: When a mouseDragged event occurs, DropListenerSupport forwards it to the DefaultDnDCatcher (consume() method). If it's the first mouseDragged event, dragGestureRecognized is fired and drag starts. Drop: Each layer in the LayerHandler listens to the drop events. When a drop occurs, a list of potential targets (layers) is shown in the popup menu. DefaultDnDCatcher recognizes Location as the droppable object. DefaultDnDCatcher recognizes OMGraphicHandlerLayer layers as potential drop targets.

See Also:
  Serialized Form

Field Summary
`protected java.beans.beancontext.BeanContextChildSupport` `beanContextChildSupport` BeanContextChildSupport object provides helper functions for BeanContextChild interface.
`protected java.awt.dnd.DragSource` `dragSource`
`protected java.awt.Point` `dropLocation`
`protected java.util.Hashtable` `layers` Hashtable for keeping references to potential drop targets
`protected MouseDelegator` `md`
`protected java.beans.PropertyChangeSupport` `pcSupport` PropertyChangeSupport for handling listeners.
`protected Projection` `proj`
`protected java.lang.Object` `transferData`

Fields inherited from class com.bbn.openmap.tools.dnd.DnDListener
`default_action, startDrag`

Fields inherited from class java.awt.dnd.DragGestureRecognizer
`component, dragGestureListener, events, sourceActions`

Constructor Summary
`DefaultDnDCatcher()` Constructs a new DefaultDnDCatcher.
`DefaultDnDCatcher(java.awt.dnd.DragSource ds)` Constructs a new DefaultDnDCatcher given the DragSource for the Component.
`DefaultDnDCatcher(java.awt.dnd.DragSource ds, java.awt.Component c)` Construct a new DefaultDnDCatcher given the DragSource for the Component c, and the Component to observe.
`DefaultDnDCatcher(java.awt.dnd.DragSource ds, java.awt.Component c, int act)`
`DefaultDnDCatcher(java.awt.dnd.DragSource ds, java.awt.Component c, int act, java.awt.dnd.DragGestureListener dgl)`

Method Summary
`void` `actionPerformed(java.awt.event.ActionEvent e)` Invoked when an action from the popup menu occurs.
`void` `addPropertyChangeListener(java.beans.PropertyChangeListener listener)`
`void` `addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener in_pcl)` Method for BeanContextChild interface.
`void` `addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener in_vcl)` Method for BeanContextChild interface.
`void` `childrenAdded(java.beans.beancontext.BeanContextMembershipEvent bcme)` BeanContextMembershipListener method.
`void` `childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)` BeanContextMembershipListener method.
`boolean` `consume(java.awt.event.MouseEvent e)` The method is invoked on mousePressed, mouseReleased, and mouseDragged events that come from the MapBean through DropListenerSupport.
`void` `drop(java.awt.dnd.DropTargetDropEvent dtde)` The drag operation has terminated with a drop on this `DropTarget`.
`void` `findAndInit(java.util.Iterator it)` Eventually gets called when the DefaultDnDCatcher is added to the BeanContext, and when other objects are added to the BeanContext anytime after that.
`void` `findAndInit(java.lang.Object someObj)` Called when an object should be evaluated by the DefaultDnDCatcher to see if it is needed.
`void` `findAndUndo(java.lang.Object someObj)` Called by childrenRemoved.
`void` `firePropertyChange(java.lang.String property, java.lang.Object oldObj, java.lang.Object newObj)`
`void` `fireVetoableChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)` Report a vetoable property update to any registered listeners.
`java.beans.beancontext.BeanContext` `getBeanContext()`
`Projection` `getProjection()` Gets current projection.
`void` `mouseDragged(java.awt.event.MouseEvent e)` The mouseDragged event gets interpreted as DragGestureRecognized when startDrag boolean is true.
`void` `mouseReleased(java.awt.event.MouseEvent e)` On mouseReleased, set startDrag to true in order to enable dragging.
`void` `projectionChanged(ProjectionEvent e)` Invoked when there has been a fundamental change to the Map.
`void` `propertyChange(java.beans.PropertyChangeEvent evt)` This method gets called when a bound property is changed.
`void` `removePropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)` remove a property change listener to this bean child
`void` `removeVetoableChangeListener(java.lang.String name, java.beans.VetoableChangeListener vcl)` remove a vetoable change listener to this child
`void` `setBeanContext(java.beans.beancontext.BeanContext in_bc)` A change in the value of the nesting BeanContext property of this BeanContextChild may be vetoed by throwing the appropriate exception.
`void` `setLayers(Layer[] allLayers)` DefaultDnDCatcher adds itself to each layer as the DropTargetListener.
`void` `setLayers(LayerEvent evt)` The method is invoked when there is a change in layers property in the LayerHandler.
`void` `setProjection(Projection projection)` Sets the current projection.
`Projection` `setProjection(ProjectionEvent projEvent)` This method lets you take the ProjectionEvent received from the MapBean, and lets you know if you should do something with it.
`void` `startDragAction(java.awt.dnd.DragGestureEvent dge, java.awt.dnd.DragSourceListener dsl)` Invoked on dragGestureRecognized in the ComponentDragGestureListener class.

Methods inherited from class com.bbn.openmap.tools.dnd.DnDListener
`dragDropEnd, dragEnter, dragEnter, dragExit, dragExit, dragOver, dragOver, dropActionChanged, dropActionChanged, getCursor, getDefaultAction, setCursor, setDefaultAction`

Methods inherited from class java.awt.dnd.MouseDragGestureRecognizer
`mouseClicked, mouseEntered, mouseExited, mouseMoved, mousePressed, registerListeners, unregisterListeners`

Methods inherited from class java.awt.dnd.DragGestureRecognizer
`addDragGestureListener, appendEvent, fireDragGestureRecognized, getComponent, getDragSource, getSourceActions, getTriggerEvent, removeDragGestureListener, resetRecognizer, setComponent, setSourceActions`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### pcSupport

    protected java.beans.PropertyChangeSupport pcSupport

  PropertyChangeSupport for handling listeners.

### beanContextChildSupport

    protected java.beans.beancontext.BeanContextChildSupport beanContextChildSupport

  BeanContextChildSupport object provides helper functions for BeanContextChild interface.

### layers

    protected java.util.Hashtable layers

  Hashtable for keeping references to potential drop targets

### dragSource

    protected java.awt.dnd.DragSource dragSource

### md

    protected transient MouseDelegator md

### proj

    protected transient Projection proj

### transferData

    protected java.lang.Object transferData

### dropLocation

    protected java.awt.Point dropLocation

Constructor Detail

### DefaultDnDCatcher

    public DefaultDnDCatcher()

  Constructs a new DefaultDnDCatcher.

### DefaultDnDCatcher

    public DefaultDnDCatcher(java.awt.dnd.DragSource ds)

  Constructs a new DefaultDnDCatcher given the DragSource for the Component.

Parameters:
  `ds` - the DragSource for the Component

### DefaultDnDCatcher

    public DefaultDnDCatcher(java.awt.dnd.DragSource ds,
                             java.awt.Component c)

  Construct a new DefaultDnDCatcher given the DragSource for the Component c, and the Component to observe.

Parameters:
  `ds` - the DragSource for the Component c
  `c` - the Component to observe

### DefaultDnDCatcher

    public DefaultDnDCatcher(java.awt.dnd.DragSource ds,
                             java.awt.Component c,
                             int act)

### DefaultDnDCatcher

    public DefaultDnDCatcher(java.awt.dnd.DragSource ds,
                             java.awt.Component c,
                             int act,
                             java.awt.dnd.DragGestureListener dgl)

Method Detail

### actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent e)

  Invoked when an action from the popup menu occurs.

  Specified by:
    `actionPerformed` in interface `java.awt.event.ActionListener`

### addPropertyChangeListener

    public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

### addPropertyChangeListener

    public void addPropertyChangeListener(java.lang.String propertyName,
                                          java.beans.PropertyChangeListener in_pcl)

  Method for BeanContextChild interface.

  Specified by:
    `addPropertyChangeListener` in interface `java.beans.beancontext.BeanContextChild`

### addVetoableChangeListener

    public void addVetoableChangeListener(java.lang.String propertyName,
                                          java.beans.VetoableChangeListener in_vcl)

  Method for BeanContextChild interface.

  Specified by:
    `addVetoableChangeListener` in interface `java.beans.beancontext.BeanContextChild`

### childrenAdded

    public void childrenAdded(java.beans.beancontext.BeanContextMembershipEvent bcme)

  BeanContextMembershipListener method. Called when new objects are added to the parent BeanContext.

  Specified by:
    `childrenAdded` in interface `java.beans.beancontext.BeanContextMembershipListener`
  Parameters:
    `bcme` - event that contains an iterator that can be used to go through the new objects.

### childrenRemoved

    public void childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)

  BeanContextMembershipListener method. Called when objects have been removed from the parent BeanContext. The DefaultDnDCatcher looks for the MapBean it is managing DnD and MouseEvents for, and any layers that may be removed.

  Specified by:
    `childrenRemoved` in interface `java.beans.beancontext.BeanContextMembershipListener`
  Parameters:
    `bcme` - event that contains an iterator that can be used to go through the removed objects.

### consume

    public boolean consume(java.awt.event.MouseEvent e)

  The method is invoked on mousePressed, mouseReleased, and mouseDragged events that come from the MapBean through DropListenerSupport.

  Parameters:
    `e` - java.awt.event.MouseEvent
  Returns:
    boolean

### drop

    public void drop(java.awt.dnd.DropTargetDropEvent dtde)

  The drag operation has terminated with a drop on this `DropTarget`. This method is responsible for undertaking the transfer of the data associated with the gesture. The `DropTargetDropEvent` provides a means to obtain a `Transferable` object that represents the data object(s) to be transfered.

  From this method, the `DropTargetListener` shall accept or reject the drop via the acceptDrop(int dropAction) or rejectDrop() methods of the `DropTargetDropEvent` parameter.

  Subsequent to acceptDrop(), but not before, `DropTargetDropEvent`'s getTransferable() method may be invoked, and data transfer may be performed via the returned `Transferable`'s getTransferData() method.

  At the completion of a drop, an implementation of this method is required to signal the success/failure of the drop by passing an appropriate `boolean` to the `DropTargetDropEvent`'s dropComplete(boolean success) method.

  Note: The actual processing of the data transfer is not required to finish before this method returns. It may be deferred until later.

  Specified by:
    `drop` in interface `java.awt.dnd.DropTargetListener`
  Overrides:
    `drop` in class `DnDListener`
  Parameters:
    `dtde` - the `DropTargetDropEvent`

### findAndInit

    public void findAndInit(java.lang.Object someObj)

  Called when an object should be evaluated by the DefaultDnDCatcher to see if it is needed.

### findAndInit

    public void findAndInit(java.util.Iterator it)

  Eventually gets called when the DefaultDnDCatcher is added to the BeanContext, and when other objects are added to the BeanContext anytime after that. The DefaultDnDCatcher looks for LayerHandler to get OMGraphicHandlerLayer layers to manage Drag and Drop events for. If a MapBean is added to the BeanContext while another already is in use, the second MapBean will take the place of the first.

  Parameters:
    `it` - iterator to use to go through the new objects in the BeanContext.

### findAndUndo

    public void findAndUndo(java.lang.Object someObj)

  Called by childrenRemoved.

### firePropertyChange

    public void firePropertyChange(java.lang.String property,
                                   java.lang.Object oldObj,
                                   java.lang.Object newObj)

### fireVetoableChange

    public void fireVetoableChange(java.lang.String name,
                                   java.lang.Object oldValue,
                                   java.lang.Object newValue)
                            throws java.beans.PropertyVetoException

  Report a vetoable property update to any registered listeners. If anyone vetos the change, then fire a new event reverting everyone to the old value and then rethrow the PropertyVetoException.

  No event is fired if old and new are equal and non-null.

  Parameters:
    `name` - The programmatic name of the property that is about to change
    `oldValue` - The old value of the property
    `newValue` - - The new value of the property
  Throws:
    `java.beans.PropertyVetoException` - if the recipient wishes the property change to be rolled back.

### getBeanContext

    public java.beans.beancontext.BeanContext getBeanContext()

  Specified by:
    `getBeanContext` in interface `java.beans.beancontext.BeanContextChild`
  Returns:
    the current BeanContext associated with the JavaBean

### getProjection

    public Projection getProjection()

  Gets current projection.

### mouseDragged

    public void mouseDragged(java.awt.event.MouseEvent e)

  The mouseDragged event gets interpreted as DragGestureRecognized when startDrag boolean is true. After the first mouseDragged event, set startDrag to false.

  Specified by:
    `mouseDragged` in interface `java.awt.event.MouseMotionListener`

### mouseReleased

    public void mouseReleased(java.awt.event.MouseEvent e)

  On mouseReleased, set startDrag to true in order to enable dragging.

  Specified by:
    `mouseReleased` in interface `java.awt.event.MouseListener`

### projectionChanged

    public void projectionChanged(ProjectionEvent e)

  Invoked when there has been a fundamental change to the Map.

  Layers are expected to recompute their graphics (if this makes sense), and then `repaint()` themselves.

  Specified by:
    `projectionChanged` in interface `ProjectionListener`
  Parameters:
    `e` - ProjectionEvent

### propertyChange

    public void propertyChange(java.beans.PropertyChangeEvent evt)

  This method gets called when a bound property is changed.

  Specified by:
    `propertyChange` in interface `java.beans.PropertyChangeListener`
  Parameters:
    `evt` - A PropertyChangeEvent object describing the event source and the property that has changed.

### removePropertyChangeListener

    public void removePropertyChangeListener(java.lang.String name,
                                             java.beans.PropertyChangeListener pcl)

  remove a property change listener to this bean child

  Specified by:
    `removePropertyChangeListener` in interface `java.beans.beancontext.BeanContextChild`

### removeVetoableChangeListener

    public void removeVetoableChangeListener(java.lang.String name,
                                             java.beans.VetoableChangeListener vcl)

  remove a vetoable change listener to this child

  Specified by:
    `removeVetoableChangeListener` in interface `java.beans.beancontext.BeanContextChild`

### setBeanContext

    public void setBeanContext(java.beans.beancontext.BeanContext in_bc)
                        throws java.beans.PropertyVetoException

  A change in the value of the nesting BeanContext property of this BeanContextChild may be vetoed by throwing the appropriate exception.

  Specified by:
    `setBeanContext` in interface `java.beans.beancontext.BeanContextChild`
  Parameters:
    `in_bc` - the new BeanContext for this object
  Throws:
    `java.beans.PropertyVetoException`

### setLayers

    public void setLayers(Layer[] allLayers)

  DefaultDnDCatcher adds itself to each layer as the DropTargetListener. This is needed in order to capture drop events from any layer on the map, and then apply the events to the applicable layers.

### setLayers

    public void setLayers(LayerEvent evt)

  The method is invoked when there is a change in layers property in the LayerHandler.

  Specified by:
    `setLayers` in interface `LayerListener`

### setProjection

    public Projection setProjection(ProjectionEvent projEvent)

  This method lets you take the ProjectionEvent received from the MapBean, and lets you know if you should do something with it. MUST to be called in the projectionChanged() method of your layer, if you want to refer to the projection later. If this methods returns null, you probably just want to call repaint() if your layer.paint() method is ready to paint what it should.

  Parameters:
    `projEvent` - the ProjectionEvent from the ProjectionListener method.
  Returns:
    The new Projection if it is different from the one we already have, null if is the same as the current one.

### setProjection

    public void setProjection(Projection projection)

  Sets the current projection.

### startDragAction

    public void startDragAction(java.awt.dnd.DragGestureEvent dge,
                                java.awt.dnd.DragSourceListener dsl)

  Invoked on dragGestureRecognized in the ComponentDragGestureListener class.

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details