Skip to content

Commit

Permalink
#19 display text
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Oct 27, 2018
1 parent abc7fd3 commit 2d5a2d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ spring-shell.log
.idea/*
*.log

user
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package org.ephyra.acropolis.report.impl.render

import java.awt.BasicStroke
import java.awt.Color
import java.awt.Font
import java.awt.Graphics2D
import java.awt.Polygon
import java.awt.image.BufferedImage
import java.awt.image.BufferedImage.TYPE_INT_RGB
import java.io.File
import java.lang.IllegalStateException
import javax.imageio.ImageIO

class DiagramRenderer(
Expand Down Expand Up @@ -48,6 +50,18 @@ class DiagramRenderer(
target.drawPolygon(polygon)
}

fun drawString(str: String, fontFile: File) {
if (fontFile.extension != "ttf") {
throw IllegalStateException("Cannot use a font which is not TTF")
}

target.color = Color.DARK_GRAY
var font = Font.createFont(Font.TRUETYPE_FONT, fontFile)
font = font.deriveFont(target.font.size * 2f)
target.font = font
target.drawString(str, 100, 100)
}

override fun close() {
target.dispose()
}
Expand Down

0 comments on commit 2d5a2d2

Please sign in to comment.