From caf053b3ad53e4ce86d07adee6d71ea1ff3e8965 Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Tue, 3 Dec 2024 15:05:13 +0000 Subject: [PATCH] 8337287: Update image in javax.swing.text.Document.insert Reviewed-by: serb, prr, abhiscxk --- .../classes/javax/swing/text/Document.java | 35 ++-- .../swing/text/doc-files/Document-insert.gif | Bin 3747 -> 0 bytes .../swing/text/doc-files/Document-insert.svg | 150 ++++++++++++++++++ 3 files changed, 171 insertions(+), 14 deletions(-) delete mode 100644 src/java.desktop/share/classes/javax/swing/text/doc-files/Document-insert.gif create mode 100644 src/java.desktop/share/classes/javax/swing/text/doc-files/Document-insert.svg diff --git a/src/java.desktop/share/classes/javax/swing/text/Document.java b/src/java.desktop/share/classes/javax/swing/text/Document.java index c9658aa3b21..801d6bcbbc3 100644 --- a/src/java.desktop/share/classes/javax/swing/text/Document.java +++ b/src/java.desktop/share/classes/javax/swing/text/Document.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -471,24 +471,31 @@ public interface Document { public void remove(int offs, int len) throws BadLocationException; /** - * Inserts a string of content. This will cause a DocumentEvent - * of type DocumentEvent.EventType.INSERT to be sent to the - * registered DocumentListeners, unless an exception is thrown. - * The DocumentEvent will be delivered by calling the - * insertUpdate method on the DocumentListener. - * The offset and length of the generated DocumentEvent - * will indicate what change was actually made to the Document. - *

+ * For example, if the document contains the text + * ‘The brown fox’, + * calling {@code insert(4, "quick ", null)} will insert the word + * ‘quick’ and the following space into the text, + * and all the marks at 4 and above will be moved by 6 (the number + * of inserted characters). + *

Diagram shows insertion of 'quick' in 'The quick brown fox' *

- * If the Document structure changed as result of the insertion, - * the details of what Elements were inserted and removed in + * If the {@code Document} structure changed as result of the insertion, + * the details of what {@code Element}s were inserted and removed in * response to the change will also be contained in the generated - * DocumentEvent. It is up to the implementation of a Document + * {@code DocumentEvent}. It is up to the implementation of a {@code Document} * to decide how the structure should change in response to an * insertion. *

- * If the Document supports undo/redo, an UndoableEditEvent will + * If the {@code Document} supports undo/redo, an {@code UndoableEditEvent} will * also be generated. * * @param offset the offset into the document to insert the content >= 0. @@ -496,7 +503,7 @@ public interface Document { * will move. * @param str the string to insert * @param a the attributes to associate with the inserted - * content. This may be null if there are no attributes. + * content. This may be {@code null} if there are no attributes. * @throws BadLocationException the given insert position is not a valid * position within the document * @see javax.swing.event.DocumentEvent diff --git a/src/java.desktop/share/classes/javax/swing/text/doc-files/Document-insert.gif b/src/java.desktop/share/classes/javax/swing/text/doc-files/Document-insert.gif deleted file mode 100644 index 7e943ce77aaf70c2fe0bf2933ddd77c846f857fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3747 zcmbu)i9geg1Hkd`W@C#qQ%KUBxzk*8HYQABlAMJ{B;=8!*(k#>a^E9{Iku%Db01O4 zRj5aigeZp6;d~_f{eFML@AC(|U$2if-U?&r(+pw(ZvlYM=UZA@Mn*=it*xb`q&Pb} z&&jErzN8~^|i2!yt_Hl0rQ^Yd$OZ%3g}{G$MkM(gP4(9zKm6B8p6iSqLDFJHd& z_xJz!@ng?)Pe4>adS$wZsEC`to34p&WKyJ*j8t4+oRXRn))vct%0BOUzG9U!F?#uJxzPtnfIxIZE!%?IELhiGIWju-`dXf- zC@j4Z4u!(+WgY^Q&FKY?Rr#|gY=7VzTAQj#~;01^K%<0>TdUF&3 zuvKs1#X)<{hnCRip^8{61q>A!5No|ut_pNb^ofG%%Ks+x$|h2;QszLdAu-~OnxWbc zzYG^K_hPUCSOF$T!~ahZ7b{y+X6|94LC*t)WQkT~Xu35tzibU(oq5&K@_n`^LHLAy zXY0>}fn0U3kV*4wNUr)mqD`unVpgv53k>Sps1{ zbigOs9RI0;1|V!IV^4ux$Wi|+U+KYfIX0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fI%NEh_!X+lbIyX70cL6i%Z9qz-t|4PJE$(Z zd8O85#^byGJGT95$Nl!zk2=h0p;Nc&m!?-O_^nf$k`sP{(97V)Pfv$^nh zf+lmI{Kj1Y6jl#r2K;nO=w7K8G>0J(V6i^(cWJ5HJkuvX9^z&KeRo|BkXq}fWmCL> zfr)OZfa+N2*R1@LzY(JT{WH;szmUwy7ZH6fmbbq8l64dY6}=yWl zJLx+pituf(De30wzCRhYu%(+fp>{y!Dp~ie2TniT;QXGPpZH@U{uB#z5)0NM-r*U5_mas?{ikn+Yk5QBl@twg7EI>> zOnibcJj(=0Gvnt*`6NdTE>Vw6s^y0pMx9lVpNzuST59PUfe1$2!)j}_2`97@L|nr4 z2ksc}Bv}>38qpFiB#W9yCG-1Fzi*_*5tHT`jT)VdTW}UPs7dNJ=R5;wVHYX=2{Bm5 zq}N*(C65fTW$kF)R-#H4P@0_T*?$_&#ZskiyiqYfYzdNpAcZk$89OOT#5B@{ z%ru(KNp7^v;gXT`H_IslH8 zl~$PYM$cOmyi{d+#?M-iQ;O&x$qc?{N?-%#uH3&F zMe!it4azz%B(RDq``JnvVr{Z~M!U*R5R#REEF@i3GI?h0jJXZF9wqByQ?PUU7%oU@ zE{s`JzEo5GiJ;Q8O+3=pT}6)dCK&@X!m!3y+k)zx-Q1l)^x62lX|V z!#U-!)C!sQ3R&CWhnv?+1uw`ORUUV)R4#T@DXu)yRH-5DsI^;p@CXxKOwe^_LL-?N zX@XHZ^UpZbY{kKR$O&sy_0zG+N{xUgJK3~Xt-P+X4 + + + + + + + + + + + + Before Insert + + + + + + 4 + + After Insert + + + + T + + h + + e + + + + + + + q + + u + + i + + c + + k + + + + + + + b + + r + + o + + w + + n + + + + f + + o + + x + + + + + + 10 + +