Font maxFont = getMaxFont(attributedWord.getIterator()); Rectangle2D bounds = getTextBoundaries(pie, maxFont, attributedWord); int[] randomDeviation = getRandomDeviation(background, bounds, maxFont);  pie.drawString(attributedWord.getIterator(), randomDeviation[0], randomDeviation[1]); pie.dispose();
ChangeableAttributedString newAttrString = new ChangeableAttributedString(g2, attributedString);   newAttrString.useMinimumSpacing(kerning);  newAttrString.moveToRandomSpot(background);  newAttrString.drawString(g2);  g2.dispose();
    public BufferedImage pasteText(final BufferedImage background,                                   final AttributedString attributedWord)    {        BufferedImage out = copyBackground(background);        Graphics2D pie = pasteBackgroundAndSetTextColor(out, background);        //set font to max in order to retrieve the correct boundaries        Font maxFont = getMaxFont(attributedWord.getIterator());        Rectangle2D bounds = getTextBoundaries(pie, maxFont, attributedWord);        int[] randomDeviation = getRandomDeviation(background, bounds, maxFont);        //draw the string        pie.drawString(attributedWord.getIterator(),                randomDeviation[0], randomDeviation[1]);        pie.dispose();        return out;    }