A method, comprising: receiving, at a computing device, a user-interface layout (Table 1) configured to specify at least a first rectangular component and a second rectangular component (320-336, 402-418), both within a container rectangle, wherein the first rectangular component has a first size in a horizontal or vertical dimension, and wherein the second rectangular component has a second size in the horizontal or vertical dimension; the computing device determining a plurality of grid lines (GL X0, GL X1, GL X2, GL X3, GL X4, GL Y0, GL Y1, GL Y2, GL Y3, GL Y4, GL Y5, GL Y6, GL Y7) based on the user-interface layout, wherein the first rectangular component is associated with a first set of at least two grid lines of the plurality of grid lines, and wherein the second rectangular component is associated with a second set of at least two grid lines of the plurality of grid lines; the computing device generating a system of constraints (420-438, 630-648, 730-746b), wherein a first constraint in the system of constraints is related to the first set of at least two grid lines, and wherein a second constraint in the system of constraints is related to the second set of at least two grid lines; characterized in the computing device solving the system of constraints to determine, for each respective grid line in the first and second sets of grid lines, a respective location for the respective grid line, wherein solving the system of constraints comprises: generating a graph comprising a plurality of nodes and a plurality of edges, wherein the plurality of nodes correspond to the plurality of grid lines, and wherein the plurality of edges correspond to the system of constraints, and using a variant of a Bellman-Ford algorithm to solve a single-source path-length problem for the graph to determine the respective locations for the respective grid lines of the plurality of grid lines; based on the respective locations of the respective grid lines, the computing device generating a user-interface display (610, 610a, 610b, 680a, 680b, 780) including the first and second rectangular components; and the computing device displaying the user-interface display. receiving, at a computing device, a user-interface layout (Table 1) configured to specify at least a first rectangular component and a second rectangular component (320-336, 402-418), both within a container rectangle, wherein the first rectangular component has a first size in a horizontal or vertical dimension, and wherein the second rectangular component has a second size in the horizontal or vertical dimension; the computing device determining a plurality of grid lines (GL X0, GL X1, GL X2, GL X3, GL X4, GL Y0, GL Y1, GL Y2, GL Y3, GL Y4, GL Y5, GL Y6, GL Y7) based on the user-interface layout, wherein the first rectangular component is associated with a first set of at least two grid lines of the plurality of grid lines, and wherein the second rectangular component is associated with a second set of at least two grid lines of the plurality of grid lines; the computing device generating a system of constraints (420-438, 630-648, 730-746b), wherein a first constraint in the system of constraints is related to the first set of at least two grid lines, and wherein a second constraint in the system of constraints is related to the second set of at least two grid lines; characterized in the computing device solving the system of constraints to determine, for each respective grid line in the first and second sets of grid lines, a respective location for the respective grid line, wherein solving the system of constraints comprises: generating a graph comprising a plurality of nodes and a plurality of edges, wherein the plurality of nodes correspond to the plurality of grid lines, and wherein the plurality of edges correspond to the system of constraints, and using a variant of a Bellman-Ford algorithm to solve a single-source path-length problem for the graph to determine the respective locations for the respective grid lines of the plurality of grid lines; based on the respective locations of the respective grid lines, the computing device generating a user-interface display (610, 610a, 610b, 680a, 680b, 780) including the first and second rectangular components; and the computing device displaying the user-interface display. generating a graph comprising a plurality of nodes and a plurality of edges, wherein the plurality of nodes correspond to the plurality of grid lines, and wherein the plurality of edges correspond to the system of constraints, and using a variant of a Bellman-Ford algorithm to solve a single-source path-length problem for the graph to determine the respective locations for the respective grid lines of the plurality of grid lines;