| Constructor and Description |
|---|
Graphics() |
| Modifier and Type | Method and Description |
|---|---|
static Graphics2D |
createGraphics(BufferedImage image,
Color color)
|
static Graphics |
drawString(Graphics g,
String str,
Font font,
Color color,
int width,
int height)
绘制字符串,默认抗锯齿
|
static Graphics |
drawStringColourful(Graphics g,
String str,
Font font,
int width,
int height)
绘制字符串,使用随机颜色,默认抗锯齿
|
static int |
getCenterY(Graphics g,
int backgroundHeight)
获取文字居中高度的Y坐标(距离上边距距离)
此方法依赖FontMetrics,如果获取失败,默认为背景高度的1/3 |
public static Graphics2D createGraphics(BufferedImage image, Color color)
image - BufferedImagecolor - Color背景颜色以及当前画笔颜色,null表示不设置背景色Graphics2Dpublic static int getCenterY(Graphics g, int backgroundHeight)
g - Graphics2D画笔backgroundHeight - 背景高度public static Graphics drawStringColourful(Graphics g, String str, Font font, int width, int height)
g - Graphics画笔str - 字符串font - 字体width - 字符串总宽度height - 字符串背景高度Copyright © 2019. All rights reserved.