Package java.awt.font

Examples of java.awt.font.TextLayout.draw()


            TextLayout layout = new TextLayout(text, font, context);
            Rectangle2D bounds = layout.getBounds();
            g2.setColor(foreGround);
            float textX = (float) (width - bounds.getWidth()) / 2;
            y = (float) (y + layout.getLeading() + 2 * layout.getAscent());
            layout.draw(g2, textX, (float) y);
        }
        return y;
    }

    /**
 
View Full Code Here


        if (inPossibleRecursion) {
            System.err.println("Called itself: drawString(AttributedCharacterIterator)");
        } else {
            inPossibleRecursion = true;
            TextLayout layout = new TextLayout(iterator, getFontRenderContext());
            layout.draw(this, x, y);
            inPossibleRecursion = false;
        }
    }

    /**
 
View Full Code Here

        if (useDrawRotatedStringWorkaround) {
            // workaround for JDC bug ID 4312117 and others...
            final TextLayout tl = new TextLayout(text, g2.getFont(),
                    g2.getFontRenderContext());
            tl.draw(g2, textX, textY);
        }
        else {
            // replaces this code...
            g2.drawString(text, textX, textY);
        }
View Full Code Here

    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
        RenderingHints.VALUE_ANTIALIAS_ON);
    textLayout = new TextLayout(captchaText, font, graphics
        .getFontRenderContext());

    textLayout.draw(graphics, CAPTCHAConstants.TEXT_X_COORDINATE,
        CAPTCHAConstants.TEXT_Y_COORDINATE);
    }

    /*
    * A helper method to apply noise on the generated image.
View Full Code Here

            int x = r.x;
            int y = (int) (r.y + tl.getAscent());
            sh = r.y + r.height;
            while (y < sh) {
                tl.draw(g2, x, y);
                if ((x += (int) sw) > (r.x + r.width)) {
                    x = r.x;
                    y += (int) tl.getAscent();
                }
            }
View Full Code Here

        BufferedImage bi = new BufferedImage(sw, sh, BufferedImage.TYPE_INT_RGB);
        Graphics2D tG2 = bi.createGraphics();
        tG2.setBackground(GfrColor.WHITE_2);
        tG2.clearRect(0, 0, sw, sh);
        tG2.setColor(GfrColor.GRAY_8);
        tlt.draw(tG2, 0, tlt.getAscent());
        Rectangle r = new Rectangle(0, 0, sw, sh);
        return new TexturePaint(bi, r);
    }
}
View Full Code Here

                // Move y-coordinate by the ascent of the layout.
                drawPosY += layout.getAscent();

                // Draw the TextLayout at (drawPosX, drawPosY).
                layout.draw(g2d, drawPosX, drawPosY);


                // Move y-coordinate in preparation for next layout.
                drawPosY += layout.getDescent() + layout.getLeading();
            }
View Full Code Here

                    // Move y-coordinate by the ascent of the layout.
                    drawPosY += layout.getAscent();

                    // Draw the TextLayout at (drawPosX, drawPosY).
                    layout.draw(g2d, drawPosX, drawPosY);


                    // Move y-coordinate in preparation for next layout.
                    drawPosY += layout.getDescent() + layout.getLeading();
View Full Code Here

                    TextLayout layout = measurer.nextLayout(lineWidth);

                    cursor.y += (layout.getAscent());
                    float dx = layout.isLeftToRight() ? 0 : (lineWidth - layout.getAdvance());

                    layout.draw(g, cursor.x + dx, cursor.y);
                    cursor.y += layout.getDescent() + layout.getLeading();
                }
            }
        }
View Full Code Here

      g2.setColor(getForeground());
      if (layoutApplication != null) {
        layoutApplication.draw(g2, xApplication, yApplication);
      }
      if (layoutText != null) {
        layoutText.draw(g2, xText, yText);
      }
    }
  }

  /* ====================================================================== */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.