Java Draw String drawStringLeft(Graphics2D g, String text, Rectangle rect, int fontHeight, Color c)

Here you can find the source of drawStringLeft(Graphics2D g, String text, Rectangle rect, int fontHeight, Color c)

Description

draw String Left

License

Open Source License

Declaration

public static void drawStringLeft(Graphics2D g, String text, Rectangle rect, int fontHeight, Color c) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Color;
import java.awt.Font;

import java.awt.Graphics2D;
import java.awt.Rectangle;

public class Main {
    public static void drawStringLeft(Graphics2D g, String text, Rectangle rect, int fontHeight, Color c) {
        Font f = new Font("Serif", Font.PLAIN, fontHeight);
        g.setFont(f);//from   w w  w  .  j av a2 s.  c  om
        g.setColor(c);
        g.drawString(text, rect.x, rect.y + rect.height);
    }

    public static void drawStringLeft(Graphics2D g, String text, int x, int y, int fontHeight, Color c) {
        drawStringLeft(g, text, x, y, fontHeight, c, false);
    }

    public static void drawStringLeft(Graphics2D g, String text, int x, int y, int fontHeight, Color c,
            boolean bold) {
        Font f = new Font("Serif", bold ? Font.BOLD : Font.PLAIN, fontHeight);
        g.setFont(f);
        g.setColor(c);
        g.drawString(text, x, y);
    }
}

Related

  1. drawStringAlignCenter(Graphics2D g2d, String s, int x, int y)
  2. drawStringAt(Graphics g, String t, int x, int y, int where)
  3. drawStringAtPoint(Graphics g, String s, Point p)
  4. drawStringEx(Graphics g1, String s, Font font, Rectangle rect, int align, int valign)
  5. drawStringInBox(Graphics g, String string, int x, int y)
  6. drawStringOnImage(Image image, String string, int x, int y)
  7. drawStringOnScreen(String s, Color color, long milseconds)
  8. drawStringPair(Graphics2D g, String str1, String str2, int left, int right, int y, int size, Color color, boolean bold)
  9. drawStringRight(final Graphics g, final FontMetrics m, final String str, final int x, final int y)