final int offset = 20;
final int offset = view.getGridSize()*2;
public void initializeLayout() {	ViewState view = ViewState.getInstance();	boolean grid = com.cosylab.vdct.Settings.getInstance().getSnapToGrid();	com.cosylab.vdct.Settings.getInstance().setSnapToGrid(false);     // avoid fixes in getX()	try	{				// count objects to layout		int containerCount = 0;		Enumeration e = getSubObjectsV().elements();		while (e.hasMoreElements())			if (e.nextElement() instanceof ContainerObject)				containerCount++;							final int offset = 20;				// groups should be the widest		int nx = (view.getWidth()-offset)/(Constants.GROUP_WIDTH+offset);		if (nx==0) nx=1;		int sx = (int)((view.getWidth()-offset)/nx);		sx = Math.min(sx, Constants.GROUP_WIDTH+offset);					int ny = containerCount/nx+1;		if (ny==0) ny=1;		int sy = (int)(view.getHeight()/(ny+1));		sy = Math.min(sy, 3*Constants.GROUP_HEIGHT);				int x = offset/2;		int y = x;		int i = 0;		VisibleObject vo;		e = getSubObjectsV().elements();		while (e.hasMoreElements()) {			vo = (VisibleObject)(e.nextElement());			if (vo instanceof ContainerObject) {				if (vo instanceof Group) ((Group)vo).initializeLayout();				if ((vo.getX()<=0) || (vo.getY()<=0) ||					(vo.getY()>=view.getHeight()) || 					(vo.getX()>=view.getWidth())) {					vo.setX(x); vo.setY(y);					x+=sx; i++;					if (i>=nx) {						x=offset/2; i=0; 						y+=sy;					}				}			}		}	} 	catch (Exception e)	{	}	finally	{		com.cosylab.vdct.Settings.getInstance().setSnapToGrid(grid);	}}