/[classpath]/classpath/javax/swing/text/DefaultStyledDocument.java
ViewVC logotype

Diff of /classpath/javax/swing/text/DefaultStyledDocument.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by rabbit78, Tue Sep 20 08:57:39 2005 UTC revision 1.13 by rabbit78, Tue Sep 20 14:53:47 2005 UTC
# Line 899  public class DefaultStyledDocument exten Line 899  public class DefaultStyledDocument exten
899    
900    /**    /**
901     * Returns the paragraph element for the specified position.     * Returns the paragraph element for the specified position.
902       * If the position is outside the bounds of the document's root element,
903       * then the closest element is returned. That is the last paragraph if
904       * <code>position >= endIndex</code> or the first paragraph if
905       * <code>position < startIndex</code>.
906     *     *
907     * @param position the position for which to query the paragraph element     * @param position the position for which to query the paragraph element
908     *     *
# Line 907  public class DefaultStyledDocument exten Line 911  public class DefaultStyledDocument exten
911    public Element getParagraphElement(int position)    public Element getParagraphElement(int position)
912    {    {
913      BranchElement root = (BranchElement) getDefaultRootElement();      BranchElement root = (BranchElement) getDefaultRootElement();
914        int start = root.getStartOffset();
915        int end = root.getEndOffset();
916        if (position >= end)
917          position = end - 1;
918        else if (position < start)
919          position = start;
920    
921      Element par = root.positionToElement(position);      Element par = root.positionToElement(position);
922    
923        assert par != null : "The paragraph element must not be null";
924      return par;      return par;
925    }    }
926    

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26