return;
}
int xTranslate = getX();
int yTranslate = getY();
g.translate(xTranslate, yTranslate);
Rectangle pos = new Rectangle();
Dimension rendererSize = getElementSize(false);
int selection = model.getSelectedIndex();
if (animationPosition != 0 && fixedSelection > FIXED_NONE_BOUNDRY) {
// selection should never move during animation of fixed elements
selection = -1;
if (orientation == VERTICAL) {
yTranslate += animationPosition;
g.translate(0, animationPosition);
} else {
xTranslate += animationPosition;
g.translate(animationPosition, 0);
}
}
int clipX = g.getClipX();
int clipY = g.getClipY();
int clipWidth = g.getClipWidth();
int clipHeight = g.getClipHeight();
if(paintFocusBehindList){
paintFocus(g, width, pos, rendererSize);
}
// this flag is for preformance improvements
// if we figured out that the list items are not visible anymore
// we should break from the List loop
boolean shouldBreak = false;
// improve performance for browsing the end of a very large list
int startingPoint = 0;
if(fixedSelection < FIXED_NONE_BOUNDRY) {
startingPoint = Math.max(0, pointerSelect(clipX + getAbsoluteX(), clipY + getAbsoluteY()) - 1);
}
for(int i = startingPoint; i < numOfcomponents; i++) {
// skip on the selected
if(i == getSelectedIndex() && animationPosition == 0){
continue;
}
calculateComponentPosition(i, width, pos, rendererSize, getElementSize(true), i <= getSelectedIndex());
// if the renderer is in the clipping region
if(pos.intersects(clipX, clipY, clipWidth, clipHeight)) {
Object value = model.getItemAt(i);
Component cmp = renderer.getListCellRendererComponent(this, value, i, false);
cmp.setCellRenderer(true);
Dimension size = pos.getSize();
renderComponent(g, cmp, pos.getX(), pos.getY(), size.getWidth(), size.getHeight());
shouldBreak = true;
} else {
//this is relevant only if the List is not fixed.
if(shouldBreak && (fixedSelection < FIXED_NONE_BOUNDRY)) {
break;
}
}
}
if(!paintFocusBehindList){
paintFocus(g, width, pos, rendererSize);
}else{
calculateComponentPosition(getSelectedIndex(), width, pos, rendererSize, getElementSize(true), true);
}
Dimension size = pos.getSize();
//if the animation has finished draw the selected element
if (animationPosition == 0 && model.getSize() > 0) {
Component selected = renderer.getListCellRendererComponent(this, model.getItemAt(selection), selection, true);
renderComponent(g, selected, pos.getX(), pos.getY(), size.getWidth(), size.getHeight());
}
g.translate(-xTranslate, -yTranslate);
}