< prev index next >

modules/base/src/main/java/javafx/collections/transformation/TransformationList.java

Print this page
rev 9769 : 8139848: SortedList should provide a way to map source index to view index


 131      * @param list a list from the transformation chain
 132      * @param index the index of an element in this list
 133      * @return the index of the element's origin in the provided list
 134      * @see #isInTransformationChain(javafx.collections.ObservableList)
 135      */
 136     public final int getSourceIndexFor(ObservableList<?> list, int index) {
 137         if (!isInTransformationChain(list)) {
 138             throw new IllegalArgumentException("Provided list is not in the transformation chain of this"
 139                     + "transformation list");
 140         }
 141         List<?> currentSource = source;
 142         int idx = getSourceIndex(index);
 143         while(currentSource != list && currentSource instanceof TransformationList) {
 144             final TransformationList tSource = (TransformationList)currentSource;
 145             idx = tSource.getSourceIndex(idx);
 146             currentSource = tSource.source;
 147         }
 148         return idx;
 149     }
 150 







 151 }


 131      * @param list a list from the transformation chain
 132      * @param index the index of an element in this list
 133      * @return the index of the element's origin in the provided list
 134      * @see #isInTransformationChain(javafx.collections.ObservableList)
 135      */
 136     public final int getSourceIndexFor(ObservableList<?> list, int index) {
 137         if (!isInTransformationChain(list)) {
 138             throw new IllegalArgumentException("Provided list is not in the transformation chain of this"
 139                     + "transformation list");
 140         }
 141         List<?> currentSource = source;
 142         int idx = getSourceIndex(index);
 143         while(currentSource != list && currentSource instanceof TransformationList) {
 144             final TransformationList tSource = (TransformationList)currentSource;
 145             idx = tSource.getSourceIndex(idx);
 146             currentSource = tSource.source;
 147         }
 148         return idx;
 149     }
 150 
 151     /**
 152      * Maps the index of the direct source list's element to an index in this list.
 153      * @param index the index in the source list
 154      * @return the index of the element in this list
 155      * @see #getSource(), #getSourceIndex()
 156      */
 157     public abstract int getViewIndex(int index);
 158 }
< prev index next >