/**
* Computes the position of entries and paints them on the canvas.
*/
private void paintEntries(Entry entry, boolean splitHorizontal, Graphics g) {
if (entry.getScaledSize() == 0) return;
try {
SingleFile sf = (SingleFile) entry;
drawRect(g, sf);
} catch (ClassCastException e) {
Dir dir = (Dir) entry;
float x = dir.getX();
float y = dir.getY();
float dirSize = dir.getScaledSize();
for (Iterator iter = dir.getFiles().iterator(); iter.hasNext(); ) {
Entry element = (Entry) iter.next();
element.setX(x);
element.setY(y);
float d = element.getScaledSize() / dirSize;
if (splitHorizontal) {
element.setW(d * dir.getW());
element.setH(dir.getH());
x += element.getW();
} else {
element.setW(dir.getW());
element.setH(d * dir.getH());
y += element.getH();
}
paintEntries(element, !splitHorizontal, g);
}
}
}