VisualFragment () { if (!hasNext()) { throw new NoSuchElementException(); } BidiRun run = myRuns[myRunIndex]; if (myRunIndex == 0 && myChunkIndex == 0 && myFragmentIndex == 0) { myFragment.startLogicalColumn = run.visualStartLogicalColumn; } else { myFragment.startLogicalColumn = myChunkIndex == 0 && myFragmentIndex == 0 ? run.visualStartLogicalColumn : myFragment.getEndLogicalColumn(); myFragment.startVisualColumn = myFragment.getEndVisualColumn(); myFragment.startX = myFragment.getEndX(); } myFragment.isRtl = run.isRtl(); List<Chunk> chunks = run.getChunks(myText, myLineStartOffset); Chunk chunk = chunks.get(run.isRtl() ? chunks.size() - 1 - myChunkIndex : myChunkIndex); myFragment.delegate = chunk.fragments.get(run.isRtl() ? chunk.fragments.size() - 1 - myFragmentIndex : myFragmentIndex); myFragment.startOffset = run.isRtl() ? run.endOffset - myOffsetInsideRun : run.startOffset + myOffsetInsideRun; myOffsetInsideRun += myFragment.getLength(); myFragmentIndex++; if (myFragmentIndex >= chunk.fragments.size()) { myFragmentIndex = 0; myChunkIndex++; if (myChunkIndex >= chunks.size()) { myChunkIndex = 0; myOffsetInsideRun = 0; myRunIndex++; } } return myFragment; }