(rankSets: Array<Array<GraphNode>>, showTypes: boolean)
| 190 | } |
| 191 | |
| 192 | private placeNodes(rankSets: Array<Array<GraphNode>>, showTypes: boolean): void { |
| 193 | // Iterate backwards from highest to lowest rank, placing nodes so that they |
| 194 | // spread out from the "center" as much as possible while still being |
| 195 | // compact and not overlapping live input lines. |
| 196 | rankSets.reverse().forEach((rankSet: Array<GraphNode>) => { |
| 197 | for (const node of rankSet) { |
| 198 | this.layoutOccupation.clearOutputs(node, showTypes); |
| 199 | } |
| 200 | |
| 201 | this.traceOccupation("After clearing outputs"); |
| 202 | |
| 203 | let placedCount = 0; |
| 204 | rankSet = rankSet.sort((a: GraphNode, b: GraphNode) => a.compare(b)); |
| 205 | for (const node of rankSet) { |
| 206 | if (node.visible) { |
| 207 | node.x = this.layoutOccupation.occupy(node); |
| 208 | this.trace(`Node ${node.id} is placed between [${node.x}, ${node.x + node.getWidth()})`); |
| 209 | const staggeredFlooredI = Math.floor(placedCount++ % 3); |
| 210 | const delta = C.MINIMUM_EDGE_SEPARATION * staggeredFlooredI; |
| 211 | node.outputApproach += delta; |
| 212 | } else { |
| 213 | node.x = 0; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | this.traceOccupation("Before clearing nodes"); |
| 218 | |
| 219 | this.layoutOccupation.clearOccupied(); |
| 220 | |
| 221 | this.traceOccupation("After clearing nodes"); |
| 222 | |
| 223 | for (const node of rankSet) { |
| 224 | this.layoutOccupation.occupyInputs(node, showTypes); |
| 225 | } |
| 226 | |
| 227 | this.traceOccupation("After occupying inputs and determining bounding box"); |
| 228 | }); |
| 229 | } |
| 230 | |
| 231 | private calculateBackEdgeNumbers(): void { |
| 232 | this.graph.maxBackEdgeNumber = 0; |
no test coverage detected