public class GraphHelper
extends java.lang.Object
限定符和类型 | 方法和说明 |
---|---|
static void |
applyRenderingHints(java.awt.Graphics g)
使用系统默认的渲染方式
|
static java.awt.image.BufferedImage |
createBufferedImageFromImage(java.awt.Image image)
将Image对象转为BufferedImage
|
static java.awt.image.BufferedImage |
createBufferedImageFromImageWithLayout(java.awt.Image image,
int width,
int height,
Style style)
从图片中创建一张不带布局的图片
|
static void |
draw(java.awt.Graphics g,
java.awt.Shape shape)
Draw a shape
|
static void |
draw(java.awt.Graphics g,
java.awt.Shape shape,
int lineStyle)
Draw a shape with line style.
|
static void |
drawArc(java.awt.Graphics g,
double x,
double y,
double width,
double height,
double startAngle,
double arcAngle)
Draw a circular or elliptical arc covering the specified rectangle.
|
static void |
drawArc(java.awt.Graphics g,
double x,
double y,
double width,
double height,
double startAngle,
double arcAngle,
int lineStyle)
Draw a circular or elliptical arc covering the specified rectangle.
|
static void |
drawLine(java.awt.Graphics g,
double x1,
double y1,
double x2,
double y2)
Draw a thin line.
|
static void |
drawLine(java.awt.Graphics g,
double x1,
double y1,
double x2,
double y2,
int lineStyle)
Draw a line according to type.
|
static void |
drawRect(java.awt.Graphics g,
double x,
double y,
double width,
double height)
Draw the specified rectangle.
|
static void |
drawRect(java.awt.Graphics g,
double x,
double y,
double width,
double height,
int lineStyle)
Draw the specified rectangle.
|
static void |
drawRotatedString(java.awt.Graphics g,
java.lang.String str,
double x,
double y,
int rotation)
画旋转字体.
|
static void |
drawRotatedString(java.awt.Graphics g,
java.lang.String str,
double x,
double y,
int rotation,
double scale)
Draw rotated string.
|
static void |
drawString(java.awt.Graphics g,
java.lang.String str,
double x,
double y)
Draw string.
|
static void |
drawString2(java.awt.Graphics g,
java.lang.String str,
double x,
double y,
int width)
画字符串.
|
static void |
fill(java.awt.Graphics g,
java.awt.Shape shape)
填充区域
|
static void |
fillArc(java.awt.Graphics g,
double x,
double y,
double width,
double height,
double startAngle,
double arcAngle)
填充弧形区域
|
static void |
fillRect(java.awt.Graphics g,
double x,
double y,
double width,
double height)
填充矩形区域
|
static java.awt.FontMetrics |
getFontMetrics(java.awt.Font font)
Do not create new FontMetrics object every time.
|
static java.awt.FontMetrics |
getFontMetrics(java.awt.Font font,
java.awt.Graphics2D g2d)
获得字体规格属性.
|
static int |
getLineStyleSize(int lineStyle)
Return the size of line style.
|
static int |
getLocTextWidth(java.lang.String key)
已过时。
|
static int |
getLocTextWidth(java.lang.String key,
java.awt.Font font)
已过时。
|
static java.awt.Stroke |
getStroke(int lineStyle)
Create a stroke object from a line style.
|
static int |
getWidth(java.lang.String value) |
static int |
getWidth(java.lang.String value,
java.awt.Font font) |
static void |
paintImage(java.awt.Graphics g,
int width,
int height,
java.awt.Image image,
int layout,
int hAlign,
int vAlign,
int specifiedImageWidth,
int specifiedImageHeight)
Paint Image according to its layout and style
|
static void |
paintImage(java.awt.Graphics g,
int width,
int height,
java.awt.Image image,
int layout,
int hAlign,
int vAlign,
int specifiedImageWidth,
int specifiedImageHeight,
boolean isNotSupportARGB)
默认非移动初始位置 初始高度偏移0, 初始宽度偏移0, 图片paint
|
static void |
paintImageMoved(java.awt.Graphics g,
int width,
int height,
java.awt.Image image,
int layout)
将图片绘制到画板上
|
static void |
paintImageMoved(java.awt.Graphics g,
int width,
int height,
java.awt.Image image,
int layout,
int hAlign,
int vAlign,
int specifiedImageWidth,
int specifiedImageHeight,
int moveWidth,
int moveHeight,
boolean isNotSupportARGB)
默认背景白色的 图片paint
|
static void |
paintImageMoved(java.awt.Graphics g,
int width,
int height,
java.awt.Image image,
int layout,
int hAlign,
int vAlign,
int specifiedImageWidth,
int specifiedImageHeight,
int moveWidth,
int moveHeight,
boolean isNotSupportARGB,
java.awt.Color backgroundcolor)
Paint Image according to its layout and style
|
static void |
setStroke(java.awt.Graphics2D g2d,
java.awt.Stroke stroke)
Set stroke.
|
static java.awt.geom.Dimension2D |
stringDimensionWithRotation(java.lang.String string,
java.awt.Font font,
int rotation,
java.awt.font.FontRenderContext fontRenderContext)
将旋转的字符串转为矩形区域
|
static double |
stringWidth(java.lang.String string,
java.awt.Font font,
java.awt.font.FontRenderContext fontRenderContext)
获取字符宽度
|
public static void draw(java.awt.Graphics g, java.awt.Shape shape)
g
- the graphics.shape
- the shape to be rendered.public static void draw(java.awt.Graphics g, java.awt.Shape shape, int lineStyle)
g
- the graphics.shape
- the shape to be rendered.lineStyle
- the line style of rectangle.public static void drawLine(java.awt.Graphics g, double x1, double y1, double x2, double y2)
g
- the graphics.x1
- line start xy1
- line start yx2
- line end xy2
- line end ypublic static void drawLine(java.awt.Graphics g, double x1, double y1, double x2, double y2, int lineStyle)
public static void drawRect(java.awt.Graphics g, double x, double y, double width, double height)
x
- the x coordinate of the rectangle to be drawn.y
- the y coordinate of the rectangle to be drawn.width
- the width of the rectangle to be drawn.height
- the height of the rectangle to be drawn.public static void drawRect(java.awt.Graphics g, double x, double y, double width, double height, int lineStyle)
x
- the x coordinate of the rectangle to be drawn.y
- the y coordinate of the rectangle to be drawn.width
- the width of the rectangle to be drawn.height
- the height of the rectangle to be drawn.lineStyle
- the line style of rectangle.public static void drawArc(java.awt.Graphics g, double x, double y, double width, double height, double startAngle, double arcAngle)
x
- the x coordinate of the rectangle to be drawn.y
- the y coordinate of the rectangle to be drawn.width
- the width of the rectangle to be drawn.height
- the height of the rectangle to be drawn.public static void drawArc(java.awt.Graphics g, double x, double y, double width, double height, double startAngle, double arcAngle, int lineStyle)
x
- the x coordinate of the rectangle to be drawn.y
- the y coordinate of the rectangle to be drawn.width
- the width of the rectangle to be drawn.height
- the height of the rectangle to be drawn.lineStyle
- the line style of shape.public static void fill(java.awt.Graphics g, java.awt.Shape shape)
g
- 画板shape
- 指定区域public static void fillRect(java.awt.Graphics g, double x, double y, double width, double height)
g
- 画板x
- x坐标y
- y坐标width
- 宽度height
- 高度public static void fillArc(java.awt.Graphics g, double x, double y, double width, double height, double startAngle, double arcAngle)
g
- 画板x
- x坐标y
- y坐标width
- 宽度height
- 高度startAngle
- 起始角度arcAngle
- 弧度public static void drawString(java.awt.Graphics g, java.lang.String str, double x, double y)
str
- the string to be rendered.x
- the X coordinates.y
- the X coordinates.
should be rendered.public static void drawString2(java.awt.Graphics g, java.lang.String str, double x, double y, int width)
public static void drawRotatedString(java.awt.Graphics g, java.lang.String str, double x, double y, int rotation)
public static void drawRotatedString(java.awt.Graphics g, java.lang.String str, double x, double y, int rotation, double scale)
str
- the string to be rendered.x
- the X coordinates.y
- the X coordinates.rotation
- the rotation of the string.public static java.awt.image.BufferedImage createBufferedImageFromImage(java.awt.Image image)
image
- 图片public static java.awt.image.BufferedImage createBufferedImageFromImageWithLayout(java.awt.Image image, int width, int height, Style style)
image
- 指定的图片width
- 宽度height
- 高度style
- 样式public static void setStroke(java.awt.Graphics2D g2d, java.awt.Stroke stroke)
public static java.awt.Stroke getStroke(int lineStyle)
public static int getLineStyleSize(int lineStyle)
public static double stringWidth(java.lang.String string, java.awt.Font font, java.awt.font.FontRenderContext fontRenderContext)
string
- 字符font
- 字体fontRenderContext
- 字体信息@Deprecated public static int getLocTextWidth(java.lang.String key, java.awt.Font font)
font
- 当前字体key
- 国际化key@Deprecated public static int getLocTextWidth(java.lang.String key)
key
- 国际化keypublic static int getWidth(java.lang.String value)
public static int getWidth(java.lang.String value, java.awt.Font font)
public static java.awt.geom.Dimension2D stringDimensionWithRotation(java.lang.String string, java.awt.Font font, int rotation, java.awt.font.FontRenderContext fontRenderContext)
string
- 字符串font
- 字体rotation
- 旋转角度fontRenderContext
- 字体信息public static java.awt.FontMetrics getFontMetrics(java.awt.Font font, java.awt.Graphics2D g2d)
public static java.awt.FontMetrics getFontMetrics(java.awt.Font font)
public static void paintImage(java.awt.Graphics g, int width, int height, java.awt.Image image, int layout, int hAlign, int vAlign, int specifiedImageWidth, int specifiedImageHeight)
g
- width
- the width of the draw paneheight
- the height of the draw paneimage
- image to be paintedlayout
- the layout of the imagepublic static void paintImage(java.awt.Graphics g, int width, int height, java.awt.Image image, int layout, int hAlign, int vAlign, int specifiedImageWidth, int specifiedImageHeight, boolean isNotSupportARGB)
public static void paintImageMoved(java.awt.Graphics g, int width, int height, java.awt.Image image, int layout, int hAlign, int vAlign, int specifiedImageWidth, int specifiedImageHeight, int moveWidth, int moveHeight, boolean isNotSupportARGB)
public static void paintImageMoved(java.awt.Graphics g, int width, int height, java.awt.Image image, int layout)
g
- 当前画板width
- 画板宽度height
- 画板高度image
- 绘制的图片layout
- 绘制图片的布局public static void paintImageMoved(java.awt.Graphics g, int width, int height, java.awt.Image image, int layout, int hAlign, int vAlign, int specifiedImageWidth, int specifiedImageHeight, int moveWidth, int moveHeight, boolean isNotSupportARGB, java.awt.Color backgroundcolor)
g
- width
- the width of the draw paneheight
- the height of the draw paneimage
- image to be paintedlayout
- the layout of the imagemoveWidth
- the moveWidth that the background hidemoveHeight
- the moveHeight that the background hide
see paintImage(), this method has two more parameters.
by Denny
note by Denny: 这个函数应该是用来在冻结行列时候画背景图片的,所以多了两个参数.public static void applyRenderingHints(java.awt.Graphics g)
g
- Graphics