< prev index next >
src/java.desktop/share/classes/java/awt/font/TextMeasurer.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 650,659 ****
--- 650,661 ----
* the insertion. Cannot be null.
* @param insertPos the position in the text where the character was
* inserted. Must not be less than the start of
* {@code newParagraph}, and must be less than the end of
* {@code newParagraph}.
+ * @throws IllegalArgumentException if multiple characters are inserted
+ * in the text represented by {@code newParagraph}
* @throws IndexOutOfBoundsException if {@code insertPos} is less
* than the start of {@code newParagraph} or greater than
* or equal to the end of {@code newParagraph}
* @throws NullPointerException if {@code newParagraph} is
* {@code null}
*** 665,680 ****
}
if (wantStats) {
collectStats = true;
}
! fStart = newParagraph.getBeginIndex();
int end = newParagraph.getEndIndex();
! if (end - fStart != fChars.length+1) {
! initAll(newParagraph);
}
char[] newChars = new char[end-fStart];
int newCharIndex = insertPos - fStart;
System.arraycopy(fChars, 0, newChars, 0, newCharIndex);
char newChar = newParagraph.setIndex(insertPos);
--- 667,685 ----
}
if (wantStats) {
collectStats = true;
}
! int start = newParagraph.getBeginIndex();
int end = newParagraph.getEndIndex();
! if (end - start != fChars.length+1) {
! // The new paragraph attempts to insert multiple characters
! throw new IllegalArgumentException("The new paragraph"
! + " attempts to insert multiple characters into the text.");
}
+ fStart = start;
char[] newChars = new char[end-fStart];
int newCharIndex = insertPos - fStart;
System.arraycopy(fChars, 0, newChars, 0, newCharIndex);
char newChar = newParagraph.setIndex(insertPos);
*** 716,739 ****
* the deletion. Cannot be null.
* @param deletePos the position in the text where the character was removed.
* Must not be less than
* the start of {@code newParagraph}, and must not be greater than the
* end of {@code newParagraph}.
* @throws IndexOutOfBoundsException if {@code deletePos} is
* less than the start of {@code newParagraph} or greater
* than the end of {@code newParagraph}
* @throws NullPointerException if {@code newParagraph} is
* {@code null}
*/
public void deleteChar(AttributedCharacterIterator newParagraph, int deletePos) {
! fStart = newParagraph.getBeginIndex();
int end = newParagraph.getEndIndex();
! if (end - fStart != fChars.length-1) {
! initAll(newParagraph);
}
char[] newChars = new char[end-fStart];
int changedIndex = deletePos-fStart;
System.arraycopy(fChars, 0, newChars, 0, deletePos-fStart);
System.arraycopy(fChars, changedIndex+1, newChars, changedIndex, end-deletePos);
--- 721,749 ----
* the deletion. Cannot be null.
* @param deletePos the position in the text where the character was removed.
* Must not be less than
* the start of {@code newParagraph}, and must not be greater than the
* end of {@code newParagraph}.
+ * @throws IllegalArgumentException if multiple characters are deleted from
+ * the text represented by {@code newParagraph}
* @throws IndexOutOfBoundsException if {@code deletePos} is
* less than the start of {@code newParagraph} or greater
* than the end of {@code newParagraph}
* @throws NullPointerException if {@code newParagraph} is
* {@code null}
*/
public void deleteChar(AttributedCharacterIterator newParagraph, int deletePos) {
! int start = newParagraph.getBeginIndex();
int end = newParagraph.getEndIndex();
! if (end - start != fChars.length-1) {
! // The new paragraph attempts to delete multiple characters
! throw new IllegalArgumentException("The new paragraph"
! + " attempts to delete multiple characters from the text.");
}
+ fStart = start;
char[] newChars = new char[end-fStart];
int changedIndex = deletePos-fStart;
System.arraycopy(fChars, 0, newChars, 0, deletePos-fStart);
System.arraycopy(fChars, changedIndex+1, newChars, changedIndex, end-deletePos);
< prev index next >