if (shape == null) return null;
  protected Shape adjustAllocation(Shape shape)  {    Rectangle rectIn = shape.getBounds();    // vertical adjustment    int height = (int) getPreferredSpan(Y_AXIS);    int y = rectIn.y + (rectIn.height - height) / 2;    // horizontal adjustment    JTextField textField = (JTextField) getContainer();    int width = (int) ((cachedSpan != -1f) ? cachedSpan : calculateHorizontalSpan());    int x;    if (horizontalVisibility != null && horizontalVisibility.getExtent() < width)        x = rectIn.x - horizontalVisibility.getValue();    else      switch (textField.getHorizontalAlignment())      {      case JTextField.CENTER:        x = rectIn.x + (rectIn.width - width) / 2;        break;      case JTextField.RIGHT:          x = rectIn.x + (rectIn.width - width - 1);        break;      case JTextField.TRAILING:          if (textField.getComponentOrientation().isLeftToRight())            x = rectIn.x + (rectIn.width - width - 1);        else          x = rectIn.x;        break;      case JTextField.LEADING:          if (textField.getComponentOrientation().isLeftToRight())          x = rectIn.x;        else            x = rectIn.x + (rectIn.width - width - 1);        break;      case JTextField.LEFT:      default:        x = rectIn.x;        break;      }        return new Rectangle(x, y, width, height);  }