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 7755afb..738ec14 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 @@ -59,7 +59,8 @@ internal class ReportRunner : IReportRunner { // This isn't fantastic. Does exact layout if the column is going to be filled and distributes otherwise. val y: Double = if (depthCount < maxDepthCount) { - diagramPadding + ((diagramHeight - 2 * diagramPadding) / (depthCount + 1)) * currentDepthCount - 0.5 * tileHeight + diagramPadding + ((diagramHeight - 2 * diagramPadding) / (depthCount + 1)) * currentDepthCount + - 0.5 * tileHeight } else { (diagramPadding + (currentDepthCount - 1) * tileHeight diff --git a/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/CardBuilder.kt b/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/CardBuilder.kt index 536774c..b4fffe1 100644 --- a/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/CardBuilder.kt +++ b/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/CardBuilder.kt @@ -5,6 +5,7 @@ import java.io.InputStream /** * Builder to encapsulate the logic of laying out an image and associated text. */ +@Suppress("MagicNumber") class CardBuilder( private val position2D: Position2D, @@ -13,16 +14,33 @@ class CardBuilder( private var source: InputStream? = null private var label: String? = null + /** + * Configures the image to use for the card being built. + * + * @param source The input stream which will provide the image data + * @return The CardBuilder instance so that method calls can be chained + */ fun withImage(source: InputStream): CardBuilder { this.source = source return this } + /** + * Configures the label to use for the card being built. + * + * @param label The label text + * @return The CardBuilder instance so that method calls can be chained + */ fun withLabel(label: String): CardBuilder { this.label = label return this } + /** + * Creates the card layout and renders it using the provided renderer. + * + * @param renderer The diagram renderer to use for drawing the card + */ fun build(renderer: DiagramRenderer) { renderer.drawOutline(position2D, size2D) @@ -63,4 +81,4 @@ class CardBuilder( renderer.addImage(imagePosition, imageSize, imageSource) } -} \ No newline at end of file +} diff --git a/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/DiagramRenderer.kt b/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/DiagramRenderer.kt index 3218f6e..c84a44a 100644 --- a/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/DiagramRenderer.kt +++ b/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/DiagramRenderer.kt @@ -40,10 +40,12 @@ class DiagramRenderer( } /** - * Add an image to the diagram at the specified coordinates + * Add an image to the diagram at the specified coordinates. * - * @param positionX The offset of the left side of the image from the left side of the diagram - * @param positionY The offset of the top side of the image from the top side of the diagram + * Note that the input size will cause the image to be scaled to that size. + * + * @param position The position of the top left corner of the image from the top left of the draw space. + * @param size The size that the image should be rendered at * @param source The input stream to read the image from */ fun addImage(position: Position2D, size: Size2D, source: InputStream) { @@ -82,7 +84,7 @@ class DiagramRenderer( * Draw a string of text onto the diagram using the given font. * * @param str The text to draw - * @param fontFile The file from which to load a font for use in the rendering + * @param position The position of the top left corner of the string from the top left of the draw space. */ fun drawString(str: String, position: Position2D) { target.color = Color.DARK_GRAY @@ -90,6 +92,13 @@ class DiagramRenderer( target.drawString(str, position.x, position.y) } + /** + * Gets the dimensions that the input string will have when drawn, given the current font and + * scaling etc. + * + * @param str The string to get dimensions for + * @return The dimensions of the input string when rendered + */ fun getStringDimensions(str: String): Size2D { val fontMetrics = target.getFontMetrics(font) @@ -98,6 +107,12 @@ class DiagramRenderer( return Size2D(bounds.width.toFloat(), bounds.height.toFloat()) } + /** + * Draws an outline, which is a rectangle where only the outline is drawn. + * + * @param position The position to draw the rectangle outline at + * @param size The size of the rectangle to draw + */ fun drawOutline(position: Position2D, size: Size2D) { target.background = Color.YELLOW target.stroke = BasicStroke(1f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND) diff --git a/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/Position2D.kt b/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/Position2D.kt index a2ed0d7..5900abc 100644 --- a/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/Position2D.kt +++ b/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/Position2D.kt @@ -6,4 +6,4 @@ package org.ephyra.acropolis.report.impl.render class Position2D( val x: Float, val y: Float -) \ No newline at end of file +) diff --git a/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/Size2D.kt b/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/Size2D.kt index 83b8ea5..cad0223 100644 --- a/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/Size2D.kt +++ b/acropolis-report/src/main/kotlin/org/ephyra/acropolis/report/impl/render/Size2D.kt @@ -6,4 +6,4 @@ package org.ephyra.acropolis.report.impl.render class Size2D( val width: Float, val height: Float -) \ No newline at end of file +) diff --git a/acropolis-shell/src/main/kotlin/org/ephyra/acropolis/shell/BootstrapCommand.kt b/acropolis-shell/src/main/kotlin/org/ephyra/acropolis/shell/BootstrapCommand.kt index 535b08a..f73fd6e 100644 --- a/acropolis-shell/src/main/kotlin/org/ephyra/acropolis/shell/BootstrapCommand.kt +++ b/acropolis-shell/src/main/kotlin/org/ephyra/acropolis/shell/BootstrapCommand.kt @@ -7,11 +7,18 @@ import org.springframework.shell.standard.ShellComponent import org.springframework.shell.standard.ShellMethod import java.io.File +/** + * Bootstraps the acropolis system. + * Should be run once when the program is set up to seed the database etc. + */ @ShellComponent class BootstrapCommand { @Autowired private lateinit var graphicalAssetService: IGraphicalAssetService + /** + * Implementation of the bootstrap command + */ @ShellMethod("Bootstrap Acropolis") fun bootstrap() { println("Bootstrapping the acropolis system.") @@ -60,4 +67,4 @@ class BootstrapCommand { GraphicalAssetType.PNG ) } -} \ No newline at end of file +}