Equilibrium theory of the Stranski-Krastanov epitaxial morphology