Program: 17745
Project: 17745
Buggy source:
/** 
 * This is currently the entire contorted calculation of zooms
 */
public int[] calcZoomSettings(Dimension screenSize){
  double screenAR=screenSize.getWidth() / screenSize.getHeight();
  double worldAR=worldRectNetAR_.getWidth() / worldRectNetAR_.getHeight();
  double worldWidthScreenAR;
  double worldHeightScreenAR;
  double zoom;
  if (worldAR > screenAR) {
    worldWidthScreenAR=worldRectNetAR_.getWidth();
    worldHeightScreenAR=worldWidthScreenAR / screenAR;
    zoom=screenSize.getWidth() / worldRectNetAR_.getWidth();
  }
 else {
    worldHeightScreenAR=worldRectNetAR_.getHeight();
    worldWidthScreenAR=worldHeightScreenAR * screenAR;
    zoom=screenSize.getHeight() / worldRectNetAR_.getHeight();
  }
  screenDim_=new Dimension(screenSize);
  bis_=new ImgAndBufPool(50000);
  double worldCenterX=worldRectNetAR_.getCenterX();
  double worldCenterY=worldRectNetAR_.getCenterY();
  double worldULX=worldCenterX - (worldWidthScreenAR / 2.0);
  double worldULY=worldCenterY - (worldHeightScreenAR / 2.0);
  worldRectScreenAR_=new Rectangle2D.Double(worldULX,worldULY,worldWidthScreenAR,worldHeightScreenAR);
  double maxZoom=screenSize.getHeight() / (4.0 * GRID_SIZE);
  double transitionZoom=screenSize.getWidth() / (1.0E4 * GRID_SIZE);
  double lastZoom=zoom;
  ArrayList<Double> zoomList=new ArrayList<Double>();
  ArrayList<Integer> forRet=new ArrayList<Integer>();
  int count=0;
  while ((lastZoom < maxZoom) || (count < 1)) {
    Double zObj=Double.valueOf(lastZoom);
    zoomList.add(zObj);
    if ((lastZoom < transitionZoom) || (count < 2)) {
      Integer index=Integer.valueOf(count);
      zoomMap_.put(zObj,index);
      forRet.add(index);
    }
    count++;
    lastZoom*=2.0;
  }
  bucketRend_.setModelDims(screenDim_,worldRectScreenAR_,bis_);
  int[] zooms=new int[forRet.size()];
  double[] zoomVals=new double[zoomList.size()];
  count=0;
  for (  Integer zo : forRet) {
    zooms[count++]=zo.intValue();
  }
  count=0;
  for (  Double zo : zoomList) {
    zoomVals[count++]=zo.doubleValue();
  }
  zcs_.setZoomPoints(zoomVals);
  return (zooms);
}

Fixed version (ground truth):
/** 
 * This is currently the entire contorted calculation of zooms
 */
public int[] calcZoomSettings(Dimension screenSize){
  double screenAR=screenSize.getWidth() / screenSize.getHeight();
  double worldAR=worldRectNetAR_.getWidth() / worldRectNetAR_.getHeight();
  double worldWidthScreenAR;
  double worldHeightScreenAR;
  double zoom;
  if (worldAR > screenAR) {
    worldWidthScreenAR=worldRectNetAR_.getWidth();
    worldHeightScreenAR=worldWidthScreenAR / screenAR;
    zoom=screenSize.getWidth() / worldRectNetAR_.getWidth();
  }
 else {
    worldHeightScreenAR=worldRectNetAR_.getHeight();
    worldWidthScreenAR=worldHeightScreenAR * screenAR;
    zoom=screenSize.getHeight() / worldRectNetAR_.getHeight();
  }
  screenDim_=new Dimension(screenSize);
  bis_=new ImgAndBufPool(50000);
  double worldCenterX=worldRectNetAR_.getCenterX();
  double worldCenterY=worldRectNetAR_.getCenterY();
  double worldULX=worldCenterX - (worldWidthScreenAR / 2.0);
  double worldULY=worldCenterY - (worldHeightScreenAR / 2.0);
  worldRectScreenAR_=new Rectangle2D.Double(worldULX,worldULY,worldWidthScreenAR,worldHeightScreenAR);
  double maxZoom=screenSize.getHeight() / (4.0 * GRID_SIZE);
  double transitionZoom=screenSize.getWidth() / (1.0E4 * GRID_SIZE);
  double lastZoom=zoom;
  ArrayList<Double> zoomList=new ArrayList<Double>();
  ArrayList<Integer> forRet=new ArrayList<Integer>();
  int count=0;
  while ((lastZoom < maxZoom) || (count < 1)) {
    Double zObj=Double.valueOf(lastZoom);
    zoomList.add(zObj);
    if ((lastZoom < transitionZoom) || (count < 2)) {
      Integer index=Integer.valueOf(count);
      zoomMap_.put(zObj,index);
      forRet.add(index);
    }
    count++;
    lastZoom*=2.0;
  }
  bucketRend_.setModelDims(screenDim_,worldRectScreenAR_,bis_);
  int[] zooms=new int[forRet.size()];
  double[] zoomVals=new double[zoomList.size()];
  count=0;
  for (  Integer zo : forRet) {
    zooms[count++]=zo.intValue();
  }
  count=0;
  for (  Double zo : zoomList) {
    zoomVals[count++]=zo.doubleValue();
  }
  zcs_.setZoomPoints(zoomVals);
  zcs_.setZoomLevels(zooms);
  return (zooms);
}