in src/org/pushingpixels/lightbeam/panels/TablePanel.java [326:369]
public PerformanceScenario getLargeRowSelectionScenario() {
return new PerformanceScenario() {
int[] perms;
@Override
public String getName() {
return "Selecting rows in large table";
}
@Override
public void setup() {
table.scrollRectToVisible(table.getCellRect(0, 0, true));
table.setRowSelectionAllowed(true);
table.setColumnSelectionAllowed(false);
table.getSelectionModel().clearSelection();
table.getSelectionModel().setSelectionMode(
ListSelectionModel.SINGLE_INTERVAL_SELECTION);
this.perms = LightBeamUtils.getPermutation(table.getRowCount(),
this.getIterationCount() * 2);
}
@Override
public int getIterationCount() {
return 10;
}
@Override
public void runSingleIteration(int iterationNumber) {
ListSelectionModel selectionModel = table.getSelectionModel();
int start = perms[2 * iterationNumber];
int end = perms[2 * iterationNumber + 1];
int startInt = Math.min(start, end);
int endInt = Math.max(start, end);
selectionModel.clearSelection();
// scroll to the middle
int selectionMiddle = (startInt + endInt) / 2;
table.scrollRectToVisible(table.getCellRect(selectionMiddle, 0,
true));
// and select
selectionModel.addSelectionInterval(startInt, endInt);
table.paintImmediately(table.getVisibleRect());
}
};
}