private static void paintTextEffect(Graphics2D g, String s, Color c,
            int size, double tx, double ty, boolean isShadow) {

        prepareGraphics(g);

        final float opacity = 0.8f; // Effect "darkness".
        final Composite oldComposite = g.getComposite();
        final Color oldColor = g.getColor();

        // Use a alpha blend smaller than 1 to prevent the effect from becoming
        // too dark when multiple paints occur on top of each other.
        float preAlpha = 0.4f;
        if (oldComposite instanceof AlphaComposite
                && ((AlphaComposite) oldComposite).getRule() == AlphaComposite.SRC_OVER) {
            preAlpha = Math.min(((AlphaComposite) oldComposite).getAlpha(),
                    preAlpha);
        }
        g.setColor(c);

        g.translate(tx, ty);

        // If the effect is a shadow it looks better to stop painting a bit to
        // early... (shadow will look softer).
        int maxSize = isShadow ? size - 1 : size;

        for (int i = -size; i <= maxSize; i++) {
            for (int j = -size; j <= maxSize; j++) {
                double distance = i * i + j * j;
                float alpha = opacity;
                if (distance > 0.0d) {
                    alpha = (float) (1.0f / ((distance * size) * opacity));
                }
                alpha *= preAlpha;
                if (alpha > 1.0f) {
                    alpha = 1.0f;
                }
                g.setComposite(AlphaComposite.getInstance(
                        AlphaComposite.SRC_OVER, alpha));
                g.drawString(s, i + size, j + size);
            }
        }

        // Restore graphics
        g.translate(-tx, -ty);
        g.setComposite(oldComposite);
        g.setColor(oldColor);

        g.drawString(s, 0, 0);
    }