in atlas-chart/src/main/scala/com/netflix/atlas/chart/graphics/LegendEntry.scala [52:107]
override def draw(g: Graphics2D, x1: Int, y1: Int, x2: Int, y2: Int): Unit = {
if (data.isInstanceOf[MessageDef]) {
// Draw the label
val txt = Text(data.label, style = Style(data.color), alignment = TextAlignment.LEFT)
val truncated = txt.truncate(x2 - x1)
truncated.draw(g, x1, y1, x2, y2)
} else {
val d = ChartSettings.normalFontDims.height - 4
// Draw the color box for the legend entry. If the color has an alpha setting, then the
// background can impact the color so we first fill with the background color of the chart.
g.setColor(styles.background.color)
g.fillRect(x1 + 2, y1 + 2, d, d)
g.setColor(data.color)
g.fillRect(x1 + 2, y1 + 2, d, d)
// Border for the color box
styles.line.configure(g)
g.drawRect(x1 + 2, y1 + 2, d, d)
// Draw the label
val txt = Text(data.label, alignment = TextAlignment.LEFT, style = styles.text)
val truncated = txt.truncate(x2 - x1 - d - 4)
truncated.draw(g, x1 + d + 4, y1, x2, y2)
data match {
case line: LineDef if showStats =>
val stats = line.legendStats
val max = format(stats.max)
val min = format(stats.min)
val avg = format(stats.avg)
val last = format(stats.last)
val total = format(stats.total)
val count = format(stats.count, false)
val rows = List(
" Max : %-11s Min : %-11s".format(max, min),
" Avg : %-11s Last : %-11s".format(avg, last),
" Tot : %-11s Cnt : %-11s".format(total, count)
)
val offset = y1 + ChartSettings.normalFontDims.height
val rowHeight = ChartSettings.smallFontDims.height
rows.zipWithIndex.foreach {
case (row, i) =>
val txt = Text(
row,
font = ChartSettings.smallFont,
alignment = TextAlignment.LEFT,
style = styles.text
)
txt.draw(g, x1 + d + 4, offset + i * rowHeight, x2, y2)
}
case _ =>
}
}
}