Skip to content

Commit

Permalink
#19 Start on card builder for rendering images with text
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Nov 12, 2018
1 parent 0e79762 commit d4839ea
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ 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.CardBuilder
import org.ephyra.acropolis.report.impl.render.DiagramRenderer
import org.ephyra.acropolis.report.impl.render.Position2D
import org.ephyra.acropolis.report.impl.render.Size2D
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.io.File
Expand Down Expand Up @@ -46,7 +49,7 @@ internal class ReportRunner : IReportRunner {
tempDepthCounts[depth] = count
}

val positions = HashMap<Node, Position>()
val positions = HashMap<Node, Position2D>()
depthMap.forEach { node, depth ->
val currentDepthCount = tempDepthCounts[depth] ?: throw IllegalStateException("missing temp depth count")

Expand All @@ -55,7 +58,7 @@ internal class ReportRunner : IReportRunner {
val y = diagramPadding + (currentDepthCount - 1) * tileHeight
+ (currentDepthCount - 1) * cardSeparationVertical

val position = Position(
val position = Position2D(
x.toFloat(),
y.toFloat()
)
Expand All @@ -69,6 +72,11 @@ internal class ReportRunner : IReportRunner {

DiagramRenderer(diagramWidth, diagramHeight).use { renderer ->
positions.forEach { node, position ->
CardBuilder(position, Size2D(tileWidth.toFloat(), tileHeight.toFloat()))
.withImage(imageSource.get(node.representedByResourceName))
.withLabel(node.label)
.build(renderer)

val imageResource = imageSource.get(node.representedByResourceName)
renderer.addImage(position.x.toInt(), position.y.toInt(), imageResource)
}
Expand Down Expand Up @@ -127,11 +135,3 @@ internal class ReportRunner : IReportRunner {
}
}
}

/**
* Represents a position on a 2D plane
*/
class Position(
val x: Float,
val y: Float
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.ephyra.acropolis.report.impl.render

import java.io.InputStream

class CardBuilder(
private val position2D: Position2D,

private val size2D: Size2D
) {
private var source: InputStream? = null
private var label: String? = null

fun withImage(source: InputStream): CardBuilder {
this.source = source
return this
}

fun withLabel(label: String): CardBuilder {
this.label = label
return this
}

fun build(renderer: DiagramRenderer) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.ephyra.acropolis.report.impl.render

/**
* Represents a position on a 2D plane
*/
class Position2D(
val x: Float,
val y: Float
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.ephyra.acropolis.report.impl.render

class Size2D(
val width: Float,
val height: Float
)

0 comments on commit d4839ea

Please sign in to comment.