public class GraphicsUtil
extends java.lang.Object
| 构造器和说明 |
|---|
GraphicsUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static java.awt.Graphics2D |
createGraphics(java.awt.image.BufferedImage bufferedImage,
java.awt.Color backgroundColor)
创建绘笔公爵
|
static java.awt.Graphics |
drawStr(java.awt.Graphics graphics,
java.lang.String str,
java.awt.Font font,
java.awt.Color color,
int width,
int height,
java.awt.Color backgroundColor)
图片绘制指定字符串
|
static int |
getCenterYHeight(java.awt.Graphics graphics,
int backgroundImageHeight)
获取内容居中高度的Y轴坐标
|
static int |
getCharWidth(java.awt.Graphics graphics,
java.lang.String str,
java.awt.Font font)
获取该字符串在对应字体下占用的宽度
|
static int |
getFontHeight(java.awt.Graphics graphics,
java.awt.Font font)
获取对应字体的一行文本高度
|
static java.awt.geom.AffineTransform |
getRotation(int degree,
int x,
int y)
获取旋转参数
|
static Point |
randomStrPosition(java.awt.Graphics graphics,
java.lang.String str,
java.awt.Font font,
int width,
int height)
随机获取字符所在画板的位置
|
static void |
setAlphaComposite(java.awt.Graphics2D graphics2D,
java.awt.AlphaComposite alphaComposite) |
public static java.awt.Graphics2D createGraphics(java.awt.image.BufferedImage bufferedImage,
java.awt.Color backgroundColor)
bufferedImage - 图片bufferbackgroundColor - 背景颜色public static java.awt.Graphics drawStr(java.awt.Graphics graphics,
java.lang.String str,
java.awt.Font font,
java.awt.Color color,
int width,
int height,
java.awt.Color backgroundColor)
graphics - 绘笔对象str - 需要绘制的字符串font - 字体color - 字体颜色,颜色可以为空,为空每个字符的颜色进行随机width - 图片的宽度height - 图片的高度backgroundColor - 图片背景颜色public static Point randomStrPosition(java.awt.Graphics graphics, java.lang.String str, java.awt.Font font, int width, int height)
graphics - 绘笔对象str - 将要输入的字符font - 字体width - 宽度(图片宽度,x轴)height - 图片高度(图片高度,y轴)public static int getCenterYHeight(java.awt.Graphics graphics,
int backgroundImageHeight)
graphics - 绘笔对象backgroundImageHeight - 图片的高度public static void setAlphaComposite(java.awt.Graphics2D graphics2D,
java.awt.AlphaComposite alphaComposite)
public static int getFontHeight(java.awt.Graphics graphics,
java.awt.Font font)
graphics - 画笔对象font - 字体public static int getCharWidth(java.awt.Graphics graphics,
java.lang.String str,
java.awt.Font font)
graphics - 画笔对象str - 对应的字符串font - 字体public static java.awt.geom.AffineTransform getRotation(int degree,
int x,
int y)
degree - 旋转度数,0 ~ 360x - 旋转圆心的x轴坐标y - 旋转圆心的y轴坐标