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

how the 'box' can fill the display

Now that I have finally understood the Affine Transform operations applied to the graphics2D object inside VisadCanvasJ2D, I can see that if you do this

w = display's width
h = display's height

ProjectionControl pc = display.getProjectionControl();
double ax, ay;
if(  w > h  ) {
        ax = (float)w / h;
        ay = 1;
        } else {
        ay = (float)h / w;
        ax = 1;
        }
pc.setAspect( new double[] { ax * 0.5/0.33, ay * 0.5/0.33 } );

then the 'box' (display real type values -1 -> 1 ) will fill the display component entirely, at least in the simple cases I have tested. There may well be data-related times when this does not hold.

It appears to work since the idea is to get the final AT scaling and translation both to 0.5 of the width (and height). The translation is already set to 0.5, we just need the scale factor from above, which when concatted to the 0.33 scaling AT in the canvas, results in a scale of 0.5 * width. Then x = -1 in visad coords maps to pixel 0, and 1 maps to display width, so the box fills the display (??)

I thought this worth sharing, as I have seen requests for it in the past on the mailing list

Stuart
        

==============================================================================
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