in atlas-chart/src/main/scala/com/netflix/atlas/chart/graphics/HeatmapLegendEntry.scala [46:96]
override def draw(g: Graphics2D, x1: Int, y1: Int, x2: Int, y2: Int): Unit = {
// Label
val label = data.settings.label.getOrElse("Heatmap")
val txt = Text(label, alignment = TextAlignment.LEFT, style = styles.text)
val truncated = txt.truncate(x2 - x1)
truncated.draw(g, x1, y1, x2, y2)
if (showStats) {
// Color scale
val colors = data.palette.colorArray
val offset = y1 + ChartSettings.normalFontDims.height
// Indent to line up with stats for a normal line
val d = ChartSettings.normalFontDims.height - 4
val indent = ChartSettings.smallFontDims.width * 4 + d + 4
// Width of color scale should match the legend stats
val scaleWidth = ChartSettings.smallFontDims.width * 38
val w = scaleWidth / colors.length
// Color boxes
g.setColor(Color.WHITE)
g.fillRect(x1 + indent, offset, w * colors.length, d)
var i = 0
while (i < colors.length) {
g.setColor(colors(i))
g.fillRect(x1 + indent + i * w, offset, w, d)
i += 1
}
// Axis lines
styles.line.configure(g)
g.drawLine(x1 + indent, offset + d, x1 + indent + w * colors.length, offset + d)
// Vertical ticks for color axis
val txtW = Math.max(w, ChartSettings.smallFontDims.width * 7)
val spaceForTicks = w >= txtW
val colorTicks = data.colorTicks
i = 0
while (i < colorTicks.length) {
val x = x1 + indent + w * i
styles.line.configure(g)
g.drawLine(x, offset + d, x, offset + d + 4)
if (spaceForTicks || i == 0 || i == colorTicks.length - 1) {
// If space is limited, only show lables for first and last tick
drawLabel(g, x, offset + d + 4, txtW, colorTicks(i).label)
}
i += 1
}
}
}