Constrained Layout Generation with Factor Graphs