Skip to content

Commit

Permalink
#19 calculate tile positions
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Oct 29, 2018
1 parent 89e70d7 commit 7797d6f
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int, Int>()
depthCounts.forEach { depth, count ->
tempDepthCounts[depth] = count
}

val positions = HashMap<Node, Position>()
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 ->

}
}

Expand Down

0 comments on commit 7797d6f

Please sign in to comment.