String heading = separator.getHeading();
if (heading != null
&& heading.length() > 0) {
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
LineMetrics lm = font.getLineMetrics(heading, fontRenderContext);
graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
fontRenderContext.getAntiAliasingHint());
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
fontRenderContext.getFractionalMetricsHint());
graphics.setFont(font);
graphics.setPaint(headingColor);
graphics.drawString(heading, padding.left, lm.getAscent() + padding.top);
Rectangle2D headingBounds = font.getStringBounds(heading, fontRenderContext);
Area titleClip = new Area(graphics.getClip());
titleClip.subtract(new Area(new Rectangle2D.Double(padding.left, padding.top,
headingBounds.getWidth() + padding.right, headingBounds.getHeight())));
graphics.clip(titleClip);
separatorY += (lm.getAscent() + lm.getDescent()) / 2 + 1;
}
graphics.setStroke(new BasicStroke(thickness));
graphics.setColor(color);
graphics.drawLine(0, separatorY, width, separatorY);