From 7797d6fdbfe2ff222d97220efbb93a2c249728ad Mon Sep 17 00:00:00 2001 From: ThetaSinner Date: Mon, 29 Oct 2018 19:56:58 +0000 Subject: [PATCH] #19 calculate tile positions --- .../acropolis/report/impl/ReportRunner.kt | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/ReportRunner.kt b/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/ReportRunner.kt index 28d5fb9..3d7a340 100644 --- a/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/ReportRunner.kt +++ b/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/ReportRunner.kt @@ -29,8 +29,31 @@ private class ReportRunner : IReportRunner { val diagramWidth = 2 * diagramPadding + (maxDepth + 1) * tileWidth + maxDepth * cardSeparationHorizontal val diagramHeight = 2 * diagramPadding + (maxCountAtDepth + 1) * tileHeight + maxCountAtDepth * cardSeparationVertical - DiagramRenderer(diagramWidth, diagramHeight).use { renderer -> + val tempDepthCounts = HashMap() + depthCounts.forEach { depth, count -> + tempDepthCounts[depth] = count + } + + val positions = HashMap() + depthMap.forEach { node, depth -> + val currentDepthCount = tempDepthCounts[depth] ?: throw IllegalStateException("missing temp depth count") + + val depthCount = depthCounts[depth] ?: throw IllegalStateException("missing depth count") + + val y = ((diagramHeight - 2 * diagramPadding) / depthCount) * currentDepthCount + diagramPadding - 0.5 * diagramHeight + val position = Position( + (diagramPadding + depth * cardSeparationHorizontal + depth * tileWidth).toFloat(), + y.toFloat() + ) + + positions[node] = position + + tempDepthCounts[depth] = currentDepthCount - 1 + } + + DiagramRenderer(diagramWidth, diagramHeight).use { renderer -> + } }