Package java.awt

Examples of java.awt.Graphics2D.drawString()


                FontRenderContext frc1 = new FontRenderContext(null, true, true);
                Rectangle2D rec = font.getStringBounds(coverScreenData.getMessage(), frc1);
                int w = (int) (rec.getWidth());
                int h = (int) (rec.getHeight());
                g2d.setFont(font);
                g2d.drawString(coverScreenData.getMessage()
                    , (getWidth()/2)-(w/2), getHeight()-(h)+10  );
            }
            Insets insets = getInsets();
            Dimension size = closeIcon.getPreferredSize();
            closeIcon.setBounds((int) (getWidth()-size.width) + insets.left, insets.top,
View Full Code Here


            // draw each word in order from top to bottom, centered in row
            for (int i = 0; i < words.length; i++) {
                Rectangle2D stringBounds = metrics.getStringBounds(words[i], g2);
                x = (int) (iw / 2 - stringBounds.getWidth() / 2);
                g2.drawString(words[i], x, y + wh);
                y += wh + rowGap;
            }

            g2.dispose();
        }
View Full Code Here

                FontRenderContext frc1 = new FontRenderContext(null, true, true);
                Rectangle2D rec = font.getStringBounds(coverScreenData.getMessage(), frc1);
                int w = (int) (rec.getWidth());
                int h = (int) (rec.getHeight());
                g2d.setFont(font);
                g2d.drawString(coverScreenData.getMessage()
                    , (getWidth()/2)-(w/2), getHeight()-(h)+10  );
            }
            Insets insets = getInsets();
            Dimension size = closeIcon.getPreferredSize();
            closeIcon.setBounds((int) (getWidth()-size.width) + insets.left, insets.top,
View Full Code Here

      Graphics2D charGraphics = charImage.createGraphics();
      charGraphics.setRenderingHints(g2d.getRenderingHints());

      charGraphics.setFont(font);
      charGraphics.setColor(Color.WHITE);
      charGraphics.drawString(c, 0, baseline);

      charGraphics.dispose();
      pack.addImage(charImage);
    }
    pack.pack(TexturePack.ALPHA_USE);
View Full Code Here

      float alpha = clarity;
      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,
          alpha));

      // 第一参数->设置的内容,后面两个参数->文字在图片上的坐标位置(x,y) .
      g.drawString(logoText, width, height);

      g.dispose();

      os = new FileOutputStream(targerPath);
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

    else
      direction = TextAttribute.RUN_DIRECTION_RTL;

    as.addAttribute(TextAttribute.RUN_DIRECTION, direction);

    g2.drawString(as.getIterator(), x, y);

    //
    // paint the mnemonic if necessary
    //
    if ((mnemonicIndex >= 0) && (mnemonicIndex < paintText.length()))
View Full Code Here

                    g2.draw(s);
                }
            }
           
            g2.setPaint(Color.black);
            g2.drawString(String.format("%.2f s", duration / 1e3), w - 40, h - 5);
        }       
       
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(150, 150);
View Full Code Here

            g2d.drawRoundRect(heldRectX, heldRectY, heldRectWidth, heldRectHeight, heldRectRadius, heldRectRadius);

            // Draw 'held' text
            g2d.setFont(heldFont);
            g2d.setColor(Color.white);
            g2d.drawString(heldText, heldTextX, heldTextY);
        }
    }

    /**
     * Calculates the dimensions needed for rendering the held-mode highlighting
View Full Code Here

          graphics.setFont(getFont().deriveFont(Font.BOLD, 33f));
          graphics.rotate(.3);
          graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .7f));
          final String str = "Work in progress ...";
          final int strWidth = SwingUtilities.computeStringWidth(getFontMetrics(getFont()), str);
          graphics.drawString(str, getSize().width / 2 - strWidth / 2, 10);
          graphics.dispose();
        }
      };
      _markUpPanel.setBorder(BorderFactory.createTitledBorder("Annotation/MarkUp Settings"));
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.