final String text = panel.getText();
if(text == null || text.length() == 0)
return;
final ScreenableStyle style = panel.getStyle();
graphics.setColor(style.getCompiledTextColor().getColor());
TextLayout textLayout = new TextLayout(text, Fonts.fromStyle(style), TextPanel.getRenderContext());
int height = (int) ((textLayout.getAscent() + textLayout.getDescent() + textLayout.getLeading()) + 0.5);
int width = (int) (textLayout.getBounds().getWidth() + textLayout.getBounds().getX() + 0.5);
final Dimension textDimensions = new Dimension(width, height);
int textX = style.getCompiledHorizontalAlignment().getX(textDimensions.width, panel.getBounds());
float textY = style.getCompiledVerticalAlignment().getY(textDimensions.height, panel.getBounds()) + textLayout.getAscent();
textLayout.draw(graphics, textX, textY + 1);
}