NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi Cristy, > My question is, how can I intercept tab/shift-tab key presses > when the graph has focus so I can in-turn move the green blob? > I tried adding a KeyListener without any luck. I also checked > out the VisAD examples and did not see any that react to key > presses. Yes, we don't have any examples that capture keyboard events for VisAD displays. Also, you cannot use a KeyListener directly with Java3D, since it grabs all the KeyEvents itself. But it will give them back through a Behavior in the Java3D scene graph. Here's how to do it. Define a new class KeyBehaviorJ3D (or whatever name you like) that is similar to visad.java3d.MouseBehaviorJ3D, except that: 1. It extends Behavior but does not implement the MouseEvent interface. 2. It does not construct a MouseHelper or implement the getMouseHelper() method. 3. It defines a different list of conditions in its constructor in 'wakeup', maybe just new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED) 4. In its processStimulus method, it does not pass AWTEvents to MouseHelper.processEvent(), but instead moves your green blob or does whatever else you want. Then in your application, after you have constructed your DisplayImplJ3D, do the following: DisplayImplJ3D display = ...; DisplayRendererJ3D display_renderer (DisplayRendererJ3D) display.getDisplayRenderer(); TransformGroup trans = display_renderer.getTrans(); KeyBehaviorJ3D key = new KeyBehaviorJ3D(display_renderer); BoundingSphere bounds new BoundingSphere(new Point3d(0.0,0.0,0.0), 2000000.0); key.setSchedulingBounds(bounds); trans.addChild(key); I have never used KeyEvents, so may have made some error here, but I think this is the general idea. Please let me know if you have problems. Cheers, Bill ---------------------------------------------------------- Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI 53706 hibbard@xxxxxxxxxxxxxxxxx 608-263-4427 fax: 608-263-6738 http://www.ssec.wisc.edu/~billh/vis.html >From owner-visad@xxxxxxxxxxxxxxxx Wed 8 2004 Dec 10:52:59 Message-ID: <1102503179.41b6dd0b4f4b6@xxxxxxxxxxxxxxxxxxx> Date: Wed, 8 Dec 2004 10:52:59 +0000 From: Adityarajsingh Santokhee <ads@xxxxxxxxxxxxxxxxxxxx> In-Reply-To: <41B60B12.4040500@xxxxxxxx> To: visad-list@xxxxxxxxxxxxx Subject: Re: Example of 2D surface animation Received: (from majordo@localhost) by unidata.ucar.edu (UCAR/Unidata) id iB8ArEm7017209 for visad-out; Wed, 8 Dec 2004 03:53:14 -0700 (MST) Received: from ssec.wisc.edu (mahogany.ssec.wisc.edu [128.104.110.2]) by unidata.ucar.edu (UCAR/Unidata) with ESMTP id iB8ArBlI017204 for <visad-list@xxxxxxxxxxxxxxxx>; Wed, 8 Dec 2004 03:53:11 -0700 (MST) Organization: UCAR/Unidata Keywords: 200412081053.iB8ArBlI017204 Received: from vimg3.rdg.ac.uk ([134.225.1.80] verified) by ssec.wisc.edu (CommuniGate Pro SMTP 4.1.8) with ESMTP id 3367143 for visad-list@xxxxxxxxxxxxx; Wed, 08 Dec 2004 04:53:05 -0600 Received: from vimp2.rdg.ac.uk ([134.225.16.91]) by vimg3.rdg.ac.uk (Exim: gateway) with esmtp id 1CbzRR-0006Sp-00 for visad-list@xxxxxxxxxxxxx; Wed, 08 Dec 2004 10:53:05 +0000 Received: from vimh1.rdg.ac.uk ([134.225.16.83]) by vimp2.rdg.ac.uk (Exim: virusscanner) with esmtp id 1CbzRM-0005cm-00 for visad-list@xxxxxxxxxxxxx; Wed, 08 Dec 2004 10:53:00 +0000 Received: from mercury.nerc-essc.ac.uk ([192.171.166.1]) by vimh1.rdg.ac.uk (Exim: host) with esmtp id 1CbzRM-0002DW-00 for visad-list@xxxxxxxxxxxxx; Wed, 08 Dec 2004 10:53:00 +0000 Received: from sweeney.nerc-essc.ac.uk (sweeney [192.171.166.116]) by mercury.nerc-essc.ac.uk (8.12.10/8.12.10) with ESMTP id iB8Aqx1t011908 for <visad-list@xxxxxxxxxxxxx>; Wed, 8 Dec 2004 10:52:59 GMT Received: from localhost.localdomain (sweeney [127.0.0.1]) by sweeney.nerc-essc.ac.uk (8.12.8/8.12.8) with ESMTP id iB8Aqxml019074 for <visad-list@xxxxxxxxxxxxx>; Wed, 8 Dec 2004 10:52:59 GMT Received: (from apache@localhost) by localhost.localdomain (8.12.8/8.12.8/Submit) id iB8AqxNU019070 for visad-list@xxxxxxxxxxxxx; Wed, 8 Dec 2004 10:52:59 GMT Received: from brahman.nerc-essc.ac.uk (brahman.nerc-essc.ac.uk [192.171.166.139]) by www.nerc-essc.ac.uk (IMP) with HTTP for <ads@xxxxxxxxxxxxxxxxxxxxxxx>; Wed, 8 Dec 2004 10:52:59 +0000 References: <Pine.GSO.4.44.0412071225001.9354-100000@xxxxxxxxxxxxxxxxxxxxxx> <1102445069.41b5fa0d7be49@xxxxxxxxxxxxxxxxxxx> <41B60B12.4040500@xxxxxxxx> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.2 X-Originating-IP: 192.171.166.139 X-Scanner: exiscan *1CbzRM-0005cm-00*v3UPwqD.Pdg* (The University of Reading) Sender: owner-visad@xxxxxxxxxxxxxxxx Precedence: bulk Thanks Curtis, Your program has solved my problem. Regards, Adit. Quoting Curtis Rueden <ctrueden@xxxxxxxx>: > Hi Adit, > > I have posted an example of surface animation as Bill described online at: > http://www.ssec.wisc.edu/~curtis/examples/SurfaceAnimation.java > > Hopefully it will be of some help. > > -Curtis > > Adityarajsingh Santokhee wrote: > > >>You can see temps moving on a constant surface if you use > >>the same values for "z" in all time steps. You can reuse > >>the same float[] array of "z" values in the range float[][] > >>for each time step. > >> > >> > > > > > >I have in fact kept the "z" values constant. What I wanted to say is that > the > >lat-lon surface is actually moving along the longitude axis with each > >timestep. > > > >Maybe I need to change the way I am defining my Math Types/scalar Maps. > > > >Cheers, > >Adit > > > > > > ----------------------------------------------------------------------- Adityarajsingh Santokhee Tel: +44 118 378 5213 (direct line) eScience Data Manager Tel: +44 118 378 8741 (ESSC) Reading e-Science Centre Fax: +44 118 378 6413 ESSC Email: ads@xxxxxxxxxxxxxxxxxxxx University of Reading 3 Earley Gate Reading RG6 6AL, UK ----------------------------------------------------------------------- ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.
visad
archives: