< prev index next >

## src/java.desktop/share/classes/javax/swing/DefaultListSelectionModel.java

Print this page

     674     /**
     675      * Remove the indices in the interval index0,index1 (inclusive) from
     676      * the selection model.  This is typically called to sync the selection
     677      * model width a corresponding change in the data model.  Note
     678      * that (as always) index0 need not be &lt;= index1.
     679      */
     680     public void removeIndexInterval(int index0, int index1)
     681     {
     682         int rmMinIndex = Math.min(index0, index1);
     683         int rmMaxIndex = Math.max(index0, index1);
     684         int gapLength = (rmMaxIndex - rmMinIndex) + 1;
     685
     686         /* Shift the entire bitset to the left to close the index0, index1
     687          * gap.
     688          */
     689         for(int i = rmMinIndex; i <= maxIndex; i++) {
     690             setState(i, value.get(i + gapLength));
     691         }
     692
     693         int leadIndex = this.leadIndex;
     694         if (leadIndex == 0 && rmMinIndex == 0) {
     695             // do nothing
     696         } else if (leadIndex > rmMaxIndex) {
     697             leadIndex = this.leadIndex - gapLength;
     698         } else if (leadIndex >= rmMinIndex) {
     699             leadIndex = rmMinIndex - 1;
     700         }
     701
     702         int anchorIndex = this.anchorIndex;
     703         if (anchorIndex == 0 && rmMinIndex == 0) {
     704             // do nothing
     705         } else if (anchorIndex > rmMaxIndex) {
     706             anchorIndex = this.anchorIndex - gapLength;
     707         } else if (anchorIndex >= rmMinIndex) {
     708             anchorIndex = rmMinIndex - 1;
     709         }
     710
     711         if (leadIndex != this.leadIndex || anchorIndex != this.anchorIndex) {
     712             updateLeadAnchorIndices(anchorIndex, leadIndex);
     713         }
     714
     715         fireValueChanged();
     716     }
     717
     718
     719     /** {@inheritDoc} */
     720     public void setValueIsAdjusting(boolean isAdjusting) {
     721         if (isAdjusting != this.isAdjusting) {
     722             this.isAdjusting = isAdjusting;
     723             this.fireValueChanged(isAdjusting);
     724         }
     725     }
     674     /**
     675      * Remove the indices in the interval index0,index1 (inclusive) from
     676      * the selection model.  This is typically called to sync the selection
     677      * model width a corresponding change in the data model.  Note
     678      * that (as always) index0 need not be &lt;= index1.
     679      */
     680     public void removeIndexInterval(int index0, int index1)
     681     {
     682         int rmMinIndex = Math.min(index0, index1);
     683         int rmMaxIndex = Math.max(index0, index1);
     684         int gapLength = (rmMaxIndex - rmMinIndex) + 1;
     685
     686         /* Shift the entire bitset to the left to close the index0, index1
     687          * gap.
     688          */
     689         for(int i = rmMinIndex; i <= maxIndex; i++) {
     690             setState(i, value.get(i + gapLength));
     691         }
     692
     693         int leadIndex = this.leadIndex;
     694         if (leadIndex > rmMaxIndex) {

     695             leadIndex = this.leadIndex - gapLength;
     696         } else if (leadIndex >= rmMinIndex) {
     697             leadIndex = rmMinIndex - 1;
     698         }
     699
     700         int anchorIndex = this.anchorIndex;
     701         if (anchorIndex > rmMaxIndex) {

     702             anchorIndex = this.anchorIndex - gapLength;
     703         } else if (anchorIndex >= rmMinIndex) {
     704             anchorIndex = rmMinIndex - 1;
     705         }
     706
     707         if (leadIndex != this.leadIndex || anchorIndex != this.anchorIndex) {
     708             updateLeadAnchorIndices(anchorIndex, leadIndex);
     709         }
     710
     711         fireValueChanged();
     712     }
     713
     714
     715     /** {@inheritDoc} */
     716     public void setValueIsAdjusting(boolean isAdjusting) {
     717         if (isAdjusting != this.isAdjusting) {
     718             this.isAdjusting = isAdjusting;
     719             this.fireValueChanged(isAdjusting);
     720         }
     721     }

< prev index next >