Class EditorDropTarget

  • All Implemented Interfaces:
    java.awt.dnd.DropTargetListener, java.io.Serializable, java.util.EventListener

    public class EditorDropTarget
    extends java.awt.dnd.DropTarget
    This class provides drag-and-drop support. When this drop target receives a transferable object containing a ptolemy object, it creates a new instance of the object, and adds it to the given graph. If the drop location falls on top of an icon associated with an instance of NamedObj, then the object may be deposited inside that instance (so the instance becomes its container). If the object being dropped implements the RelativeLocatable marker interface, then instead of dropping it inside the target object, it is dropped into the container of the target object and assigned a location relative to the target object. If the drop location is not on top of any object, then the object is deposited inside the model associated with the target graph. In any case, if the target container implements the DropListener interface, then it is informed of the drop by calling its dropped() method.

    Sometimes, you will want to disable the feature that a drop onto a NamedObj results in the dropped object being placed inside that NamedObj. To disable this feature, call setDropIntoEnabled() with a false argument.

    Since:
    Ptolemy II 2.0
    Version:
    $Id$
    Author:
    Steve Neuendorffer and Edward A. Lee, Contributor: Michael Shilman and Sven Koehler
    See Also:
    Serialized Form
    Pt.AcceptedRating:
    Red (johnr)
    Pt.ProposedRating:
    Red (eal)
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.awt.dnd.DropTarget

        java.awt.dnd.DropTarget.DropTargetAutoScroller
    • Constructor Summary

      Constructors 
      Constructor Description
      EditorDropTarget()
      Construct a new graph target to operate on the given JGraph.
      EditorDropTarget​(JGraph graph)
      Construct a new graph target to operate on the given JGraph.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void deRegisterAdditionalListener​(java.awt.dnd.DropTargetListener listener)
      Remove an additional listener.
      java.util.Vector<java.awt.dnd.DropTargetListener> getAdditionalListeners()
      Return the Vector of listeners that have been registered.
      boolean isDropIntoEnabled()
      Return true if the feature is enabled that a a drop onto an instance of NamedObj results in that NamedObj containing the dropped object.
      void registerAdditionalListener​(java.awt.dnd.DropTargetListener listener)
      Register additional DropTargetListeners.
      void setDropIntoEnabled​(boolean enabled)
      If the argument is false, then disable the feature that a a drop onto an instance of NamedObj results in that NamedObj containing the dropped object.
      • Methods inherited from class java.awt.dnd.DropTarget

        addDropTargetListener, addNotify, clearAutoscroll, createDropTargetAutoScroller, createDropTargetContext, dragEnter, dragExit, dragOver, drop, dropActionChanged, getComponent, getDefaultActions, getDropTargetContext, getFlavorMap, initializeAutoscrolling, isActive, removeDropTargetListener, removeNotify, setActive, setComponent, setDefaultActions, setFlavorMap, updateAutoscroll
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EditorDropTarget

        public EditorDropTarget()
        Construct a new graph target to operate on the given JGraph.
      • EditorDropTarget

        public EditorDropTarget​(JGraph graph)
        Construct a new graph target to operate on the given JGraph.
        Parameters:
        graph - The diva graph panel.
    • Method Detail

      • deRegisterAdditionalListener

        public void deRegisterAdditionalListener​(java.awt.dnd.DropTargetListener listener)
        Remove an additional listener.
        Parameters:
        listener - The DropTargetListener to be removed.
      • isDropIntoEnabled

        public boolean isDropIntoEnabled()
        Return true if the feature is enabled that a a drop onto an instance of NamedObj results in that NamedObj containing the dropped object. Otherwise, return false.
        Returns:
        True if drop into is enabled.
      • registerAdditionalListener

        public void registerAdditionalListener​(java.awt.dnd.DropTargetListener listener)
        Register additional DropTargetListeners.
        Parameters:
        listener - The DropTargetListener to be added.
      • setDropIntoEnabled

        public void setDropIntoEnabled​(boolean enabled)
        If the argument is false, then disable the feature that a a drop onto an instance of NamedObj results in that NamedObj containing the dropped object. If the argument is true, then reenable the feature. The feature is enabled by default.
        Parameters:
        enabled - False to disable the drop into feature.
      • getAdditionalListeners

        public java.util.Vector<java.awt.dnd.DropTargetListener> getAdditionalListeners()
        Return the Vector of listeners that have been registered.
        Returns:
        The listeners that have been registered with registerAdditionalListener(DropTargetListener).