private float calculateBestStarSize(int width,int height){
  if (maxStarSize != Integer.MAX_VALUE) {
    float desiredTotalWidth=calculateTotalWidth(maxStarSize,numberOfStars,starsSeparation,true);
    float desiredTotalHeight=calculateTotalHeight(maxStarSize,numberOfStars,starsSeparation,true);
    if (desiredTotalWidth >= width || desiredTotalHeight >= height) {
      float sizeBasedOnWidth=(width - getPaddingLeft() - getPaddingRight()- starsSeparation * (numberOfStars - 1)) / numberOfStars;
      float sizeBasedOnHeight=height - getPaddingTop() - getPaddingBottom();
      return Math.min(sizeBasedOnWidth,sizeBasedOnHeight);
    }
 else {
      return maxStarSize;
    }
  }
 else {
    float sizeBasedOnWidth=(width - getPaddingLeft() - getPaddingRight()- starsSeparation * (numberOfStars - 1)) / numberOfStars;
    float sizeBasedOnHeight=height - getPaddingTop() - getPaddingBottom();
    return Math.min(sizeBasedOnWidth,sizeBasedOnHeight);
  }
}

private float calculateBestStarSize ( int width , int height ) { if ( maxStarSize != Integer . MAX_VALUE ) { float desiredTotalWidth = calculateTotalWidth ( maxStarSize , numberOfStars , starsSeparation , true ) ; float desiredTotalHeight = calculateTotalHeight ( maxStarSize , numberOfStars , starsSeparation , true ) ; if ( desiredTotalWidth >= width || desiredTotalHeight >= height ) { float sizeBasedOnWidth = ( width - getPaddingLeft ( ) - getPaddingRight ( ) - starsSeparation * ( numberOfStars - 1 ) ) / numberOfStars ; float sizeBasedOnHeight = height - getPaddingTop ( ) - getPaddingBottom ( ) ; return Math . min ( sizeBasedOnWidth , sizeBasedOnHeight ) ; } else { return maxStarSize ; } } else { float sizeBasedOnWidth = ( width - getPaddingLeft ( ) - getPaddingRight ( ) - starsSeparation * ( numberOfStars - 1 ) ) / numberOfStars ; float sizeBasedOnHeight = height - getPaddingTop ( ) - getPaddingBottom ( ) ; return Math . min ( sizeBasedOnWidth , sizeBasedOnHeight ) ; } }
calculates largest possible star size , based on chosen width and height . if maxstarsize is present , it will be considered and star size will not be greater than this value .
