Package java.awt.font

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


        public void runTest(Object ctx, int numReps) {
            TLContext tlctx = (TLContext)ctx;
            Graphics2D g2d = tlctx.g2d;
            TextLayout tl = tlctx.tl;
            do {
                tl.draw(g2d, 40, 40);
            } while (--numReps >= 0);
        }
    }
}
View Full Code Here


    public void paint(Graphics g) {
        super.paint(g);
        g.setColor(getForeground());
        TextLayout layout = composedTextLayout;
        if (layout != null) {
            layout.draw((Graphics2D) g, TEXT_ORIGIN_X, TEXT_ORIGIN_Y);
        }
        if (caret != null) {
            Rectangle rectangle = getCaretRectangle(caret);
            g.setXORMode(getBackground());
            g.fillRect(rectangle.x, rectangle.y, 1, rectangle.height);
View Full Code Here

   * @see Graphics2D#drawString(AttributedCharacterIterator, float, float)
   */
  public void drawString(AttributedCharacterIterator iterator, float x, float y)
  {
    TextLayout layout = new TextLayout(iterator, getFontRenderContext());
        layout.draw(this, x, y);
  }

  /**
   * Renders the specified string as a series of AWT shapes, created using a
   * glyph vector. The glyphs are converted a single outline and then rendered as closed SWF
View Full Code Here

            g2.setColor(bgColor);
            g2.fillRect(getOffsetX(pos) + center.getX() - 6, getOffsetY(pos) + center.getY() - 5, 12 + (int)bounds.getWidth(),10 +(int) bounds.getHeight());
        }

        g2.setColor(fgColor);
        tl.draw(g2, getOffsetX(pos) + center.getX(),  getOffsetY(pos) + center.getY() + (int) bounds.getHeight());
        g2.setColor(original);
    }

}
View Full Code Here

                           int x, int y) {
        if (iterator == null) {
            throw new NullPointerException("AttributedCharacterIterator is null");
        }
        TextLayout tl = new TextLayout(iterator, getFontRenderContext());
        tl.draw(this, (float) x, (float) y);
    }

    public void drawString(AttributedCharacterIterator iterator,
                           float x, float y) {
        if (iterator == null) {
View Full Code Here

                           float x, float y) {
        if (iterator == null) {
            throw new NullPointerException("AttributedCharacterIterator is null");
        }
        TextLayout tl = new TextLayout(iterator, getFontRenderContext());
        tl.draw(this, x, y);
    }

    public void drawGlyphVector(GlyphVector gv, float x, float y)
    {
        if (gv == null) {
View Full Code Here

      Rectangle2D rectangle = textLayout.getBounds();
      int height = (int) rectangle.getHeight();
      int top = Math.abs((height - CaptchaImage.HEIGHT));

      graphics.setColor(this.getFontColor());
      textLayout.draw(graphics, left, top);
      left += 20;
    }
  }

  private int getWidth() {
View Full Code Here

            if (text != null && text.length() > 0) {
                FontRenderContext context = g2.getFontRenderContext();
                TextLayout layout = new TextLayout(text, getFont(), context);
                Rectangle2D bounds = layout.getBounds();
                g2.setColor(getForeground());
                layout.draw(g2, (float) (frameWidth - bounds.getWidth()) / 2,
                        (float) (maxY + layout.getLeading() + 2 * layout.getAscent()));
            }
        }
    }

View Full Code Here

        graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);

        textLayout.draw(graphics, 0, 0);

        int absciss = calculateAbsciss(image);
        int ordinate = calculateOrdinate(image);

        BufferedImage croppedImage = image.getSubimage(absciss - 1, ordinate - 1, (int) textWidth + 2, (int) textHeight + 2);
View Full Code Here

            float ascent = textLayout.getAscent();
            textY += ascent; // Move down to baseline.

            g2d.setColor(glowColor);
            g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
            textLayout.draw(g2d, textX + glowSize / 2 + 1, textY + glowSize / 2 - 1);
            textLayout.draw(g2d, textX + glowSize / 2 + 1, textY + glowSize / 2 + 1);
            textLayout.draw(g2d, textX + glowSize / 2 - 1, textY + glowSize / 2 - 1);
            textLayout.draw(g2d, textX + glowSize / 2 - 1, textY + glowSize / 2 + 1);

            g2d.setColor(getForeground());
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.