//XXX this whole thing is a hack. there
// really should be no empty levels.
// fix is elsewhere...
int nonEmptyLevels = 0;
for (Iterator i = new ArrayIterator(levelData._levels); i.hasNext();) {
ArrayList nodes = (ArrayList) i.next();
if (nodes.size() > 0) {
nonEmptyLevels++;
}
}
nonEmptyLevels = Math.max(1, nonEmptyLevels);
if (getOrientation() == VERTICAL) {
double ystep;
double y;
ystep = vp.getHeight() / nonEmptyLevels;
y = vp.getY() + (ystep / 2);
// int lnum=0;
for (Iterator i = new ArrayIterator(levelData._levels); i.hasNext();) {
ArrayList nodes = (ArrayList) i.next();
int levelWidth;
if (useDummies) {
levelWidth = nodes.size();
} else {
// HH, use the number of real nodes (no dummies) to
// determine the step size in the x direction.
levelWidth = 0;
for (Iterator j = nodes.iterator(); j.hasNext();) {
Object n = j.next();
if (!isDummy(n)) {
levelWidth++;
}
}
// System.out.println("Level " + lnum + ": " + nodes.size() + " nodes, real nodes: " + levelWidth);
// lnum++;
}
double xstep;
double x;
xstep = vp.getWidth() / levelWidth;
x = vp.getX() + (xstep / 2);
if (nodes.size() == 0) {
continue; //XXX why do we have an empty level???
}
for (Iterator ns = nodes.iterator(); ns.hasNext();) {
Object node = ns.next();
if (!isDummy(node)) {
placeNode(node, x, y);
}
x += xstep;
}
y += ystep;
}
} else {
double xstep;
double x;
xstep = vp.getWidth() / nonEmptyLevels;
x = vp.getX() + (xstep / 2);
for (Iterator i = new ArrayIterator(levelData._levels); i.hasNext();) {
ArrayList nodes = (ArrayList) i.next();
int levelWidth;
if (useDummies) {
levelWidth = nodes.size();
} else {