private float calculateTypeAndScale(){
  movementType=MovingViewAnimator.AUTO_MOVE;
  float scale=1f;
  float scaleByImage=Math.max(imageWidth / canvasWidth,imageHeight / canvasHeight);
  Matrix m=new Matrix();
  if (offsetWidth == 0 && offsetHeight == 0) {
    float sW=canvasWidth / imageWidth;
    float sH=canvasHeight / imageHeight;
    if (sW > sH) {
      scale=Math.min(sW,maxRelativeSize);
      m.setTranslate((canvasWidth - imageWidth * scale) / 2f,0);
      movementType=MovingViewAnimator.VERTICAL_MOVE;
    }
 else     if (sW < sH) {
      scale=Math.min(sH,maxRelativeSize);
      m.setTranslate(0,(canvasHeight - imageHeight * scale) / 2f);
      movementType=MovingViewAnimator.HORIZONTAL_MOVE;
    }
 else {
      scale=Math.max(sW,maxRelativeSize);
      movementType=(scale == sW) ? MovingViewAnimator.NONE_MOVE : MovingViewAnimator.DIAGONAL_MOVE;
    }
  }
 else   if (offsetWidth == 0) {
    scale=canvasWidth / imageWidth;
    movementType=MovingViewAnimator.VERTICAL_MOVE;
  }
 else   if (offsetHeight == 0) {
    scale=canvasHeight / imageHeight;
    movementType=MovingViewAnimator.HORIZONTAL_MOVE;
  }
 else   if (scaleByImage > maxRelativeSize) {
    scale=maxRelativeSize / scaleByImage;
    if (imageWidth * scale < canvasWidth || imageHeight * scale < canvasHeight) {
      scale=Math.max(canvasWidth / imageWidth,canvasHeight / imageHeight);
    }
  }
  m.preScale(scale,scale);
  setImageMatrix(m);
  return scale;
}

private float calculateTypeAndScale ( ) { movementType = MovingViewAnimator . AUTO_MOVE ; float scale = 1f ; float scaleByImage = Math . max ( imageWidth / canvasWidth , imageHeight / canvasHeight ) ; Matrix m = new Matrix ( ) ; if ( offsetWidth == 0 && offsetHeight == 0 ) { float sW = canvasWidth / imageWidth ; float sH = canvasHeight / imageHeight ; if ( sW > sH ) { scale = Math . min ( sW , maxRelativeSize ) ; m . setTranslate ( ( canvasWidth - imageWidth * scale ) / 2f , 0 ) ; movementType = MovingViewAnimator . VERTICAL_MOVE ; } else if ( sW < sH ) { scale = Math . min ( sH , maxRelativeSize ) ; m . setTranslate ( 0 , ( canvasHeight - imageHeight * scale ) / 2f ) ; movementType = MovingViewAnimator . HORIZONTAL_MOVE ; } else { scale = Math . max ( sW , maxRelativeSize ) ; movementType = ( scale == sW ) ? MovingViewAnimator . NONE_MOVE : MovingViewAnimator . DIAGONAL_MOVE ; } } else if ( offsetWidth == 0 ) { scale = canvasWidth / imageWidth ; movementType = MovingViewAnimator . VERTICAL_MOVE ; } else if ( offsetHeight == 0 ) { scale = canvasHeight / imageHeight ; movementType = MovingViewAnimator . HORIZONTAL_MOVE ; } else if ( scaleByImage > maxRelativeSize ) { scale = maxRelativeSize / scaleByImage ; if ( imageWidth * scale < canvasWidth || imageHeight * scale < canvasHeight ) { scale = Math . max ( canvasWidth / imageWidth , canvasHeight / imageHeight ) ; } } m . preScale ( scale , scale ) ; setImageMatrix ( m ) ; return scale ; }
sets the best movement type and scale .
