From 89e70d7af8af1284e15fc1fb94b58a5476b01bbd Mon Sep 17 00:00:00 2001 From: ThetaSinner Date: Sun, 28 Oct 2018 23:23:04 +0000 Subject: [PATCH] #19 start working on the layout process --- .../acropolis/report/impl/ReportRunner.kt | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) 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 1e62973..28d5fb9 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 @@ -4,15 +4,47 @@ import org.ephyra.acropolis.report.api.IReportRunner import org.ephyra.acropolis.report.api.model.Graph import org.ephyra.acropolis.report.api.model.GraphContainer import org.ephyra.acropolis.report.api.model.Node +import org.ephyra.acropolis.report.impl.render.DiagramRenderer import org.springframework.stereotype.Component +import java.lang.IllegalStateException @Component private class ReportRunner : IReportRunner { override fun run(graphContainer: GraphContainer) { println("Running report") - buildNodeDepth(graphContainer.graph) + val depthMap = buildNodeDepth(graphContainer.graph) + val depthCounts = countDepths(depthMap) - + val maxDepth = depthMap.values.max() ?: throw IllegalStateException("missing depth") + val maxCountAtDepth = depthCounts.values.max() ?: throw IllegalStateException("missing count") + + val tileWidth = 300 + val tileHeight = 350 + + val cardSeparationHorizontal = 75 + val cardSeparationVertical = 35 + + val diagramPadding = 30 + + val diagramWidth = 2 * diagramPadding + (maxDepth + 1) * tileWidth + maxDepth * cardSeparationHorizontal + val diagramHeight = 2 * diagramPadding + (maxCountAtDepth + 1) * tileHeight + maxCountAtDepth * cardSeparationVertical + + DiagramRenderer(diagramWidth, diagramHeight).use { renderer -> + + } + } + + private fun countDepths(depthMap: HashMap): HashMap { + val depthCounts = HashMap() + depthMap.forEach { (_, v) -> + val t = depthCounts[v] + if (t == null) { + depthCounts[v] = 0 + } else { + depthCounts[v] = t + 1 + } + } + return depthCounts } fun buildNodeDepth(graph: Graph): HashMap { @@ -53,3 +85,8 @@ private class ReportRunner : IReportRunner { } } } + +class Position( + val x: Float, + val y: Float +)