< prev index next >

src/java.desktop/share/classes/java/awt/font/LineBreakMeasurer.java

Print this page


   1 /*
   2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 496      */
 497     public void insertChar(AttributedCharacterIterator newParagraph,
 498                            int insertPos) {
 499 
 500         measurer.insertChar(newParagraph, insertPos);
 501 
 502         limit = newParagraph.getEndIndex();
 503         pos = start = newParagraph.getBeginIndex();
 504 
 505         charIter.reset(measurer.getChars(), newParagraph.getBeginIndex());
 506         breakIter.setText(charIter);
 507     }
 508 
 509     /**
 510      * Updates this {@code LineBreakMeasurer} after a single
 511      * character is deleted from the text, and sets the current
 512      * position to the beginning of the paragraph.
 513      * @param newParagraph the text after the deletion
 514      * @param deletePos the position in the text at which the character
 515      *    is deleted


 516      * @throws IndexOutOfBoundsException if {@code deletePos} is
 517      *         less than the start of {@code newParagraph} or greater
 518      *         than the end of {@code newParagraph}
 519      * @throws NullPointerException if {@code newParagraph} is
 520      *         {@code null}
 521      * @see #insertChar
 522      */
 523     public void deleteChar(AttributedCharacterIterator newParagraph,
 524                            int deletePos) {
 525 
 526         measurer.deleteChar(newParagraph, deletePos);
 527 
 528         limit = newParagraph.getEndIndex();
 529         pos = start = newParagraph.getBeginIndex();
 530 
 531         charIter.reset(measurer.getChars(), start);
 532         breakIter.setText(charIter);
 533     }
 534 }
   1 /*
   2  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 496      */
 497     public void insertChar(AttributedCharacterIterator newParagraph,
 498                            int insertPos) {
 499 
 500         measurer.insertChar(newParagraph, insertPos);
 501 
 502         limit = newParagraph.getEndIndex();
 503         pos = start = newParagraph.getBeginIndex();
 504 
 505         charIter.reset(measurer.getChars(), newParagraph.getBeginIndex());
 506         breakIter.setText(charIter);
 507     }
 508 
 509     /**
 510      * Updates this {@code LineBreakMeasurer} after a single
 511      * character is deleted from the text, and sets the current
 512      * position to the beginning of the paragraph.
 513      * @param newParagraph the text after the deletion
 514      * @param deletePos the position in the text at which the character
 515      *    is deleted
 516      * @throws IllegalArgumentException if multiple characters are deleted from
 517      *         the text represented by {@code newParagraph}
 518      * @throws IndexOutOfBoundsException if {@code deletePos} is
 519      *         less than the start of {@code newParagraph} or greater
 520      *         than the end of {@code newParagraph}
 521      * @throws NullPointerException if {@code newParagraph} is
 522      *         {@code null}
 523      * @see #insertChar
 524      */
 525     public void deleteChar(AttributedCharacterIterator newParagraph,
 526                            int deletePos) {
 527 
 528         measurer.deleteChar(newParagraph, deletePos);
 529 
 530         limit = newParagraph.getEndIndex();
 531         pos = start = newParagraph.getBeginIndex();
 532 
 533         charIter.reset(measurer.getChars(), start);
 534         breakIter.setText(charIter);
 535     }
 536 }
< prev index next >