protected double estimateMaximumTickLabelWidth(Graphics2D g2, TickUnit unit) { RectangleInsets tickLabelInsets = getTickLabelInsets(); double result = tickLabelInsets.getLeft() + tickLabelInsets.getRight(); if (isVerticalTickLabels()) { FontRenderContext frc = g2.getFontRenderContext(); return result + ((double) getTickLabelFont().getLineMetrics("0", frc).getHeight()); } String lowerStr; String upperStr; FontMetrics fm = g2.getFontMetrics(getTickLabelFont()); Range range = getRange(); double lower = range.getLowerBound(); double upper = range.getUpperBound(); NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { lowerStr = formatter.format(lower); upperStr = formatter.format(upper); } else { lowerStr = unit.valueToString(lower); upperStr = unit.valueToString(upper); } return result + Math.max((double) fm.stringWidth(lowerStr), (double) fm.stringWidth(upperStr)); }