Java TreeSet convertSpanToSparseGrid(final int curIx, final int span, final TreeSet indexes)

Here you can find the source of convertSpanToSparseGrid(final int curIx, final int span, final TreeSet indexes)

Description

Spanning is specified in the uncompressed grid number.

License

Open Source License

Parameter

Parameter Description
span The span un the uncompressed grid. <code>LayoutUtil.INF</code> will be interpreted to span the rest of the column/row excluding the surrounding docking components.
indexes The indexes in the correct dimension.

Return

The converted span.

Declaration

private static int convertSpanToSparseGrid(final int curIx, final int span, final TreeSet<Integer> indexes) 

Method Source Code

//package com.java2s;

import java.util.TreeSet;

public class Main {
    /**/*from   ww w. j  a va  2  s .  co m*/
     * Spanning is specified in the uncompressed grid number. They can for instance be more than 60000 for the outer
     * edge dock grid cells. When the grid is compressed and indexed after only the cells that area occupied the span
     * is erratic. This method use the row/col indexes and corrects the span to be correct for the compressed grid.
     * 
     * @param span The span un the uncompressed grid. <code>LayoutUtil.INF</code> will be interpreted to span the rest
     *            of the column/row excluding the surrounding docking components.
     * @param indexes The indexes in the correct dimension.
     * @return The converted span.
     */
    private static int convertSpanToSparseGrid(final int curIx, final int span, final TreeSet<Integer> indexes) {
        final int lastIx = curIx + span;
        int retSpan = 1;

        for (final Integer ix : indexes) {
            if (ix <= curIx) {
                continue; // We have not arrived to the correct index yet
            }

            if (ix >= lastIx) {
                break;
            }

            retSpan++;
        }
        return retSpan;
    }
}

Related

  1. addSplits(TreeSet splitKeys, byte[] prefix, int splitBits)
  2. buildTreeSet(Collection elements)
  3. changeComparator(TreeSet set, Comparator cmp)
  4. concatenate(TreeSet in)
  5. createTreeSet(Iterable c)
  6. cvtListToTreeSet(List list)
  7. findSizedSubdirs(final String size, final TreeSet themeSubdirs)
  8. getDockInsets(final TreeSet set)