private void fitToBounds(boolean center,ScaleAndTranslate scaleAndTranslate){
  if (panLimit == PAN_LIMIT_OUTSIDE && isImageReady()) {
    center=false;
  }
  PointF vTranslate=scaleAndTranslate.translate;
  float scale=limitedScale(scaleAndTranslate.scale);
  float scaleWidth=scale * sWidth();
  float scaleHeight=scale * sHeight();
  if (panLimit == PAN_LIMIT_CENTER && isImageReady()) {
    vTranslate.x=Math.max(vTranslate.x,getWidth() / 2 - scaleWidth);
    vTranslate.y=Math.max(vTranslate.y,getHeight() / 2 - scaleHeight);
  }
 else   if (center) {
    vTranslate.x=Math.max(vTranslate.x,getWidth() - scaleWidth);
    vTranslate.y=Math.max(vTranslate.y,getHeight() - scaleHeight);
  }
 else {
    vTranslate.x=Math.max(vTranslate.x,-scaleWidth);
    vTranslate.y=Math.max(vTranslate.y,-scaleHeight);
  }
  float maxTx;
  float maxTy;
  if (panLimit == PAN_LIMIT_CENTER && isImageReady()) {
    maxTx=Math.max(0,getWidth() / 2);
    maxTy=Math.max(0,getHeight() / 2);
  }
 else   if (center) {
    maxTx=Math.max(0,(getWidth() - scaleWidth) / 2);
    maxTy=Math.max(0,(getHeight() - scaleHeight) / 2);
  }
 else {
    maxTx=Math.max(0,getWidth());
    maxTy=Math.max(0,getHeight());
  }
  vTranslate.x=Math.min(vTranslate.x,maxTx);
  vTranslate.y=Math.min(vTranslate.y,maxTy);
  scaleAndTranslate.scale=scale;
}

private void fitToBounds ( boolean center , ScaleAndTranslate scaleAndTranslate ) { if ( panLimit == PAN_LIMIT_OUTSIDE && isImageReady ( ) ) { center = false ; } PointF vTranslate = scaleAndTranslate . translate ; float scale = limitedScale ( scaleAndTranslate . scale ) ; float scaleWidth = scale * sWidth ( ) ; float scaleHeight = scale * sHeight ( ) ; if ( panLimit == PAN_LIMIT_CENTER && isImageReady ( ) ) { vTranslate . x = Math . max ( vTranslate . x , getWidth ( ) / 2 - scaleWidth ) ; vTranslate . y = Math . max ( vTranslate . y , getHeight ( ) / 2 - scaleHeight ) ; } else if ( center ) { vTranslate . x = Math . max ( vTranslate . x , getWidth ( ) - scaleWidth ) ; vTranslate . y = Math . max ( vTranslate . y , getHeight ( ) - scaleHeight ) ; } else { vTranslate . x = Math . max ( vTranslate . x , - scaleWidth ) ; vTranslate . y = Math . max ( vTranslate . y , - scaleHeight ) ; } float maxTx ; float maxTy ; if ( panLimit == PAN_LIMIT_CENTER && isImageReady ( ) ) { maxTx = Math . max ( 0 , getWidth ( ) / 2 ) ; maxTy = Math . max ( 0 , getHeight ( ) / 2 ) ; } else if ( center ) { maxTx = Math . max ( 0 , ( getWidth ( ) - scaleWidth ) / 2 ) ; maxTy = Math . max ( 0 , ( getHeight ( ) - scaleHeight ) / 2 ) ; } else { maxTx = Math . max ( 0 , getWidth ( ) ) ; maxTy = Math . max ( 0 , getHeight ( ) ) ; } vTranslate . x = Math . min ( vTranslate . x , maxTx ) ; vTranslate . y = Math . min ( vTranslate . y , maxTy ) ; scaleAndTranslate . scale = scale ; }
adjusts hypothetical future scale and translate values to keep scale within the allowed range and the image on screen . minimum scale is set so one dimension fills the view and the image is centered on the other dimension . used to calculate what the target of an animation should be .
