Class EditorDropTargetListener

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

    public class EditorDropTargetListener
    extends java.lang.Object
    implements java.awt.dnd.DropTargetListener
    A drop target listener that provides drag and drop for the Ptolemy editor.

    Derived classes could extend this class to provide a different drag and drop interface.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Sven Koehler, Contributor: Christopher Brooks.
    Pt.AcceptedRating:
    Red (johnr)
    Pt.ProposedRating:
    Red (eal)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected Figure _getFigureUnder​(java.awt.geom.Point2D point)
      Return the figure that is an icon of a NamedObj and is under the specified point, or null if there is none.
      protected NamedObj _getObjectUnder​(java.awt.geom.Point2D point)
      Return the object under the specified point, or null if there is none.
      void dragEnter​(java.awt.dnd.DropTargetDragEvent dropEvent)
      Accept the event if the data is a known key.
      void dragExit​(java.awt.dnd.DropTargetEvent dropEvent)
      Remove any highlighting that might be active.
      void dragOver​(java.awt.dnd.DropTargetDragEvent dropEvent)
      If the location of the event is over an icon for an instance of NamedObj, then highlight that icon.
      void drop​(java.awt.dnd.DropTargetDropEvent dropEvent)
      If the transferable object is recognized as a Ptolemy II object, then use the MoML description of the object to create a new instance of the object at the drop location.
      void dropActionChanged​(java.awt.dnd.DropTargetDragEvent dropEvent)
      Accept the event if the data is a known key.
      void setDropTarget​(EditorDropTarget dropTarget)
      Links this Listener back to the EditorDropTarget it belongs to.
      • Methods inherited from class java.lang.Object

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

      • EditorDropTargetListener

        public EditorDropTargetListener()
    • Method Detail

      • dragEnter

        public void dragEnter​(java.awt.dnd.DropTargetDragEvent dropEvent)
        Accept the event if the data is a known key. This is called while a drag operation is ongoing, when the mouse pointer enters the operable part of the drop site for the DropTarget registered with this listener.
        Specified by:
        dragEnter in interface java.awt.dnd.DropTargetListener
        Parameters:
        dropEvent - The drop event.
      • dragExit

        public void dragExit​(java.awt.dnd.DropTargetEvent dropEvent)
        Remove any highlighting that might be active. This is called while a drag operation is ongoing, when the mouse pointer has exited the operable part of the drop site for the DropTarget registered with this listener.
        Specified by:
        dragExit in interface java.awt.dnd.DropTargetListener
        Parameters:
        dropEvent - The drop event.
      • dragOver

        public void dragOver​(java.awt.dnd.DropTargetDragEvent dropEvent)
        If the location of the event is over an icon for an instance of NamedObj, then highlight that icon. This is called when a drag operation is ongoing, while the mouse pointer is still over the operable part of the drop site for the DropTarget registered with this listener.
        Specified by:
        dragOver in interface java.awt.dnd.DropTargetListener
        Parameters:
        dropEvent - The drop event.
      • drop

        public void drop​(java.awt.dnd.DropTargetDropEvent dropEvent)
        If the transferable object is recognized as a Ptolemy II object, then use the MoML description of the object to create a new instance of the object at the drop location. If the drop location is on top of an icon representing an instance of NamedObj, then make that instance the container of the new object. Otherwise, make the model associated with the graph the container. This is called when the drag operation has terminated with a drop on the operable part of the drop site for the DropTarget registered with this listener.
        Specified by:
        drop in interface java.awt.dnd.DropTargetListener
        Parameters:
        dropEvent - The drop event.
      • dropActionChanged

        public void dropActionChanged​(java.awt.dnd.DropTargetDragEvent dropEvent)
        Accept the event if the data is a known key. This is called if the user has modified the current drop gesture.
        Specified by:
        dropActionChanged in interface java.awt.dnd.DropTargetListener
        Parameters:
        dropEvent - The drop event.
      • setDropTarget

        public void setDropTarget​(EditorDropTarget dropTarget)
        Links this Listener back to the EditorDropTarget it belongs to.
        Parameters:
        dropTarget - The drop target.
      • _getFigureUnder

        protected Figure _getFigureUnder​(java.awt.geom.Point2D point)
        Return the figure that is an icon of a NamedObj and is under the specified point, or null if there is none.
        Parameters:
        point - The point in the graph pane.
        Returns:
        The object under the specified point, or null if there is none or it is not a NamedObj.
      • _getObjectUnder

        protected NamedObj _getObjectUnder​(java.awt.geom.Point2D point)
        Return the object under the specified point, or null if there is none.
        Parameters:
        point - The point in the graph pane.
        Returns:
        The object under the specified point, or null if there is none or it is not a NamedObj.