ActualTextIterator implements Iterator<GlyphLine.GlyphLinePart> { @Override public GlyphLine.GlyphLinePart next() { if (glyphLine.actualText == null) { GlyphLine.GlyphLinePart result = new GlyphLine.GlyphLinePart(pos, glyphLine.end, null); pos = glyphLine.end; return result; } else { GlyphLine.GlyphLinePart currentResult = nextGlyphLinePart(pos); if (currentResult == null) { return null; } pos = currentResult.end; if (!glyphLinePartNeedsActualText(currentResult)) { currentResult.actualText = null; while (pos < glyphLine.end) { GlyphLine.GlyphLinePart nextResult = nextGlyphLinePart(pos); if (nextResult != null && !glyphLinePartNeedsActualText(nextResult)) { currentResult.end = nextResult.end; pos = nextResult.end; } else { break; } } } return currentResult; } } ActualTextIterator(GlyphLine glyphLine);  ActualTextIterator(GlyphLine glyphLine, int start, int end); @Override boolean hasNext(); @Override GlyphLine.GlyphLinePart next(); @Override void remove();  }
@Test public void testActualTestParts() { Glyph glyph = new Glyph(200, 200, '\u002d'); GlyphLine glyphLine = new GlyphLine(Arrays.asList(glyph)); glyphLine.setActualText(0, 1, "\u002d"); ActualTextIterator actualTextIterator = new ActualTextIterator(glyphLine); GlyphLine.GlyphLinePart part = actualTextIterator.next(); Assert.assertNull(part.actualText); }