public class OFDPageGraphics2D extends Graphics2D
在 PageGraphics2D 中所有接口参数单位均为 毫米(mm)。
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addRenderingHints(Map<?,?> hints)
添加绘制器参数(为了兼容接口,无实际用途)
|
void |
clearRect(int x,
int y,
int width,
int height)
使用背景色填充矩形区域
|
void |
clip(Shape s)
设置裁剪区域
若已经存在裁剪区域,那么新的裁剪区域与旧的裁剪区域取交集。
|
void |
clipRect(int x,
int y,
int width,
int height)
设置矩形裁剪区域
|
void |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
复制矩形区域
|
Graphics |
create()
复制当前绘制上下文为新的上下文
|
void |
dispose()
销毁绘制上下文
|
void |
draw(Shape s)
绘制图形
|
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
在矩形区域内绘制圆弧
注意:0度位于时钟3点钟位置,正数角度表示顺时针旋转,负数为逆时针,圆形位于矩形中心。
|
void |
drawGlyphVector(GlyphVector g,
float x,
float y)
在指定位置上绘制绘制图形路径数据,
图形的绘制将绘制将受到画笔参数(Paint) 、被裁剪矩阵(clip)、变换矩阵影响(CTM)。
|
void |
drawImage(BufferedImage img,
BufferedImageOp op,
int x,
int y)
在画布指定位置绘制图像,在绘制前将会使用
BufferedImageOp 过滤图像
等价于
img1 = op.filter(img, null);
drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
|
boolean |
drawImage(Image img,
AffineTransform xform,
ImageObserver obs)
通过变换矩阵在指定位置绘制图像
|
boolean |
drawImage(Image img,
int x,
int y,
Color bgcolor,
ImageObserver observer)
在指定位置绘制图片
图片保持原有大小,图片的透明部分将会使用指定颜色填充
|
boolean |
drawImage(Image img,
int x,
int y,
ImageObserver observer)
在指定坐标位置上绘制图片
绘制的图片大小为图元原始大小
|
boolean |
drawImage(Image img,
int x,
int y,
int width,
int height,
Color bgcolor,
ImageObserver observer)
在指定矩形区域内绘制图片
图片将伸缩至矩形区域大小,图片的透明部分将会使用指定颜色填充
|
boolean |
drawImage(Image img,
int x,
int y,
int width,
int height,
ImageObserver observer)
将图片绘制于指定矩形区域内
|
boolean |
drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
Color bgcolor,
ImageObserver observer)
绘制图片内某个矩形区域 到 画布的某个指定矩形区域
图片将会缩放适应目标区域,图片的透明部分将会使用指定颜色填充
|
boolean |
drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
ImageObserver observer)
绘制图片内某个矩形区域 到 画布的某个指定矩形区域,图片将会缩放适应目标区域
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
画线
|
void |
drawOval(int x,
int y,
int width,
int height)
使用当前颜色在矩形区域内描边椭圆形
|
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
使用当前颜色和描边属性描边多边形
|
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
绘制折线
注意绘制的折线是一个不闭合的图形
|
void |
drawRect(int x,
int y,
int width,
int height)
描边矩形
|
void |
drawRenderableImage(RenderableImage img,
AffineTransform xform)
通过变换矩阵在指定位置绘制图像
|
void |
drawRenderedImage(RenderedImage img,
AffineTransform xform)
通过变换矩阵在指定位置绘制图像
|
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
绘制圆角矩形
|
void |
drawString(AttributedCharacterIterator iterator,
float x,
float y)
使用迭代器绘制文字图形
文字图形的绘制将绘制将受到画笔参数(Paint) 、被裁剪矩阵(clip)、变换矩阵影响(CTM)。
|
void |
drawString(AttributedCharacterIterator iterator,
int x,
int y)
使用迭代器绘制文字图形
文字图形的绘制将绘制将受到画笔参数(Paint) 、被裁剪矩阵(clip)、变换矩阵影响(CTM)。
|
void |
drawString(String str,
float x,
float y)
使用当前的 字体(Font) 以及 画笔参数(Paint) 在指定位置上绘制文字
文字将转换为图形路径绘制填充在OFD页面上
第一个文字的基线坐标为传入的(x,y)参数位置。
|
void |
drawString(String str,
int x,
int y)
使用当前的 字体(Font) 以及 画笔参数(Paint) 在指定位置上绘制文字
文字将转换为图形路径绘制填充在OFD页面上
第一个文字的基线坐标为传入的(x,y)参数位置。
|
void |
fill(Shape s)
填充图形
|
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
在矩形区域内填充扇形
注意:0度位于时钟3点钟位置,正数角度表示顺时针旋转,负数为逆时针,圆形位于矩形中心。
|
void |
fillOval(int x,
int y,
int width,
int height)
使用当前颜色在矩形区域内填充椭圆形
|
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
使用当前颜色填充多边形
|
void |
fillRect(int x,
int y,
int width,
int height)
填充矩形区域
|
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
填充圆角矩形
|
Color |
getBackground()
获取背景颜色
|
Shape |
getClip()
获取裁剪区域
|
Rectangle |
getClipBounds()
获取裁剪区域的外接矩形大小
|
Color |
getColor()
返回前景色
|
Composite |
getComposite()
获取像素合成模式
该属性只是为了兼容AWT接口保留,并无实际用途。
|
GraphicsConfiguration |
getDeviceConfiguration()
获取设备图形配置对象
|
Font |
getFont()
获取当前字体
|
FontMetrics |
getFontMetrics(Font f)
获取特定字体的字体规格
|
FontRenderContext |
getFontRenderContext()
获取绘制上下文中的字体绘制上下文
|
Paint |
getPaint()
获取绘制参数
|
Object |
getRenderingHint(RenderingHints.Key hintKey)
获取绘制器参数值(为了兼容接口,无实际用途)
|
RenderingHints |
getRenderingHints()
获取当前绘制器参数信息(为了兼容接口,无实际用途)
|
Stroke |
getStroke()
获取描边属性
|
AffineTransform |
getTransform()
返回当前的变换矩阵
|
boolean |
hit(Rectangle rect,
Shape s,
boolean onStroke)
检查在设备空间内容 指定的矩形区域是否与 指定形状存在交集。
|
void |
rotate(double theta)
绕原点旋转画布
|
void |
rotate(double theta,
double x,
double y)
绕指定点旋转画布
等价于
translate(x, y);
rotate(theta);
translate(-x, -y);
|
void |
scale(double sx,
double sy)
坐标缩放
|
void |
setBackground(Color color)
设置背景颜色
|
void |
setClip(int x,
int y,
int width,
int height)
设置矩形裁剪区域
若已经存在裁剪区域那么旧的裁剪区域将会被新的裁剪区域覆盖
|
void |
setClip(Shape s)
设置裁剪区域
若已经存在裁剪区域那么旧的裁剪区域将会被新的裁剪区域覆盖
|
void |
setColor(Color c)
设置前景色
|
void |
setComposite(Composite comp)
设置像素合成模式
该方法原用于在设备绘制图像时,当前绘制的像素与原位置上已经存在的像素颜色的合成方式。
|
void |
setFont(Font font)
设置绘图上下文的字体
|
void |
setPaint(Paint paint)
设置绘制参数
|
void |
setPaintMode()
setPaintMode 不实现
|
void |
setRenderingHint(RenderingHints.Key hintKey,
Object hintValue)
设置绘制器参数
|
void |
setRenderingHints(Map<?,?> hints)
替换绘制器参数(为了兼容接口,无实际用途)
|
void |
setStroke(Stroke s)
设置描边属性
|
void |
setTransform(AffineTransform tx)
设置变换矩阵
|
void |
setXORMode(Color c1)
setXORMode 不实现
|
void |
shear(double shx,
double shy)
切变
|
ST_Array |
trans(AffineTransform tx)
转为AWT变换矩阵
AffineTransform 为 OFD 类型变换矩阵ST_Array |
void |
transform(AffineTransform tx)
图形变换
|
void |
translate(double tx,
double ty)
平移原点
|
void |
translate(int x,
int y)
平移原点坐标
|
draw3DRect, fill3DRectcreate, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toStringpublic final ST_ID pageID
public void draw(Shape s)
draw 在类中 Graphics2Ds - 图形public void drawString(String str, int x, int y)
文字将转换为图形路径绘制填充在OFD页面上
第一个文字的基线坐标为传入的(x,y)参数位置。
文字绘制的将被裁剪矩阵(clip)、变换矩阵影响。
drawString 在类中 Graphics2Dstr - 待绘制文字序列x - 首个文字基线X坐标y - 首个文字基线Y坐标public void drawString(String str, float x, float y)
文字将转换为图形路径绘制填充在OFD页面上
第一个文字的基线坐标为传入的(x,y)参数位置。
文字绘制的将被裁剪矩阵(clip)、变换矩阵影响。
drawString 在类中 Graphics2Dstr - 待绘制文字序列x - 首个文字基线X坐标y - 首个文字基线Y坐标public void drawString(AttributedCharacterIterator iterator, int x, int y)
文字图形的绘制将绘制将受到画笔参数(Paint) 、被裁剪矩阵(clip)、变换矩阵影响(CTM)。
第一个文字图形的基线坐标为传入的(x,y)参数位置。
drawString 在类中 Graphics2Diterator - 待绘制文本的迭代器x - 首个文字基线X坐标y - 首个文字基线Y坐标public void drawString(AttributedCharacterIterator iterator, float x, float y)
文字图形的绘制将绘制将受到画笔参数(Paint) 、被裁剪矩阵(clip)、变换矩阵影响(CTM)。
第一个文字图形的基线坐标为传入的(x,y)参数位置。
drawString 在类中 Graphics2Diterator - 待绘制文本的迭代器x - 首个文字基线X坐标y - 首个文字基线Y坐标public void drawGlyphVector(GlyphVector g, float x, float y)
图形的绘制将绘制将受到画笔参数(Paint) 、被裁剪矩阵(clip)、变换矩阵影响(CTM)。
第一个文字的基线坐标为传入的(x,y)参数位置。
drawGlyphVector 在类中 Graphics2Dg - 路径向量数据x - 图形绘制位置X坐标y - 图形绘制位置Y坐标public boolean drawImage(Image img, int x, int y, ImageObserver observer)
绘制的图片大小为图元原始大小
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
图片保持原有大小,图片的透明部分将会使用指定颜色填充
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
图片将伸缩至矩形区域大小,图片的透明部分将会使用指定颜色填充
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
图片将会缩放适应目标区域,图片的透明部分将会使用指定颜色填充
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
drawImage 在类中 Graphics2Dimg - 待绘制的图像(可渲染图像接口)xform - 变换矩阵,指定图像绘制方式obs - 忽略public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
BufferedImageOp 过滤图像
等价于
img1 = op.filter(img, null);
drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
drawImage 在类中 Graphics2Dimg - 待绘制图像op - 图片渲染前的过滤器x - 图片左上角X坐标y - 图片左上角Y坐标public void drawRenderedImage(RenderedImage img, AffineTransform xform)
drawRenderedImage 在类中 Graphics2Dimg - 待绘制的图像(可渲染图像接口)xform - 变换矩阵,指定图像绘制方式public void drawRenderableImage(RenderableImage img, AffineTransform xform)
drawRenderableImage 在类中 Graphics2Dimg - 待绘制的图像(可渲染图像接口)xform - 变换矩阵,指定图像绘制方式public void fill(Shape s)
fill 在类中 Graphics2Ds - Java图形public boolean hit(Rectangle rect, Shape s, boolean onStroke)
onStroke 为false,表示检查指定形状整体是否与指定矩形相交。
onStroke 为true,表示检查指定形状的描边整体是否与指定矩形相交。
hit 在类中 Graphics2Drect - 矩形区域s - 待检查的图形形状onStroke - 相交检查方式,true - 描边区域是否相交; false - 整个形状是否相交public GraphicsConfiguration getDeviceConfiguration()
getDeviceConfiguration 在类中 Graphics2Dpublic void setComposite(Composite comp)
该方法原用于在设备绘制图像时,当前绘制的像素与原位置上已经存在的像素颜色的合成方式。 OFD中没有对应的合成效果,仅做兼容性实现。
setComposite 在类中 Graphics2Dcomp - 合成方式public void setPaint(Paint paint)
setPaint 在类中 Graphics2Dpaint - 设置画笔颜色,用于填充和描边public void setStroke(Stroke s)
setStroke 在类中 Graphics2Ds - 描边属性参数public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
setRenderingHint 在类中 Graphics2DhintKey - 参数名hintValue - 参数值public Object getRenderingHint(RenderingHints.Key hintKey)
getRenderingHint 在类中 Graphics2DhintKey - 参数名public void setRenderingHints(Map<?,?> hints)
setRenderingHints 在类中 Graphics2Dhints - 新参数public void addRenderingHints(Map<?,?> hints)
addRenderingHints 在类中 Graphics2Dhints - 键值对public RenderingHints getRenderingHints()
getRenderingHints 在类中 Graphics2Dpublic void setPaintMode()
setPaintMode 在类中 Graphicspublic void setXORMode(Color c1)
setXORMode 在类中 Graphicsc1 - the XOR alternation colorpublic FontMetrics getFontMetrics(Font f)
getFontMetrics 在类中 Graphicsf - 特定字体public Rectangle getClipBounds()
getClipBounds 在类中 Graphicspublic void clipRect(int x,
int y,
int width,
int height)
public void setClip(int x,
int y,
int width,
int height)
若已经存在裁剪区域那么旧的裁剪区域将会被新的裁剪区域覆盖
public void clip(Shape s)
若已经存在裁剪区域,那么新的裁剪区域与旧的裁剪区域取交集。
clip 在类中 Graphics2Ds - 裁剪区域,如果为 null 则清除裁剪区域public void setClip(Shape s)
若已经存在裁剪区域那么旧的裁剪区域将会被新的裁剪区域覆盖
public void copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
copyArea 在类中 Graphicsx - the x coordinate of the source rectangle.y - the y coordinate of the source rectangle.width - the width of the source rectangle.height - the height of the source rectangle.dx - the horizontal distance to copy the pixels.dy - the vertical distance to copy the pixels.public void drawLine(int x1,
int y1,
int x2,
int y2)
public void fillRect(int x,
int y,
int width,
int height)
public void drawRect(int x,
int y,
int width,
int height)
public void clearRect(int x,
int y,
int width,
int height)
public void drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
drawRoundRect 在类中 Graphicsx - 矩形左上角X坐标y - 矩形左上角Y坐标width - 矩形宽度height - 矩形高度arcWidth - 水平圆角半径arcHeight - 垂直圆角半径public void fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
fillRoundRect 在类中 Graphicsx - 矩形左上角X坐标y - 矩形左上角Y坐标width - 矩形宽度height - 矩形高度arcWidth - 水平圆角半径arcHeight - 垂直圆角半径public void drawOval(int x,
int y,
int width,
int height)
public void fillOval(int x,
int y,
int width,
int height)
public void drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
注意:0度位于时钟3点钟位置,正数角度表示顺时针旋转,负数为逆时针,圆形位于矩形中心。
public void fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
注意:0度位于时钟3点钟位置,正数角度表示顺时针旋转,负数为逆时针,圆形位于矩形中心。
圆弧起点和终点为圆心
public void drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
注意绘制的折线是一个不闭合的图形
drawPolyline 在类中 GraphicsxPoints - 折点 X坐标 序列yPoints - 折点 Y坐标 序列nPoints - 折点总数public void drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
drawPolygon 在类中 GraphicsxPoints - 多边形 X坐标 序列yPoints - 多边形 Y坐标 序列nPoints - 多边形点数量public void fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
fillPolygon 在类中 GraphicsxPoints - 多边形 X坐标 序列yPoints - 多边形 Y坐标 序列nPoints - 多边形点数量public void translate(int x,
int y)
translate 在类中 Graphics2Dx - x方向的平移距离y - y方向的平移距离public void translate(double tx,
double ty)
translate 在类中 Graphics2Dtx - x方向的平移距离ty - y方向的平移距离public void rotate(double theta)
rotate 在类中 Graphics2Dtheta - 旋转角度,计算方式为 theta = angle * Math.PI / 180 ,负数表示逆时针。public void rotate(double theta,
double x,
double y)
等价于
translate(x, y);
rotate(theta);
translate(-x, -y);
rotate 在类中 Graphics2Dtheta - 旋转角度,计算方式为 theta = angle * Math.PI / 180 ,负数表示逆时针。x - 旋转点X坐标y - 旋转点Y坐标public void scale(double sx,
double sy)
scale 在类中 Graphics2Dsx - 缩放当前绘图的宽度 (1=100%, 0.5=50%, 2=200%, 依次类推)sy - 缩放当前绘图的高度 (1=100%, 0.5=50%, 2=200%, 依次类推)public void shear(double shx,
double shy)
shear 在类中 Graphics2Dshx - X方向切变角度shy - Y方向切变角度public void transform(AffineTransform tx)
transform 在类中 Graphics2Dtx - 变换矩阵public void setTransform(AffineTransform tx)
setTransform 在类中 Graphics2Dtx - 变换矩阵public AffineTransform getTransform()
getTransform 在类中 Graphics2Dpublic Paint getPaint()
getPaint 在类中 Graphics2Dpublic Composite getComposite()
该属性只是为了兼容AWT接口保留,并无实际用途。
getComposite 在类中 Graphics2Dpublic void setBackground(Color color)
setBackground 在类中 Graphics2Dcolor - 该颜色将用于 clearRect 清空区域public Color getBackground()
getBackground 在类中 Graphics2Dpublic Stroke getStroke()
getStroke 在类中 Graphics2DBasicStrokepublic FontRenderContext getFontRenderContext()
getFontRenderContext 在类中 Graphics2Dpublic ST_Array trans(AffineTransform tx)
AffineTransform 为 OFD 类型变换矩阵ST_Arraytx - AWT变换矩阵Copyright © 2025. All rights reserved.