String text; Element elem = getElement();  try { text = elem.getDocument().getText(elem.getStartOffset(), elem.getEndOffset()); } catch (BadLocationException e) {  AssertionError ae = new AssertionError(); ae.initCause(e); throw ae; }
if (cachedSpan != -1f) return cachedSpan;
  public float getPreferredSpan(int axis)  {    if (axis != X_AXIS && axis != Y_AXIS)      throw new IllegalArgumentException();    FontMetrics fm = getFontMetrics();    if (axis == Y_AXIS)      return super.getPreferredSpan(axis);    String text;    Element elem = getElement();    try      {	text = elem.getDocument().getText(elem.getStartOffset(),					  elem.getEndOffset());      }    catch (BadLocationException e)      {	// Should never happen	AssertionError ae = new AssertionError();	ae.initCause(e);	throw ae;      }        return fm.stringWidth(text);  }