[kepler-dev] handling layer events

Chad Berkley berkley at nceas.ucsb.edu
Fri Oct 21 11:25:34 PDT 2005


Thanks, Edward.  Worked like a charm.

chad

Edward A. Lee wrote:
> At 03:30 PM 10/18/2005 -0700, Chad Berkley wrote:
> 
>> Hi,
>>
>> I'm trying to enable the canvas to allow a user to drag an actor from
>> the canvas back to the actor library.  I've got the drag n' drop
>> working, except that I can't seem to figure out how to get a
>> reference to the NamedObj that implements the diva Figure on the
>> canvas.  I have a reference to the Figure and also a reference to the
>> root model itself, but how do I get a reference to the NamedObj that
>> the Figure represents?  I'm working within the confines of
>> BasicGraphFrame and the LayerAdapter that is implemented there.  My
>> question is, how do I reconcile a Figure with a NamedObj so that when
>> I drop the actor (or director or whatever) onto the actor library, i
>> can process the actual ptolemy object instead of the diva object?
>>
>> thanks,
>> chad
> 
> 
> The following method in ptolemy.vergil.basic.EditorDropTarget
> illustrates what you need, I think:
> 
>         /** Return the object under the specified point, or null if there
>          *  is none.
>          *  @param point The point in the graph pane.
>          *  @return The object under the specified point, or null if there
>          *   is none or it is not a NamedObj.
>          */
>         private NamedObj _getObjectUnder(Point2D point) {
>             Figure figureUnderMouse = _getFigureUnder(point);
> 
>             if (figureUnderMouse == null) {
>                 return null;
>             }
> 
>             Object objectUnderMouse = ((UserObjectContainer) 
> figureUnderMouse)
>                     .getUserObject();
> 
>             // Object might be a Location, in which case we want its 
> container.
>             if (objectUnderMouse instanceof Location) {
>                 return (NamedObj) ((NamedObj) 
> objectUnderMouse).getContainer();
>             } else if (objectUnderMouse instanceof NamedObj) {
>                 return (NamedObj) objectUnderMouse;
>             }
> 
>             return null;
>         }
> 
> 
>> _______________________________________________
>> Kepler-dev mailing list
>> Kepler-dev at ecoinformatics.org
>> http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev
> 
> 
> ------------
> Edward A. Lee
> Professor, Chair of the EE Division, Associate Chair of EECS
> 231 Cory Hall, UC Berkeley, Berkeley, CA 94720
> phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845
> eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal 
> 
> ---------------------------------------------------------------------------- 
> 
> Posted to the ptolemy-hackers mailing list.  Please send administrative
> mail for this list to: ptolemy-hackers-request at ptolemy.eecs.berkeley.edu
> 


More information about the Kepler-dev mailing list