Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

problem obtaining screen coords from visad coordinates using MouseBehaviour

Given the standard visad 'box' whose lower left has value -1,-1 in the visad coordinate system, and upper right of 1,1, I need to obtain the screen coordinates of the points.

In offscreen mode, this works. The visadCanvasJ2D has an affineTransform which takes account of the (Swing/awt) component's physical width and height, and the MouseBehaviour object on which I call getScreenCoords() uses the canvas's AffineTransform (I have been through the source code).

But in onscreen mode, the canvas has no 'size' when its AffineTransform is built, so width and height default to 1. So then MouseBehaviour's getScreenCoords returns x' = (0.33,0,0.5) y' = (0,-0.33,0.5) which is wrong.

I see that ProjectionControl's setAspect call affects the DisplayRenderer's AffineTransform, but this does appear to update the AT in the canvas, as used by the MouseBehaviour.

So, how do I get screen coords in onscreen mode? I suspect that I am overlooking something very simple here.

My app is actually an offscreen one, but I am intrigued as to how MouseBehaviour.getScreenCoords would/should work in the general case.

Any help appreciated

Stuart Maclean

==============================================================================
To unsubscribe visad, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================


 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690