@@ -52,11 +52,11 @@ This file is part of the iText (R) project.
52
52
53
53
public class GlyphLine implements Serializable {
54
54
private static final long serialVersionUID = 4689818013371677649L ;
55
- protected List <Glyph > glyphs ;
56
- protected List <ActualText > actualText ;
57
55
public int start ;
58
56
public int end ;
59
57
public int idx ;
58
+ protected List <Glyph > glyphs ;
59
+ protected List <ActualText > actualText ;
60
60
61
61
public GlyphLine () {
62
62
this .glyphs = new ArrayList <>();
@@ -77,8 +77,8 @@ public GlyphLine(List<Glyph> glyphs) {
77
77
* Create a new line of Glyphs from a slice of a List of Glyphs.
78
78
*
79
79
* @param glyphs list of Glyphs to slice
80
- * @param start starting index of the slice
81
- * @param end terminating index of the slice
80
+ * @param start starting index of the slice
81
+ * @param end terminating index of the slice
82
82
*/
83
83
public GlyphLine (List <Glyph > glyphs , int start , int end ) {
84
84
this .glyphs = glyphs ;
@@ -89,10 +89,10 @@ public GlyphLine(List<Glyph> glyphs, int start, int end) {
89
89
/**
90
90
* Create a new line of Glyphs from a slice of a List of Glyphs, and add the actual text.
91
91
*
92
- * @param glyphs list of Glyphs to slice
92
+ * @param glyphs list of Glyphs to slice
93
93
* @param actualText corresponding list containing the actual text the glyphs represent
94
- * @param start starting index of the slice
95
- * @param end terminating index of the slice
94
+ * @param start starting index of the slice
95
+ * @param end terminating index of the slice
96
96
*/
97
97
protected GlyphLine (List <Glyph > glyphs , List <ActualText > actualText , int start , int end ) {
98
98
this (glyphs , start , end );
@@ -114,9 +114,10 @@ public GlyphLine(GlyphLine other) {
114
114
115
115
/**
116
116
* Copy a slice of a line of Glyphs
117
+ *
117
118
* @param other line of Glyphs to copy
118
119
* @param start starting index of the slice
119
- * @param end terminating index of the slice
120
+ * @param end terminating index of the slice
120
121
*/
121
122
public GlyphLine (GlyphLine other , int start , int end ) {
122
123
this .glyphs = other .glyphs .subList (start , end );
@@ -130,8 +131,9 @@ public GlyphLine(GlyphLine other, int start, int end) {
130
131
131
132
/**
132
133
* Get the unicode string representation of the GlyphLine slice.
134
+ *
133
135
* @param start starting index of the slice
134
- * @param end terminating index of the slice
136
+ * @param end terminating index of the slice
135
137
* @return String containing the unicode representation of the slice.
136
138
*/
137
139
public String toUnicodeString (int start , int end ) {
@@ -158,7 +160,7 @@ public String toString() {
158
160
/**
159
161
* Copy a slice of this Glyphline.
160
162
*
161
- * @param left leftmost index of the slice
163
+ * @param left leftmost index of the slice
162
164
* @param right rightmost index of the slice
163
165
* @return new GlyphLine containing the copied slice
164
166
*/
@@ -220,17 +222,23 @@ public void add(GlyphLine other) {
220
222
glyphs .addAll (other .glyphs .subList (other .start , other .end ));
221
223
}
222
224
225
+ /**
226
+ * Replaces the current content with the other line's content.
227
+ *
228
+ * @param other the line with the content to be set to the current one
229
+ */
223
230
public void replaceContent (GlyphLine other ) {
224
231
glyphs .clear ();
225
232
glyphs .addAll (other .glyphs );
226
- if (actualText != null ) {
227
- actualText .clear ();
228
- }
229
233
if (other .actualText != null ) {
230
234
if (actualText == null ) {
231
235
actualText = new ArrayList <>();
236
+ } else {
237
+ actualText .clear ();
232
238
}
233
239
actualText .addAll (other .actualText );
240
+ } else {
241
+ actualText = null ;
234
242
}
235
243
start = other .start ;
236
244
end = other .end ;
@@ -347,7 +355,7 @@ public boolean equals(Object obj) {
347
355
if (obj == null || getClass () != obj .getClass ()) {
348
356
return false ;
349
357
}
350
- GlyphLine other = (GlyphLine )obj ;
358
+ GlyphLine other = (GlyphLine ) obj ;
351
359
if (end - start != other .end - other .start ) {
352
360
return false ;
353
361
}
@@ -386,6 +394,10 @@ private void addAllGlyphs(int index, List<Glyph> additionalGlyphs) {
386
394
}
387
395
}
388
396
397
+ public interface IGlyphLineFilter {
398
+ boolean accept (Glyph glyph );
399
+ }
400
+
389
401
public static class GlyphLinePart {
390
402
public int start ;
391
403
public int end ;
@@ -409,19 +421,14 @@ public GlyphLinePart setReversed(boolean reversed) {
409
421
}
410
422
}
411
423
412
- public interface IGlyphLineFilter {
413
- boolean accept (Glyph glyph );
414
- }
415
-
416
424
protected static class ActualText implements Serializable {
417
425
private static final long serialVersionUID = 5109920013485372966L ;
426
+ public String value ;
418
427
419
428
public ActualText (String value ) {
420
429
this .value = value ;
421
430
}
422
431
423
- public String value ;
424
-
425
432
@ Override
426
433
public boolean equals (Object obj ) {
427
434
if (this == obj ) {
0 commit comments