Example usage for com.google.common.collect Range lowerEndpoint

List of usage examples for com.google.common.collect Range lowerEndpoint

Introduction

In this page you can find the example usage for com.google.common.collect Range lowerEndpoint.

Prototype

public C lowerEndpoint() 

Source Link

Document

Returns the lower endpoint of this range.

Usage

From source file:edu.mit.streamjit.impl.compiler2.ActorGroup.java

/**
 * Make loop handles for each Actor that execute the iteration given as
 * an argument, then bind them together in an outer loop body that
 * executes all the iterations.  Before the outer loop we must also
 * reinitialize the splitter/joiner index arrays to their initial
 * values.//from   w ww  .  j a  v a2s  . c  o m
 */
private MethodHandle makeGroupLoop(Range<Integer> iterations, int unrollFactor,
        Map<Actor, MethodHandle> withRWHandlesBound) {
    if (iterations.isEmpty())
        return Combinators.nop();
    List<MethodHandle> loopHandles = new ArrayList<>(actors().size());
    Map<int[], int[]> requiredCopies = new LinkedHashMap<>();
    for (Actor a : actors())
        loopHandles.add(makeWorkerLoop((WorkerActor) a, withRWHandlesBound.get(a), unrollFactor,
                iterations.lowerEndpoint(), requiredCopies));
    MethodHandle groupLoop = MethodHandles.insertArguments(OVERALL_GROUP_LOOP, 0,
            Combinators.semicolon(loopHandles), iterations.lowerEndpoint(), iterations.upperEndpoint(),
            unrollFactor);
    if (!requiredCopies.isEmpty()) {
        int[][] copies = new int[requiredCopies.size() * 2][];
        int i = 0;
        for (Map.Entry<int[], int[]> e : requiredCopies.entrySet()) {
            copies[i++] = e.getKey();
            copies[i++] = e.getValue();
        }
        groupLoop = Combinators
                .semicolon(MethodHandles.insertArguments(REINITIALIZE_ARRAYS, 0, (Object) copies), groupLoop);
    }
    return groupLoop;
}

From source file:com.wealdtech.collect.TreeRangedMultimap.java

@Override
public Collection<V> get(final Range<K> range) {
    // Find all items which start before this range ends
    ImmutableSet.Builder<V> startersB = ImmutableSet.builder();
    Map.Entry<K, List<V>> startEntry = startMap.floorEntry(range.upperEndpoint());
    while (startEntry != null) {
        // Because our range is [) we don't include anything on the upper endpoint itself
        if (!startEntry.getKey().equals(range.upperEndpoint())) {
            startersB.addAll(startEntry.getValue());
        }/*  ww w.  ja  v  a  2  s.c  o  m*/
        startEntry = startMap.lowerEntry(startEntry.getKey());
    }
    final ImmutableSet<V> starters = startersB.build();

    // Final all items which end after this range starts
    ImmutableSet.Builder<V> finishersB = ImmutableSet.builder();
    Map.Entry<K, List<V>> finishEntry = endMap.ceilingEntry(range.lowerEndpoint());
    while (finishEntry != null) {
        // Because our range is [) we don't include anything on the lower endpoint itself
        if (!finishEntry.getKey().equals(range.lowerEndpoint())) {
            finishersB.addAll(finishEntry.getValue());
        }
        finishEntry = endMap.higherEntry(finishEntry.getKey());
    }
    final ImmutableSet<V> finishers = finishersB.build();

    // Our result is everything which is in both sets
    return Sets.intersection(starters, finishers);
}

From source file:com.google.googlejavaformat.java.JavaOutput.java

/**
 * Emit a list of {@link Replacement}s to convert from input to output.
 *
 * @return a list of {@link Replacement}s, sorted by start index, without overlaps
 *///  w w w  . j av a2s . c  om
public ImmutableList<Replacement> getFormatReplacements(RangeSet<Integer> iRangeSet0) {
    ImmutableList.Builder<Replacement> result = ImmutableList.builder();
    Map<Integer, Range<Integer>> kToJ = JavaOutput.makeKToIJ(this);

    // Expand the token ranges to align with re-formattable boundaries.
    RangeSet<Integer> breakableRanges = TreeRangeSet.create();
    RangeSet<Integer> iRangeSet = iRangeSet0.subRangeSet(Range.closed(0, javaInput.getkN()));
    for (Range<Integer> iRange : iRangeSet.asRanges()) {
        Range<Integer> range = expandToBreakableRegions(iRange.canonical(DiscreteDomain.integers()));
        if (range.equals(EMPTY_RANGE)) {
            // the range contains only whitespace
            continue;
        }
        breakableRanges.add(range);
    }

    // Construct replacements for each reformatted region.
    for (Range<Integer> range : breakableRanges.asRanges()) {

        Input.Tok startTok = startTok(javaInput.getToken(range.lowerEndpoint()));
        Input.Tok endTok = endTok(javaInput.getToken(range.upperEndpoint() - 1));

        // Add all output lines in the given token range to the replacement.
        StringBuilder replacement = new StringBuilder();

        int replaceFrom = startTok.getPosition();
        // Replace leading whitespace in the input with the whitespace from the formatted file
        while (replaceFrom > 0) {
            char previous = javaInput.getText().charAt(replaceFrom - 1);
            if (!CharMatcher.whitespace().matches(previous)) {
                break;
            }
            replaceFrom--;
        }

        int i = kToJ.get(startTok.getIndex()).lowerEndpoint();
        // Include leading blank lines from the formatted output, unless the formatted range
        // starts at the beginning of the file.
        while (i > 0 && getLine(i - 1).isEmpty()) {
            i--;
        }
        // Write out the formatted range.
        for (; i < kToJ.get(endTok.getIndex()).upperEndpoint(); i++) {
            // It's possible to run out of output lines (e.g. if the input ended with
            // multiple trailing newlines).
            if (i < getLineCount()) {
                if (i > 0) {
                    replacement.append(lineSeparator);
                }
                replacement.append(getLine(i));
            }
        }

        int replaceTo = Math.min(endTok.getPosition() + endTok.length(), javaInput.getText().length());
        // If the formatted ranged ended in the trailing trivia of the last token before EOF,
        // format all the way up to EOF to deal with trailing whitespace correctly.
        if (endTok.getIndex() == javaInput.getkN() - 1) {
            replaceTo = javaInput.getText().length();
        }
        // Replace trailing whitespace in the input with the whitespace from the formatted file.
        // If the trailing whitespace in the input includes one or more line breaks, preserve the
        // whitespace after the last newline to avoid re-indenting the line following the formatted
        // line.
        int newline = -1;
        while (replaceTo < javaInput.getText().length()) {
            char next = javaInput.getText().charAt(replaceTo);
            if (!CharMatcher.whitespace().matches(next)) {
                break;
            }
            int newlineLength = Newlines.hasNewlineAt(javaInput.getText(), replaceTo);
            if (newlineLength != -1) {
                newline = replaceTo;
                // Skip over the entire newline; don't count the second character of \r\n as a newline.
                replaceTo += newlineLength;
            } else {
                replaceTo++;
            }
        }
        if (newline != -1) {
            replaceTo = newline;
        }

        if (newline == -1) {
            // There wasn't an existing trailing newline; add one.
            replacement.append(lineSeparator);
        }
        for (; i < getLineCount(); i++) {
            String after = getLine(i);
            int idx = CharMatcher.whitespace().negate().indexIn(after);
            if (idx == -1) {
                // Write out trailing empty lines from the formatted output.
                replacement.append(lineSeparator);
            } else {
                if (newline == -1) {
                    // If there wasn't a trailing newline in the input, indent the next line.
                    replacement.append(after.substring(0, idx));
                }
                break;
            }
        }

        result.add(Replacement.create(replaceFrom, replaceTo, replacement.toString()));
    }
    return result.build();
}

From source file:org.dishevelled.bio.range.entrytree.CenteredRangeTree.java

/**
 * Depth first search.//  w w  w  .jav  a  2  s  .com
 *
 * @param query query range
 * @param node node
 * @param result list of matching ranges
 * @param visited set of visited nodes
 */
private void depthFirstSearch(final Range<C> query, final Node node, final List<Entry<C, V>> result,
        final Set<Node> visited) {
    if (node == null || visited.contains(node) || query.isEmpty()) {
        return;
    }
    if (node.left() != null && Ranges.isLessThan(query, node.center())) {
        depthFirstSearch(query, node.left(), result, visited);
    } else if (node.right() != null && Ranges.isGreaterThan(query, node.center())) {
        depthFirstSearch(query, node.right(), result, visited);
    }
    if (Ranges.isGreaterThan(query, node.center())) {
        for (Entry<C, V> entry : node.overlapByUpperEndpoint()) {
            Range<C> range = entry.getRange();
            if (Ranges.intersect(range, query)) {
                result.add(entry);
            }
            if (Ranges.isGreaterThan(query, range.upperEndpoint())) {
                break;
            }
        }
    } else if (Ranges.isLessThan(query, node.center())) {
        for (Entry<C, V> entry : node.overlapByLowerEndpoint()) {
            Range<C> range = entry.getRange();
            if (Ranges.intersect(range, query)) {
                result.add(entry);
            }
            if (Ranges.isLessThan(query, range.lowerEndpoint())) {
                break;
            }
        }
    } else {
        result.addAll(node.overlapByLowerEndpoint());
    }
    visited.add(node);
}

From source file:com.pingcap.tikv.predicates.ScanBuilder.java

private List<KeyRange> buildTableScanKeyRange(TiTableInfo table, List<IndexRange> indexRanges) {
    requireNonNull(table, "Table cannot be null to encoding keyRange");
    requireNonNull(indexRanges, "indexRanges cannot be null to encoding keyRange");

    List<KeyRange> ranges = new ArrayList<>(indexRanges.size());
    for (IndexRange ir : indexRanges) {
        ByteString startKey;//from   w  w  w.j  a  v a2 s  . com
        ByteString endKey;
        if (ir.hasAccessPoints()) {
            checkArgument(!ir.hasRange(), "Table scan must have one and only one access condition / point");

            Object v = ir.getAccessPoints().get(0);
            checkArgument(v instanceof Long, "Table scan key range must be long value");
            DataType type = ir.getTypes().get(0);
            checkArgument(type instanceof IntegerType, "Table scan key range must be long value");
            startKey = TableCodec.encodeRowKeyWithHandle(table.getId(), (long) v);
            endKey = ByteString.copyFrom(KeyUtils.prefixNext(startKey.toByteArray()));
        } else if (ir.hasRange()) {
            checkArgument(!ir.hasAccessPoints(),
                    "Table scan must have one and only one access condition / point");
            Range r = ir.getRange();
            DataType type = ir.getRangeType();
            checkArgument(type instanceof IntegerType, "Table scan key range must be long value");

            if (!r.hasLowerBound()) {
                // -INF
                // TODO: Domain and encoding should be further encapsulated
                startKey = TableCodec.encodeRowKeyWithHandle(table.getId(), Long.MIN_VALUE);
            } else {
                // Comparision with null should be filtered since it yields unknown always
                Object lb = r.lowerEndpoint();
                checkArgument(lb instanceof Long, "Table scan key range must be long value");
                long lVal = (long) lb;
                if (r.lowerBoundType().equals(BoundType.OPEN)) {
                    // TODO: Need push back?
                    if (lVal != Long.MAX_VALUE) {
                        lVal++;
                    }
                }
                startKey = TableCodec.encodeRowKeyWithHandle(table.getId(), lVal);
            }

            if (!r.hasUpperBound()) {
                // INF
                endKey = TableCodec.encodeRowKeyWithHandle(table.getId(), Long.MAX_VALUE);
            } else {
                Object ub = r.upperEndpoint();
                checkArgument(ub instanceof Long, "Table scan key range must be long value");
                long lVal = (long) ub;
                if (r.upperBoundType().equals(BoundType.CLOSED)) {
                    if (lVal != Long.MAX_VALUE) {
                        lVal++;
                    }
                }
                endKey = TableCodec.encodeRowKeyWithHandle(table.getId(), lVal);
            }
        } else {
            throw new TiClientInternalException("Empty access conditions");
        }

        ranges.add(KeyRange.newBuilder().setStart(startKey).setEnd(endKey).build());
    }

    if (ranges.isEmpty()) {
        ByteString startKey = TableCodec.encodeRowKeyWithHandle(table.getId(), Long.MIN_VALUE);
        ByteString endKey = TableCodec.encodeRowKeyWithHandle(table.getId(), Long.MAX_VALUE);
        ranges.add(KeyRange.newBuilder().setStart(startKey).setEnd(endKey).build());
    }

    return ranges;
}

From source file:org.eclipse.fx.ui.controls.styledtext.internal.LineNode.java

protected Range<Integer> toGlobal(Range<Integer> range) {
    int lineOffset = this.lineHelper.getOffset(index);
    return Range.range(lineOffset + range.lowerEndpoint(), range.lowerBoundType(),
            lineOffset + range.upperEndpoint(), range.upperBoundType());
}

From source file:org.eclipse.fx.ui.controls.styledtext.internal.LineNode.java

protected Range<Integer> toLocal(Range<Integer> range) {
    int lineOffset = -this.lineHelper.getOffset(index);
    return Range.range(lineOffset + range.lowerEndpoint(), range.lowerBoundType(),
            lineOffset + range.upperEndpoint(), range.upperBoundType());
}

From source file:jetbrains.jetpad.hybrid.HybridSynchronizer.java

private CellTrait createTargetTrait() {
    return new CellTrait() {
        @Override/*from w  ww. ja  v  a  2 s .  c o  m*/
        public Object get(Cell cell, CellTraitPropertySpec<?> spec) {
            if (spec == HYBRID_SYNCHRONIZER) {
                return HybridSynchronizer.this;
            }
            if (spec == CellStateHandler.PROPERTY) {
                return getCellStateHandler();
            }

            return super.get(cell, spec);
        }

        @Override
        public void onKeyPressed(Cell cell, KeyEvent event) {
            Cell focusedCell = cell.cellContainer().get().focusedCell.get();
            if (myTargetList.contains(focusedCell)) {
                Cell currentCell = cell.cellContainer().get().focusedCell.get();
                if (!hasSelection()) {
                    if (event.is(KeyStrokeSpecs.SELECT_UP) && currentCell != null) {
                        mySelectionSupport.select(currentCell, currentCell);
                        event.consume();
                    }
                } else {
                    Range<Integer> currentRange = selection();
                    if (event.is(KeyStrokeSpecs.SELECT_UP)) {
                        ParseNode parseNode = myTokenListEditor.parseNode();
                        if (parseNode != null) {
                            if (!currentRange.equals(parseNode.range())) {
                                ParseNode node = ParseNodes.findForRange(parseNode, currentRange);
                                ParseNode parentNode = ParseNodes.nonSameRangeParent(node);
                                if (parentNode != null) {
                                    select(parentNode.range());
                                    event.consume();
                                }
                            }
                        } else {
                            if (!currentRange.equals(Range.closed(0, tokens().size()))) {
                                select(Range.closed(0, tokens().size()));
                                event.consume();
                            }
                        }
                    }

                    if (event.is(KeyStrokeSpecs.SELECT_DOWN)) {
                        ParseNode parseNode = myTokenListEditor.parseNode();
                        if (parseNode != null) {
                            ParseNode node = ParseNodes.findForRange(parseNode, currentRange);
                            ParseNode childNode = ParseNodes.nonSameRangeChild(node,
                                    myTargetList.indexOf(mySelectionSupport.currentCell()));
                            if (childNode != null) {
                                select(childNode.range());
                                event.consume();
                                return;
                            }
                        }

                        if (!mySelectionSupport.isCurrentCompletelySelected()) {
                            mySelectionSupport.clearSelection();
                            event.consume();
                        }
                    }
                }
            }
            super.onKeyPressed(cell, event);
        }

        @Override
        public void onCopy(Cell cell, CopyCutEvent event) {
            if (canCopy()) {
                event.consume(copy());
                return;
            }
            super.onCopy(cell, event);
        }

        @Override
        public void onCut(Cell cell, CopyCutEvent event) {
            if (canCut()) {
                event.consume(cut());
                return;
            }
            super.onCut(cell, event);
        }

        @Override
        public void onPaste(Cell cell, PasteEvent event) {
            if (canPaste(event.getContent())) {
                paste(event.getContent());
                event.consume();
                return;
            }
            super.onPaste(cell, event);
        }

        private boolean canPaste(ClipboardContent content) {
            return content.isSupported(TOKENS_CONTENT);
        }

        private void paste(ClipboardContent content) {
            List<Token> tokens = content.get(TOKENS_CONTENT);
            Cell currentCell = mySelectionSupport.currentCell();

            int targetIndex;
            if (currentCell != null) {
                int currentCellIndex = myTargetList.indexOf(currentCell);
                targetIndex = Positions.isHomePosition(currentCell) ? currentCellIndex : currentCellIndex + 1;
            } else {
                targetIndex = 0;
            }

            myTokenListEditor.tokens.addAll(targetIndex, tokens);
            myTokenListEditor.updateToPrintedTokens();
            tokenOperations().select(targetIndex + tokens.size() - 1, LAST).run();
        }

        private boolean canCopy() {
            return hasSelection();
        }

        private ClipboardContent copy() {
            final Range<Integer> selection = selection();
            final List<Token> tokens = new ArrayList<>(
                    tokens().subList(selection.lowerEndpoint(), selection.upperEndpoint()));
            return new ClipboardContent() {
                @Override
                public boolean isSupported(ContentKind<?> kind) {
                    return kind == TOKENS_CONTENT;
                }

                @Override
                public <T> T get(ContentKind<T> kind) {
                    if (kind == TOKENS_CONTENT) {
                        return (T) Collections.unmodifiableList(tokens);
                    }
                    return null;
                }
            };
        }

        private boolean canCut() {
            return hasSelection();
        }

        private ClipboardContent cut() {
            ClipboardContent result = copy();
            clearSelection();
            return result;
        }
    };
}

From source file:org.pshdl.model.extensions.RangeExtension.java

protected Optional<Range<BigInteger>> _determineRange(final HDLManip obj, final HDLEvaluationContext context) {
    HDLExpression _target = obj.getTarget();
    final Optional<Range<BigInteger>> right = this.determineRange(_target, context);
    boolean _isPresent = right.isPresent();
    boolean _not = (!_isPresent);
    if (_not) {// ww w. j a v a 2 s  . com
        return Optional.<Range<BigInteger>>absent();
    }
    HDLManip.HDLManipType _type = obj.getType();
    if (_type != null) {
        switch (_type) {
        case CAST:
            final HDLType type = obj.getCastTo();
            if ((type instanceof HDLPrimitive)) {
                HDLPrimitives _instance = HDLPrimitives.getInstance();
                final Optional<Range<BigInteger>> castRange = _instance.getValueRange(((HDLPrimitive) type),
                        context);
                boolean _isPresent_1 = right.isPresent();
                boolean _not_1 = (!_isPresent_1);
                if (_not_1) {
                    return Optional.<Range<BigInteger>>absent();
                }
                HDLPrimitive.HDLPrimitiveType _type_1 = ((HDLPrimitive) type).getType();
                boolean _equals = Objects.equal(_type_1, HDLPrimitive.HDLPrimitiveType.INTEGER);
                if (_equals) {
                    Range<BigInteger> _intRange = HDLPrimitives.intRange(BigInteger.valueOf(32L));
                    Range<BigInteger> _get = right.get();
                    Range<BigInteger> _intersection = _intRange.intersection(_get);
                    return Optional.<Range<BigInteger>>of(_intersection);
                }
                HDLPrimitive.HDLPrimitiveType _type_2 = ((HDLPrimitive) type).getType();
                boolean _equals_1 = Objects.equal(_type_2, HDLPrimitive.HDLPrimitiveType.NATURAL);
                if (_equals_1) {
                    Range<BigInteger> _uintRange = HDLPrimitives.uintRange(BigInteger.valueOf(32L));
                    Range<BigInteger> _get_1 = right.get();
                    Range<BigInteger> _intersection_1 = _uintRange.intersection(_get_1);
                    return Optional.<Range<BigInteger>>of(_intersection_1);
                }
                HDLPrimitive.HDLPrimitiveType _type_3 = ((HDLPrimitive) type).getType();
                boolean _equals_2 = Objects.equal(_type_3, HDLPrimitive.HDLPrimitiveType.BIT);
                if (_equals_2) {
                    Range<BigInteger> _createRange = RangeTool.<BigInteger>createRange(BigInteger.ZERO,
                            BigInteger.ONE);
                    Range<BigInteger> _get_2 = right.get();
                    Range<BigInteger> _intersection_2 = _createRange.intersection(_get_2);
                    return Optional.<Range<BigInteger>>of(_intersection_2);
                }
                boolean _isPresent_2 = castRange.isPresent();
                boolean _not_2 = (!_isPresent_2);
                if (_not_2) {
                    return Optional.<Range<BigInteger>>absent();
                }
                Range<BigInteger> _get_3 = castRange.get();
                Range<BigInteger> _get_4 = right.get();
                Range<BigInteger> _intersection_3 = _get_3.intersection(_get_4);
                return Optional.<Range<BigInteger>>of(_intersection_3);
            }
            obj.<IHDLObject>addMeta(ProblemDescription.SOURCE, obj);
            obj.<ProblemDescription>addMeta(ProblemDescription.DESCRIPTION,
                    ProblemDescription.TYPE_NOT_SUPPORTED_FOR_CONSTANTS);
            return Optional.<Range<BigInteger>>absent();
        case ARITH_NEG:
            Range<BigInteger> _get_5 = right.get();
            BigInteger _upperEndpoint = _get_5.upperEndpoint();
            BigInteger _negate = _upperEndpoint.negate();
            Range<BigInteger> _get_6 = right.get();
            BigInteger _lowerEndpoint = _get_6.lowerEndpoint();
            BigInteger _negate_1 = _lowerEndpoint.negate();
            Range<BigInteger> _createRange_1 = RangeTool.<BigInteger>createRange(_negate, _negate_1);
            return Optional.<Range<BigInteger>>of(_createRange_1);
        case BIT_NEG:
            Range<BigInteger> _get_7 = right.get();
            BigInteger _upperEndpoint_1 = _get_7.upperEndpoint();
            int _bitLength = _upperEndpoint_1.bitLength();
            BigInteger _shiftLeft = BigInteger.ONE.shiftLeft(_bitLength);
            BigInteger _subtract = _shiftLeft.subtract(BigInteger.ONE);
            Range<BigInteger> _createRange_2 = RangeTool.<BigInteger>createRange(BigInteger.ZERO, _subtract);
            return Optional.<Range<BigInteger>>of(_createRange_2);
        case LOGIC_NEG:
            obj.<IHDLObject>addMeta(ProblemDescription.SOURCE, obj);
            obj.<ProblemDescription>addMeta(ProblemDescription.DESCRIPTION,
                    ProblemDescription.BOOLEAN_NOT_SUPPORTED_FOR_RANGES);
            Range<BigInteger> _createRange_3 = RangeTool.<BigInteger>createRange(BigInteger.ZERO,
                    BigInteger.ONE);
            return Optional.<Range<BigInteger>>of(_createRange_3);
        default:
            break;
        }
    }
    throw new RuntimeException("Incorrectly implemented obj op");
}

From source file:fr.openwide.core.export.excel.AbstractExcelTableExport.java

/**
 * Finalise la cration de la feuille de calcul, notamment en demandant le
 * redimensionnement automatique des colonnes.
 * //from  w w  w  .  j  a  va 2 s.c o m
 * @param sheet feuilles de calcul
 * @param columnInfos map contenant l'en-tte et les informations d'une colonne
 * @param landscapePrintSetup dfinit si la feuille est imprime en paysage ou non
 */
protected void finalizeSheet(Sheet sheet, RangeMap<Integer, ColumnInformation> columnInfos,
        boolean landscapePrintSetup) {
    for (Map.Entry<Range<Integer>, ColumnInformation> entry : columnInfos.asMapOfRanges().entrySet()) {
        ColumnInformation columnInformation = entry.getValue();
        Range<Integer> range = entry.getKey();
        int beginIndex = range.lowerEndpoint();
        int endIndex = range.upperEndpoint();

        // Dtermination de la taille maximum de cette colonne
        int maxColumnWidth;
        if (columnInformation.getColumnMaxWidth() != -1) {
            maxColumnWidth = columnInformation.getColumnMaxWidth();
        } else {
            maxColumnWidth = ABSOLUTE_MAX_COLUMN_WIDTH;
        }

        // Dtermination de la taille souhaite pour la colonne
        if (columnInformation.getColumnWidth() != -1) {
            // On force la taille des colonnes en fonction de la columnInformation

            int columnWidth = columnInformation.getColumnWidth();
            columnWidth = Math.min(columnWidth, maxColumnWidth);

            // On prend en compte le fait que la "colonne" peut s'tendre en fait sur plusieurs colonnes (fusion de cellules au niveau du header)
            int columnSpan = endIndex - beginIndex + 1;
            columnWidth = columnWidth / columnSpan;

            // On redimmensionne les colonnes
            for (int columnIndex = beginIndex; columnIndex <= endIndex; ++columnIndex) {
                sheet.setColumnWidth(columnIndex, columnWidth);
            }
        } else {
            // On redimmensionne les colonnes une  une en prennant leur taille actuelle et en les augmentant un petit peu
            for (int columnIndex = beginIndex; columnIndex <= endIndex; ++columnIndex) {
                sheet.autoSizeColumn(columnIndex);
                int columnWidth = (int) (sheet.getColumnWidth(beginIndex) * COLUMN_RESIZE_RATIO);
                columnWidth = Math.min(columnWidth, maxColumnWidth);
                sheet.setColumnWidth(columnIndex, columnWidth);
            }
        }
    }

    finalizeSheet(sheet, landscapePrintSetup);
}