ui/src/main/java/ucar/nc2/ui/geoloc/Navigation.java
public AffineTransform calcTransform(boolean rotate, double displayX, double displayY, double displayWidth, double displayHeight) {
    getMapArea( bb); // current world bounding box
       // scale to limiting dimension
    double pxpsx, pypsy;
    if (rotate) {
      pxpsx = displayHeight/bb.getWidth();
      pypsy = displayWidth/bb.getHeight();
    } else {
      pxpsx = displayWidth/bb.getWidth();
      pypsy = displayHeight/bb.getHeight();
    }
    double pps = Math.min( pxpsx, pypsy);

      // calc offset: based on center point staying in center
    double wx0 = bb.getX() + bb.getWidth()/2;  // world midpoint
    double wy0 = bb.getY() + bb.getHeight()/2;
    double x0 = displayX + displayWidth/2 - pps * wx0;
    double y0 = displayY + displayHeight/2 + pps * wy0;

    AffineTransform cat = new AffineTransform(pps, 0.0, 0.0, -pps, x0, y0);

    // rotate if we need to
    if (rotate)
        cat.rotate(Math.PI/2, wx0, wy0);

    if (debug) {
      System.out.println("Navigation calcTransform = "+ displayX +" "+ displayY+
                " "+ displayWidth+" "+displayHeight);
      System.out.println("  world = "+ bb);
      System.out.println("  scale/origin = "+ pps +" "+ x0+" "+ y0);
      System.out.println("  transform = "+ cat);
    }
    return cat;
  }
public AffineTransform calcTransform(boolean rotate, double displayX, double displayY, double displayWidth, double displayHeight) {
    getMapArea( bb); // current world bounding box
       // scale to limiting dimension
    double pxpsx, pypsy;
    if (rotate) {
      pxpsx = displayHeight/bb.getWidth();
      pypsy = displayWidth/bb.getHeight();
    } else {
      pxpsx = displayWidth/bb.getWidth();
      pypsy = displayHeight/bb.getHeight();
    }
    double pps = Math.min( pxpsx, pypsy);

      // calc offset: based on center point staying in center
    double wx0 = bb.getX() + bb.getWidth()/2;  // world midpoint
    double wy0 = bb.getY() + bb.getHeight()/2;
    double x0 = displayX + displayWidth/2 - pps * wx0;
    double y0 = displayY + displayHeight/2 + pps * wy0;

    AffineTransform cat = new AffineTransform(pps, 0.0, 0.0, -pps, x0, y0);

    // rotate if we need to
    if (rotate)
        cat.rotate(Math.PI/2, wx0, wy0);

    if (debug) {
      System.out.println("Navigation calcTransform = "+ displayX +" "+ displayY+
                " "+ displayWidth+" "+displayHeight);
      System.out.println("  world = "+ bb);
      System.out.println("  scale/origin = "+ pps +" "+ x0+" "+ y0);
      System.out.println("  transform = "+ cat);
    }
    return cat;
  }
Calculate an affine transform based on the display size parameters - used for printing.
@param rotate should the page be rotated?
@param displayX            upper right corner of display area
@param displayY            upper right corner of display area
@param displayWidth   display area
@param displayHeight   display area

see Navigation.calcTransform