Package java.awt

Examples of java.awt.Graphics2D.drawString()


      // String rand = String.valueOf(random2Char(random.nextInt(62)));
      String rand = String.valueOf(random.nextInt(10));
      sRand += rand;
      // 将认证码显示到图象中,调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
      g.setColor(new Color(20 + random.nextInt(130), 20 + random.nextInt(130), 20 + random.nextInt(130))); // --4--50-100
      g.drawString(rand, (13 * i) + 6, 16);
    }
    // 将认证码存入SESSION
    request.getSession().setAttribute(Constants_core.RANDOM_CHECKCODE, sRand);
    // System.out.println("checkcode:"+sRand);
    // 图象生效
View Full Code Here


                charGraphics.translate(-halfCharDim, -halfCharDim);
                charGraphics.setColor(textColor);
                charGraphics.setFont(textFont);

                int charX = (int) (0.5 * charDim - 0.5 * charWidth);
                charGraphics.drawString("" + captchaCode.charAt(i), charX,
                        ((charDim - fontMetrics.getAscent()) / 2 + fontMetrics.getAscent()));

                float x = horizMargin + spacePerChar * (i) - charDim / 2.0f;
                int y = ((height - charDim) / 2);

View Full Code Here

    {
      if (box.getPoolSize() > 0)
      {
        final Graphics2D graphics1 = getGraphics();
        graphics1.setFont(new Font("Serif", Font.PLAIN, 10)); // NON-NLS
        graphics1.drawString("Your box is too small ...", // NON-NLS : TODO _ Change the way we handle this case
            (int) StrictGeomUtility.toExternalValue(box.getX()),
            (int) StrictGeomUtility.toExternalValue(box.getY()) + 10);
      }
    }
    else
View Full Code Here

      final float baseLine = lineMetrics.getAscent();
      final float iconWidth = icon.getIconWidth();
      final float textX = insets.left + gap + iconWidth;
      final float iconHeight = icon.getIconHeight();
      final float textY = insets.top + baseLine + (iconHeight - lineMetrics.getHeight());
      g2.drawString(text, textX, textY);
    }
    else if (icon != null)
    {
      icon.paintIcon(this, g2, insets.left, insets.top);
    }
View Full Code Here

      final FontMetrics fontMetrics = g2.getFontMetrics();
      final LineMetrics lineMetrics = fontMetrics.getLineMetrics(text, g2);
      final float baseLine = lineMetrics.getAscent();
      final int textX = insets.left;
      final float textY = insets.top + baseLine;
      g2.drawString(text, textX, textY);
    }

    final Border border = getBorder();
    if (border != null)
    {
View Full Code Here

    graphics2D.fill(bounds);
    graphics2D.setFont(font);
    graphics2D.setColor(foreground);
    if (value == null)
    {
      graphics2D.drawString("Subreport", 0, font.getSize2D());
    }
    else
    {
      graphics2D.drawString(String.valueOf(value), 0, font.getSize2D());
    }
View Full Code Here

    {
      graphics2D.drawString("Subreport", 0, font.getSize2D());
    }
    else
    {
      graphics2D.drawString(String.valueOf(value), 0, font.getSize2D());
    }
    graphics2D.dispose();
  }

  /**
 
View Full Code Here

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    if (rotate == RotateTextIcon.NONE)
    {
      g2d.drawString(text, 2, ascent);
    }
    else if (rotate == RotateTextIcon.CW)
    {
      final AffineTransform trans = new AffineTransform();
      trans.concatenate(oldTransform);
View Full Code Here

      final AffineTransform trans = new AffineTransform();
      trans.concatenate(oldTransform);
      trans.translate(0, 2);
      trans.rotate(Math.PI / 2, height / 2, width / 2);
      g2d.setTransform(trans);
      g2d.drawString(text, (height - width) / 2, (width - height) / 2 + ascent);
    }
    else if (rotate == RotateTextIcon.CCW)
    {
      final AffineTransform trans = new AffineTransform();
      trans.concatenate(oldTransform);
View Full Code Here

      final AffineTransform trans = new AffineTransform();
      trans.concatenate(oldTransform);
      trans.translate(0, -2);
      trans.rotate(Math.PI * 3 / 2, height / 2, width / 2);
      g2d.setTransform(trans);
      g2d.drawString(text, (height - width) / 2, (width - height) / 2 + ascent);
    }

    return new ImageIcon(bufferedImage);
  }

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.