Element element = getCharacterElement(position); return element.getParentElement();
BranchElement root = (BranchElement) getDefaultRootElement(); int start = root.getStartOffset(); int end = root.getEndOffset(); if (position >= end) position = end - 1; else if (position < start) position = start;  Element par = root.positionToElement(position);  assert par != null : "The paragraph element must not be null"; return par;
  public Element getParagraphElement(int position)  {    Element element = getCharacterElement(position);    return element.getParentElement();  }