Console: Tweak graph title placement

This commit is contained in:
zzz
2024-05-17 13:30:47 -04:00
parent e479e187da
commit aedb7cd19a

View File

@@ -264,8 +264,12 @@ public class RrdGraph implements RrdGraphConstants {
if (!gdef.onlyGraph) {
worker.setTextAntiAliasing(gdef.textAntiAliasing);
if (gdef.title != null) {
int x = im.xgif / 2 - (int) (worker.getStringWidth(gdef.title, gdef.getFont(FONTTAG_TITLE)) / 2);
int y = PADDING_TOP + (int) worker.getFontAscent(gdef.getFont(FONTTAG_TITLE));
// I2P truncate on the right only
//int x = im.xgif / 2 - (int) (worker.getStringWidth(gdef.title, gdef.getFont(FONTTAG_TITLE)) / 2);
int x = Math.max(2, im.xgif / 2 - (int) (worker.getStringWidth(gdef.title, gdef.getFont(FONTTAG_TITLE)) / 2));
// I2P a little less padding on top and more on the bottom
//int y = PADDING_TOP + (int) worker.getFontAscent(gdef.getFont(FONTTAG_TITLE));
int y = PADDING_TOP * 2 / 3 + (int) worker.getFontAscent(gdef.getFont(FONTTAG_TITLE));
worker.drawString(gdef.title, x, y, gdef.getFont(FONTTAG_TITLE), gdef.getColor(ElementsNames.font));
}
if (gdef.verticalLabel != null) {