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:

  • 2006 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: