[kepler-dev] Ptolemy selection event api

Christopher Brooks cxh at eecs.berkeley.edu
Mon Jul 13 20:25:27 PDT 2009



Shawn Bowers wrote:
> Hi Christopher,
> 
> I was wondering if there is a listener api for vergil selection
> events. In particular, for the tagging work we are doing, we would
> like to register for and be notified of selection events on actors,
> ports, the canvas (i.e., a model), channels, etc.
> 
> Any pointers would be great.
> 
> Thanks,
> Shawn

Hi Shawn,

I took a look an to me it looks like the best place to start is
ptolemy.vergil.basic.BasicGraphFrame.createHierarchy(), which
gets the selection and then determines what NamedObjs are associated
and processes them.

Vergil uses Diva for things like Selection, see SelectionInteractor
in
http://ptolemy.berkeley.edu/ptolemyII/ptII7.0/ptII7.0.1/doc/codeDoc/diva/canvas/interactor/package-summary.html

There are some diva tutorials in ptII/diva/canvas/tutorial, I'd probably start
with the DragTutorial.

ptolemy.vergil.basic.BasicGraphFrame implements a number of Listeners.
ptolemy.vergil.basic.ExtendedGraphFrame extends BasicGraphFrame
ptolemy.vergil.actor.ActorGraphFrame extends ExtendedGraphFrame.

ActorGraphFrame has some private classes that extend AbstractAction
that do the real work.

I'm not that up on selection listeners. I'd probably start with
http://www.j2ee.me/docs/books/tutorial/uiswing/events/index.html
Then thing to do would be to figure out how to register your listeners
without writing a class that extends ActorGraphFrame.

If you have a NamedObj, you can get the Effigy by calling
ptolemy.actor.gui.Configuration.findEffigy().  The Effigy should
contain one or more Tableaus, which you can iterate through like
ptolemy.actor.gui.Effigy.showTableau() does.

For each tableau, you can get the JFrame by calling Tableau.getFrame().
Once you have a JFrame, you can add listeners.

The Ptolemy way to do this would be to have an attribute which you could
drag in that would register your listeners for you.  It might also be
possible to piggy back that attribute somewhere so that everything that
was opened would get the listeners added, but I'm not sure about
the details.  Probably the thing to do would be to add an attribute
that would name a class that would be called at some point when the
Effigy is created.  Configuration._openModel() seems like a possible
location.

Bert is working on a Decorator pattern, which might help here.

Sorry about giving a quick brief answer, I did not have anything off
the top of my head and knew that it would be hours before I could
get around to looking at this.

Someone else who has done more UI work probably has a better answer
than mine.

_Christopher


-- 
Christopher Brooks (cxh at eecs berkeley edu) University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841 fax:510.642.2718	      (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 (W-F) 510.655.5480


More information about the Kepler-dev mailing list