Consumer<Graphics2D> (float x, float y, int startColumn, int endColumn) { assert startColumn >= 0; assert endColumn <= myCharPositions.length; assert startColumn < endColumn; return g -> { Color color = g.getColor(); assert color != null; float newX = x - getX(startColumn) + getX(endColumn); if (lastFragment == this && lastEndColumn == startColumn && lastEndX == x && lastY == y && color.equals(lastColor)) { lastEndColumn = endColumn; lastEndX = newX; return; } flushDrawingCache(g); lastFragment = this; lastStartColumn = startColumn; lastEndColumn = endColumn; lastColor = color; lastStartX = x; lastEndX = newX; lastY = y; }; }