They're ranked in order of the standings as they get eliminated. For example, if Anaheim is eliminated in the first round they will have the 15th overall pick. If San Jose is eliminated in the first round, they will have the 22nd pick because they will be the team that was the best in the standings of the 8 eliminated. So, the Stanley Cup champions have the 30th pick.
So to make it short, it is based on both the standings and the order of elimination.
Anyways, that's how it was in the past, unless they've changed it this year.
I made that as clear as possible, but if it's not clear just tell me.