int xdev = new Double((1 + myRandom.nextDouble()) * 0.25 * maxFont.getSize()).intValue(); int ydev = new Double((1 + myRandom.nextDouble()) * 0.2 * maxFont.getSize()).intValue();
newAttrString.useMinimumSpacing(kerning);  Point2D firstTextStartingPoint = newAttrString.moveToRandomSpot(background);  newAttrString.drawString(g2);
    public BufferedImage pasteText(final BufferedImage background,                                   final AttributedString attributedWord)            throws CaptchaException    {        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);        //evaluate the max deviation        Double maxx = new Double(background.getWidth()                - bounds.getWidth());        Double maxy = new Double(background.getHeight()                - bounds.getHeight() - 0.4 * maxFont.getSize());        if (maxx.intValue() < 0 || maxy.intValue() < 0)            throw new CaptchaException("word is too big, " +                    "try to use less letters," +                    "smaller font or bigger background");        //evaluate the first to second deviation        int xdev = new Double((1 + myRandom.nextDouble())                * 0.25 * maxFont.getSize()).intValue();        int ydev = new Double((1 + myRandom.nextDouble())                * 0.2 * maxFont.getSize()).intValue();        //evaluate the random deviation        int x = myRandom.nextInt(maxx.intValue() - xdev);        //don't forget y goes down!        int y = maxFont.getSize() + myRandom.nextInt(maxy.intValue() - ydev);        //draw the string        pie.drawString(attributedWord.getIterator(), x, y);        // draw the second one        pie.drawString(attributedWord.getIterator(), x + xdev, y + ydev);        pie.dispose();        return out;    }