Statistical-mechanical selection of the shapes of disk galaxies