< prev index next >

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

Print this page

    1016             }
    1017             System.arraycopy(current, last,
    1018                              viewToModel, last + i, index - last);
    1019             viewToModel[index + i] = toAdd.get(i);
    1020             last = index;
    1021         }
    1022         System.arraycopy(current, last, viewToModel, last + max,
    1023                          current.length - last);
    1024     }
    1025
    1026     /**
    1027      * Returns true if we should try and optimize the processing of the
    1028      * <code>TableModelEvent</code>.  If this returns false, assume the
    1029      * event was dealt with and no further processing needs to happen.
    1030      */
    1031     private boolean shouldOptimizeChange(int firstRow, int lastRow) {
    1032         if (!isTransformed()) {
    1033             // Not transformed, nothing to do.
    1034             return false;
    1035         }
    1036         if (!sorted || (lastRow - firstRow) > viewToModel.length / 10) {
    1037             // We either weren't sorted, or to much changed, sort it all

    1038             sort();
    1039             return false;
    1040         }
    1041         return true;
    1042     }
    1043
    1044     private void rowsInserted0(int firstRow, int lastRow) {
    1045         int[] oldViewToModel = getViewToModelAsInts(viewToModel);
    1046         int i;
    1047         int delta = (lastRow - firstRow) + 1;
    1048         List<Row> added = new ArrayList<Row>(delta);
    1049
    1050         // Build the list of Rows to add into added
    1051         for (i = firstRow; i <= lastRow; i++) {
    1052             if (include(i)) {
    1053                 added.add(new Row(this, i));
    1054             }
    1055         }
    1056
    1057         // Adjust the model index of rows after the effected region
    1016             }
    1017             System.arraycopy(current, last,
    1018                              viewToModel, last + i, index - last);
    1019             viewToModel[index + i] = toAdd.get(i);
    1020             last = index;
    1021         }
    1022         System.arraycopy(current, last, viewToModel, last + max,
    1023                          current.length - last);
    1024     }
    1025
    1026     /**
    1027      * Returns true if we should try and optimize the processing of the
    1028      * <code>TableModelEvent</code>.  If this returns false, assume the
    1029      * event was dealt with and no further processing needs to happen.
    1030      */
    1031     private boolean shouldOptimizeChange(int firstRow, int lastRow) {
    1032         if (!isTransformed()) {
    1033             // Not transformed, nothing to do.
    1034             return false;
    1035         }
    1036         if (!sorted || viewToModel.length == 0 ||
    1037                 (lastRow - firstRow) > viewToModel.length / 10) {
    1038             // We either weren't sorted, or to much changed, sort it all or
    1039             // this is the first row added and we have to update diffeent caches
    1040             sort();
    1041             return false;
    1042         }
    1043         return true;
    1044     }
    1045
    1046     private void rowsInserted0(int firstRow, int lastRow) {
    1047         int[] oldViewToModel = getViewToModelAsInts(viewToModel);
    1048         int i;
    1049         int delta = (lastRow - firstRow) + 1;
    1050         List<Row> added = new ArrayList<Row>(delta);
    1051
    1052         // Build the list of Rows to add into added
    1053         for (i = firstRow; i <= lastRow; i++) {
    1054             if (include(i)) {
    1055                 added.add(new Row(this, i));
    1056             }
    1057         }
    1058
    1059         // Adjust the model index of rows after the effected region

< prev index next >