private double estimateMaximumTickLabelWidth(Graphics2D g2,DateTickUnit unit){
  RectangleInsets tickLabelInsets=getTickLabelInsets();
  double result=tickLabelInsets.getLeft() + tickLabelInsets.getRight();
  Font tickLabelFont=getTickLabelFont();
  FontRenderContext frc=g2.getFontRenderContext();
  LineMetrics lm=tickLabelFont.getLineMetrics("ABCxyz",frc);
  if (isVerticalTickLabels()) {
    result+=lm.getHeight();
  }
 else {
    DateRange range=(DateRange)getRange();
    Date lower=range.getLowerDate();
    Date upper=range.getUpperDate();
    String lowerStr, upperStr;
    DateFormat formatter=getDateFormatOverride();
    if (formatter != null) {
      lowerStr=formatter.format(lower);
      upperStr=formatter.format(upper);
    }
 else {
      lowerStr=unit.dateToString(lower);
      upperStr=unit.dateToString(upper);
    }
    FontMetrics fm=g2.getFontMetrics(tickLabelFont);
    double w1=fm.stringWidth(lowerStr);
    double w2=fm.stringWidth(upperStr);
    result+=Math.max(w1,w2);
  }
  return result;
}

private double estimateMaximumTickLabelWidth ( Graphics2D g2 , DateTickUnit unit ) { RectangleInsets tickLabelInsets = getTickLabelInsets ( ) ; double result = tickLabelInsets . getLeft ( ) + tickLabelInsets . getRight ( ) ; Font tickLabelFont = getTickLabelFont ( ) ; FontRenderContext frc = g2 . getFontRenderContext ( ) ; LineMetrics lm = tickLabelFont . getLineMetrics ( "ABCxyz" , frc ) ; if ( isVerticalTickLabels ( ) ) { result += lm . getHeight ( ) ; } else { DateRange range = ( DateRange ) getRange ( ) ; Date lower = range . getLowerDate ( ) ; Date upper = range . getUpperDate ( ) ; String lowerStr , upperStr ; DateFormat formatter = getDateFormatOverride ( ) ; if ( formatter != null ) { lowerStr = formatter . format ( lower ) ; upperStr = formatter . format ( upper ) ; } else { lowerStr = unit . dateToString ( lower ) ; upperStr = unit . dateToString ( upper ) ; } FontMetrics fm = g2 . getFontMetrics ( tickLabelFont ) ; double w1 = fm . stringWidth ( lowerStr ) ; double w2 = fm . stringWidth ( upperStr ) ; result += Math . max ( w1 , w2 ) ; } return result ; }
estimates the maximum width of the tick labels , assuming the specified tick unit is used . < p > rather than computing the string bounds of every tick on the axis , we just look at two values : the lower bound and the upper bound for the axis . these two values will usually be representative .
