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
[EMAIL PROTECTED]
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
[EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal
----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list. Please send administrative
mail for this list to: [EMAIL PROTECTED]