int minx = 0, miny = 0, maxx = 0, x = dim.width;
final Iterator<BaseVertex> nodeIter = graph.getChildren().iterator();
while ( nodeIter.hasNext() ) {
Point loc = nodeIter.next().getLocation();
minx = Math.min( loc.x,
minx );
maxx = Math.max( loc.x,
maxx );
miny = Math.min( loc.y,
miny );
}
int delta = (x - (maxx - minx + 20)) / 2;
minx = minx - (delta);
final Iterator<BaseVertex> nodeIter2 = graph.getChildren().iterator();
while ( nodeIter2.hasNext() ) {
final BaseVertex vertex = nodeIter2.next();
Point loc = vertex.getLocation();
vertex.setLocation( new Point( loc.x - minx,
loc.y - miny ) );
}
}