Skip to content

Commit

Permalink
#19 Fixing detect issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Nov 14, 2018
1 parent 9b1fa61 commit 3406096
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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)

Expand Down Expand Up @@ -63,4 +81,4 @@ class CardBuilder(

renderer.addImage(imagePosition, imageSize, imageSource)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -82,14 +84,21 @@ 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
target.font = font
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)

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ package org.ephyra.acropolis.report.impl.render
class Position2D(
val x: Float,
val y: Float
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ package org.ephyra.acropolis.report.impl.render
class Size2D(
val width: Float,
val height: Float
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -60,4 +67,4 @@ class BootstrapCommand {
GraphicalAssetType.PNG
)
}
}
}

0 comments on commit 3406096

Please sign in to comment.