afreechart/src/main/java/org/afree/chart/text/TextFragment.java
/**
     * Calculates the vertical offset between the baseline and the specified
     * text anchor.
     * 
     * @param anchor
     *            the anchor.
     * 
     * @return the offset.
     */
Calculates the vertical offset between the baseline and the specified
text anchor.

@param anchor
the anchor.

@return the offset.
Calculates the vertical offset between the baseline and the specified text anchor . @param anchor the anchor . @return the offset .
public float calculateBaselineOffset(final TextAnchor anchor) {
        float result = 0.0f;
        Paint paint = PaintUtility.createPaint(Paint.ANTI_ALIAS_FLAG, paintType, font);
        final FontMetrics fm = paint.getFontMetrics();
        if (anchor == TextAnchor.TOP_LEFT || anchor == TextAnchor.TOP_CENTER
                                          || anchor == TextAnchor.TOP_RIGHT) {
            result = Math.abs(fm.ascent);
        }
        else if (anchor == TextAnchor.BOTTOM_LEFT 
                || anchor == TextAnchor.BOTTOM_CENTER
                || anchor == TextAnchor.BOTTOM_RIGHT) {
            result = -Math.abs(fm.descent) - Math.abs(fm.leading);
        }
        return result;
    }
public float calculateBaselineOffset ( final TextAnchor anchor ) { float result = 0.0f ; Paint paint = PaintUtility . createPaint ( Paint . ANTI_ALIAS_FLAG , paintType , font ) ; final FontMetrics fm = paint . getFontMetrics ( ) ; if ( anchor == TextAnchor . TOP_LEFT || anchor == TextAnchor . TOP_CENTER || anchor == TextAnchor . TOP_RIGHT ) { result = Math . abs ( fm . ascent ) ; } else if ( anchor == TextAnchor . BOTTOM_LEFT || anchor == TextAnchor . BOTTOM_CENTER || anchor == TextAnchor . BOTTOM_RIGHT ) { result = - Math . abs ( fm . descent ) - Math . abs ( fm . leading ) ; } return result ; }
Calculates the vertical offset between the baseline and the specified
 text anchor.
Calculates the vertical offset between the baseline and the specified text anchor .