private String generateFittingText(Method method,Rectangle2D rect,FontMetrics fontMetrics){
  if (rect.getWidth() < fontMetrics.stringWidth("...")) {
    return "";
  }
  String fullyQualified=method.getNameSpace() + "." + method.getName();
  if (fontMetrics.stringWidth(fullyQualified) < rect.getWidth()) {
    return fullyQualified;
  }
  String abbrevPackage=getShortPackageName(method.getNameSpace()) + "." + method.getName();
  if (fontMetrics.stringWidth(abbrevPackage) < rect.getWidth()) {
    return abbrevPackage;
  }
  if (fontMetrics.stringWidth(method.getName()) < rect.getWidth()) {
    return method.getName();
  }
  return "";
}

private String generateFittingText ( Method method , Rectangle2D rect , FontMetrics fontMetrics ) { if ( rect . getWidth ( ) < fontMetrics . stringWidth ( "..." ) ) { return "" ; } String fullyQualified = method . getNameSpace ( ) + "." + method . getName ( ) ; if ( fontMetrics . stringWidth ( fullyQualified ) < rect . getWidth ( ) ) { return fullyQualified ; } String abbrevPackage = getShortPackageName ( method . getNameSpace ( ) ) + "." + method . getName ( ) ; if ( fontMetrics . stringWidth ( abbrevPackage ) < rect . getWidth ( ) ) { return abbrevPackage ; } if ( fontMetrics . stringWidth ( method . getName ( ) ) < rect . getWidth ( ) ) { return method . getName ( ) ; } return "" ; }
find the best text for the given rectangle constraints .
