public abstract class Graphics extends Object
Graphics
所有图形上下文,允许应用程序画上,在各种设备上实现组件的基类,以及到了屏幕图像。
一个Graphics
对象封装所需的基本渲染操作,java支持状态信息。此状态信息包括以下属性:
Component
对象绘制。setXORMode(java.awt.Color)
)。坐标是无限薄的,介于输出设备的像素之间的。绘制一个图形的轮廓的操作,通过遍历一个无限薄的路径之间的像素与一个像素大小的笔,挂下来,并在路径上的锚点的权利。填充一个数字的操作通过填充该无限薄的路径的内部。操作水平文本渲染渲染字形上升部分完全高于基线坐标。
绘图笔挂下来,从路径遍历右。这有以下几点启示:
所有出现在这Graphics
对象的方法的参数是相对于这Graphics
对象翻译起始的方法调用之前的坐标。
所有的渲染操作只修改像素,躺在当前剪辑区域内,由用户空间的一个Shape
指定用Graphics
对象的程序控制。这个空用户卡转化装置的空间,结合空夹持器,这是由Windows和设备程度的可见性定义。用户的夹具和装置夹的组合定义了空复合夹,这决定了最终的裁剪区域。无法通过渲染系统修改用户剪辑以反映所得到的复合剪辑。用户卡只能通过setClip
或clipRect
方法改变。所有的绘图或书写都是在当前的颜色,使用当前的油漆模式,并在当前的字体。
Component
,
clipRect(int, int, int, int)
,
setColor(java.awt.Color)
,
setPaintMode()
,
setXORMode(java.awt.Color)
,
setFont(java.awt.Font)
Modifier | Constructor and Description |
---|---|
protected |
Graphics()
构建了一种新的
Graphics 对象。
|
Modifier and Type | Method and Description |
---|---|
abstract void |
clearRect(int x, int y, int width, int height)
通过将其与当前绘图表面的背景颜色填充,清除指定的矩形。
|
abstract void |
clipRect(int x, int y, int width, int height)
与当前剪辑与指定的矩形。
|
abstract void |
copyArea(int x, int y, int width, int height, int dx, int dy)
本区的组件
dx 和
dy 指定的距离。
|
abstract Graphics |
create()
创建一个新的
Graphics 对象,一份本
Graphics 对象。
|
Graphics |
create(int x, int y, int width, int height)
创建一个新的基于此
Graphics 对象
Graphics 对象,但一个新的翻译和剪辑区域。
|
abstract void |
dispose()
将这个图形上下文和释放任何系统资源,它是利用。
|
void |
draw3DRect(int x, int y, int width, int height, boolean raised)
绘制指定矩形的三维突出显示的轮廓。
|
abstract void |
drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
绘制一个圆形或椭圆弧的轮廓,覆盖指定的矩形。
|
void |
drawBytes(byte[] data, int offset, int length, int x, int y)
使用指定的字节数组指定的文本,使用此图形上下文的当前字体和颜色。
|
void |
drawChars(char[] data, int offset, int length, int x, int y)
使用指定的字符数组指定的文本,使用此图形上下文的当前字体和颜色。
|
abstract boolean |
drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
提请尽可能多的指定的图像,是目前可用。
|
abstract boolean |
drawImage(Image img, int x, int y, ImageObserver observer)
提请尽可能多的指定的图像,是目前可用。
|
abstract boolean |
drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
绘制已缩放到适合在指定的矩形内的指定图像的大部分区域。
|
abstract boolean |
drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
绘制已缩放到适合在指定的矩形内的指定图像的大部分区域。
|
abstract boolean |
drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
吸引尽可能多的指定区域,指定的图像是目前可用的,缩放在飞放在指定区域的目标的表面。
|
abstract boolean |
drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
吸引尽可能多的指定区域,指定的图像是目前可用的,缩放在飞放在指定区域的目标的表面。
|
abstract void |
drawLine(int x1, int y1, int x2, int y2)
画一条线,使用当前颜色,这个图形中的坐标系统中的点
(x1, y1) 和
(x2, y2) 之间。
|
abstract void |
drawOval(int x, int y, int width, int height)
绘制椭圆的轮廓。
|
abstract void |
drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
绘制一个闭合的多边形阵列nullx定义和nully坐标。
|
void |
drawPolygon(Polygon p)
绘制一个由指定的
Polygon 对象定义多边形的轮廓。
|
abstract void |
drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
绘制一系列相互连接的直线阵列nullx定义和nully坐标。
|
void |
drawRect(int x, int y, int width, int height)
绘制指定矩形的轮廓。
|
abstract void |
drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
使用此图形上下文的当前颜色绘制一个圆角矩形。
|
abstract void |
drawString(AttributedCharacterIterator iterator, int x, int y)
使指定的迭代器将其属性按照
TextAttribute 类的规范文本。
|
abstract void |
drawString(String str, int x, int y)
使用指定的字符串绘制的文本,使用此图形上下文的当前字体和颜色。
|
void |
fill3DRect(int x, int y, int width, int height, boolean raised)
画一个充满当前颜色的三维高亮矩形。
|
abstract void |
fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
填充一个圆形或椭圆形的圆弧覆盖指定的矩形。
|
abstract void |
fillOval(int x, int y, int width, int height)
填充一个椭圆形,由指定的矩形与当前颜色。
|
abstract void |
fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
填充一个封闭的多边形阵列nullx定义和nully坐标。
|
void |
fillPolygon(Polygon p)
填充指定的多边形对象定义的多边形,用图形上下文的当前颜色填充。
|
abstract void |
fillRect(int x, int y, int width, int height)
填充指定的矩形。
|
abstract void |
fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
填充指定的圆角矩形与当前颜色。
|
void |
finalize()
将这个图形上下文,一旦它不再被引用。
|
abstract Shape |
getClip()
获取当前剪辑区域。
|
abstract Rectangle |
getClipBounds()
返回当前剪切区域的边框矩形。
|
Rectangle |
getClipBounds(Rectangle r)
返回当前剪切区域的边框矩形。
|
Rectangle |
getClipRect()
过时的。
作为JDK 1.1版本,取而代之的
getClipBounds() 。
|
abstract Color |
getColor()
获取此图形上下文的当前颜色。
|
abstract Font |
getFont()
获取当前字体。
|
FontMetrics |
getFontMetrics()
获取当前字体的字体度量。
|
abstract FontMetrics |
getFontMetrics(Font f)
获取指定字体的字体度量。
|
boolean |
hitClip(int x, int y, int width, int height)
如果指定的矩形区域可能与当前剪辑区域相交,则返回真。
|
abstract void |
setClip(int x, int y, int width, int height)
将当前剪辑设置为给定坐标指定的矩形。
|
abstract void |
setClip(Shape clip)
将当前剪辑区域设置为任意形状的剪辑区域。
|
abstract void |
setColor(Color c)
将此图形上下文的当前颜色设置为指定的颜色。
|
abstract void |
setFont(Font font)
将此图形上下文的字体设置为指定的字体。
|
abstract void |
setPaintMode()
设置此图形上下文的绘制模式,用此图形上下文的当前颜色覆盖目标。
|
abstract void |
setXORMode(Color c1)
设置此图形上下文的绘制模式,以在该图形上下文的当前颜色和新指定颜色之间交替进行。
|
String |
toString()
返回表示这
Graphics 对象的值
String 对象。
|
abstract void |
translate(int x, int y)
将图形上下文的起源点(nullx, nully)在当前坐标系统。
|
protected Graphics()
Graphics
对象。此构造函数是一个图形上下文的默认构造函数。
因为Graphics
是一个抽象类,应用程序不能直接调用此构造函数。图形上下文从其他图形上下文获得或是在组件调用getGraphics
创建。
create()
,
Component.getGraphics()
public abstract Graphics create()
Graphics
对象,一份本
Graphics
对象。
public Graphics create(int x, int y, int width, int height)
Graphics
对象
Graphics
对象,但一个新的翻译和剪辑区域。新
Graphics
对象有其起源翻译到指定点(nullx, nully)。它的剪辑区域是由原始剪辑区域与指定的矩形的交集所决定的。参数都在原来的
Graphics
对象的坐标系统的解释。新的图形上下文是相同的原始,除了在两个方面:
0
, 0
)在新的图形上下文是相同的(nullx, nully)在原图形上下文。0
, 0
),其大小是由指定的width
和height
参数。x
- nullx坐标。
y
- nully坐标。
width
-裁剪矩形的宽度。
height
-裁剪矩形的高度。
translate(int, int)
,
clipRect(int, int, int, int)
public abstract void translate(int x, int y)
x
- nullx坐标。
y
- nully坐标。
public abstract Color getColor()
Color
,
setColor(Color)
public abstract void setColor(Color c)
c
-新的渲染色彩。
Color
,
getColor()
public abstract void setPaintMode()
public abstract void setXORMode(Color c1)
当执行绘图操作时,将当前颜色的像素更改为指定的颜色,反之亦然。
除了两种颜色以外的颜色的像素是不可预测的,但可逆的方式改变;如果相同的数字被绘制两次,那么所有的像素恢复到他们的原始值。
c1
-异或变换颜色
public abstract Font getFont()
Font
,
setFont(Font)
public abstract void setFont(Font font)
public FontMetrics getFontMetrics()
getFont()
,
FontMetrics
,
getFontMetrics(Font)
public abstract FontMetrics getFontMetrics(Font f)
f
-指定的字体
getFont()
,
FontMetrics
,
getFontMetrics()
public abstract Rectangle getClipBounds()
setClip(null)
夹已被清除,此方法返回
null
。矩形中的坐标相对于这个图形上下文的坐标系原点。
null
如果没有夹套。
getClip()
,
clipRect(int, int, int, int)
,
setClip(int, int, int, int)
,
setClip(Shape)
public abstract void clipRect(int x, int y, int width, int height)
setClip(null)
,指定矩形成为新的剪辑。此方法设置用户剪辑,这是独立于与设备边界和窗口可见性相关联的裁剪。此方法只能用于使当前剪辑较小。设置当前剪辑较大,使用任何SetClip方法。渲染操作在裁剪区域外没有效果。
x
的x坐标的矩形相交的夹
y
-矩形相交的剪辑与Y坐标
width
-矩形相交的夹的宽度
height
-矩形相交的剪辑与高度
setClip(int, int, int, int)
,
setClip(Shape)
public abstract void setClip(int x, int y, int width, int height)
x
-新的剪辑矩形nullx坐标。
y
-新的剪辑矩形nully坐标。
width
-新的剪辑矩形的宽度。
height
-新的剪辑矩形的高度。
clipRect(int, int, int, int)
,
setClip(Shape)
,
getClip()
public abstract Shape getClip()
setClip(null)
夹已被清除,此方法返回
null
。
Shape
对象,或
null
如果没有夹套。
getClipBounds()
,
clipRect(int, int, int, int)
,
setClip(int, int, int, int)
,
setClip(Shape)
public abstract void setClip(Shape clip)
Shape
接口可以用来设置夹。这是保证是唯一支持的
Shape
对象
Shape
对象,通过
getClip
方法和通过
Rectangle
对象。此方法设置用户剪辑,这是独立于与设备边界和窗口可见性相关联的裁剪。
clip
-
Shape
使用设置夹
getClip()
,
clipRect(int, int, int, int)
,
setClip(int, int, int, int)
public abstract void copyArea(int x, int y, int width, int height, int dx, int dy)
dx
和
dy
指定的距离。从
x
和
y
指定的点,此方法复制向下和向右。复制组件面积向左或向上,或指定
dx
dy
负值。如果源矩形的一部分在于外部组件的范围,或是由另一个窗口或组件的遮挡,
copyArea
将无法复制相关的像素。这一地区略可以通过调用组件的
paint
方法刷新。
x
-源矩形的nullx坐标。
y
-源矩形的nully坐标。
width
-源矩形的宽度。
height
-源矩形的高度。
dx
-复制像素的水平距离。
dy
-复制像素的垂直距离。
public abstract void drawLine(int x1, int y1, int x2, int y2)
(x1, y1)
和
(x2, y2)
之间。
x1
-第一点的nullx坐标。
y1
-第一点的nully坐标。
x2
-第二点的nullx坐标。
y2
-第二点的nully坐标。
public abstract void fillRect(int x, int y, int width, int height)
x
和
x + width - 1
。顶部和底部边缘在
y
和
y + height - 1
。由此产生的矩形面积
width
像素像素高宽
height
。矩形填充使用图形上下文的当前颜色。
x
-矩形填充nullx坐标。
y
-矩形填充nully坐标。
width
-矩形要填充的宽度。
height
-矩形填充高度。
clearRect(int, int, int, int)
,
drawRect(int, int, int, int)
public void drawRect(int x, int y, int width, int height)
x
和
x + width
。顶部和底部边缘在
y
和
y + height
。矩形绘制使用图形上下文的当前颜色。
x
-矩形来绘制的nullx坐标。
y
-矩形来绘制的nully坐标。
width
-矩形来绘制宽度。
height
-矩形被拉高。
fillRect(int, int, int, int)
,
clearRect(int, int, int, int)
public abstract void clearRect(int x, int y, int width, int height)
用java 1.1开始,屏幕图像的背景色可以是系统依赖性。应用程序应该使用setColor
随后fillRect
确保屏幕图像被一个特定的颜色。
x
-矩形清除nullx坐标。
y
-矩形清除nully坐标。
width
-矩形清除宽度。
height
-矩形的高度清晰。
fillRect(int, int, int, int)
,
drawRect(int, int, int, int)
,
setColor(java.awt.Color)
,
setPaintMode()
,
setXORMode(java.awt.Color)
public abstract void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
x
和
x + width
,分别。顶部和底部的矩形的边在
y
和
y + height
。
x
-矩形来绘制的nullx坐标。
y
-矩形来绘制的nully坐标。
width
-矩形来绘制宽度。
height
-矩形被拉高。
arcWidth
-在四角圆弧的横径。
arcHeight
-在四角圆弧垂直直径。
fillRoundRect(int, int, int, int, int, int)
public abstract void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
x
和
x + width - 1
,分别。顶部和底部的矩形的边在
y
和
y + height - 1
。
x
-矩形填充nullx坐标。
y
-矩形填充nully坐标。
width
-矩形要填充的宽度。
height
-矩形填充高度。
arcWidth
-在四角圆弧的横径。
arcHeight
-在四角圆弧垂直直径。
drawRoundRect(int, int, int, int, int, int)
public void draw3DRect(int x, int y, int width, int height, boolean raised)
用于突出效果的颜色取决于当前颜色。由此产生的矩形的占地面积是width + 1
像素像素高宽height + 1
。
x
-矩形来绘制的nullx坐标。
y
-矩形来绘制的nully坐标。
width
-矩形来绘制宽度。
height
-矩形被拉高。
raised
-一个布尔值,确定矩形似乎是凸起的表面或渗入表面。
fill3DRect(int, int, int, int, boolean)
public void fill3DRect(int x, int y, int width, int height, boolean raised)
x
-矩形填充nullx坐标。
y
-矩形填充nully坐标。
width
-矩形要填充的宽度。
height
-矩形填充高度。
raised
-一个布尔值,确定矩形似乎是凸起的表面或蚀刻的表面。
draw3DRect(int, int, int, int, boolean)
public abstract void drawOval(int x, int y, int width, int height)
x
,
y
,
width
指定的矩形内,和
height
参数。
椭圆形的占地面积是width + 1
像素宽,height + 1
像素高。
x
-椭圆的左上角要画nullx坐标。
y
-椭圆的左上角要画nully坐标。
width
-椭圆来绘制宽度。
height
-椭圆来绘制的高度。
fillOval(int, int, int, int)
public abstract void fillOval(int x, int y, int width, int height)
x
-椭圆的左上角要填充的nullx坐标。
y
-椭圆的左上角要填充的nully坐标。
width
-椭圆要填充的宽度。
height
-椭圆形充满高度。
drawOval(int, int, int, int)
public abstract void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
产生的电弧从startAngle
和延伸arcAngle
度,使用当前颜色。角度解释,0 度在3 点位置。正值表示逆时针旋转,而负值表示顺时针旋转。
电弧的中心是矩形原点为中心(nullx, nully),其大小是由指定的width
和height
参数。
产生的电弧占地面积width + 1
像素像素高宽height + 1
。
的角度被指定的相对的约束矩形的非平方范围,例如,45度总是落在直线上的中心的椭圆的矩形的右上角。其结果是,如果边界矩形明显长在一个轴比其他的角度,开始和结束的圆弧段将被扭曲的更远沿长轴的界限。
x
-电弧的左上角要画nullx坐标。
y
-电弧的左上角要画nully坐标。
width
-电弧被吸引的宽度。
height
-电弧被吸引的高度。
startAngle
开始-角。
arcAngle
-弧角的程度,相对于起始角。
fillArc(int, int, int, int, int, int)
public abstract void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
产生的电弧从startAngle
和延伸arcAngle
度。角度解释,0 度在3 点位置。正值表示逆时针旋转,而负值表示顺时针旋转。
电弧的中心是矩形原点为中心(nullx, nully),其大小是由指定的width
和height
参数。
产生的电弧占地面积width + 1
像素像素高宽height + 1
。
的角度被指定的相对的约束矩形的非平方范围,例如,45度总是落在直线上的中心的椭圆的矩形的右上角。其结果是,如果边界矩形明显长在一个轴比其他的角度,开始和结束的圆弧段将被扭曲的更远沿长轴的界限。
x
-电弧的左上角要填充的nullx坐标。
y
-电弧的左上角要填充的nully坐标。
width
-弧要填充的宽度。
height
-电弧被填充的高度。
startAngle
开始-角。
arcAngle
-弧角的程度,相对于起始角。
drawArc(int, int, int, int, int, int)
public abstract void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
xPoints
- nullx点数组
yPoints
- nully点数组
nPoints
-点总数
drawPolygon(int[], int[], int)
public abstract void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
此方法绘制的nPoint
线段定义的多边形,其中第一nPoint - 1
线段线段的(xPoints[i - 1], yPoints[i - 1])
到(xPoints[i], yPoints[i])
,1 ≤ 空我 ≤ nPoints
。图由图连接的最后一点到第一点线自动关闭,如果这些点是不同的。
xPoints
-一系列的
x
坐标。
yPoints
-一系列的
y
坐标。
nPoints
-总点数。
fillPolygon(int[], int[], int)
,
drawPolyline(int[], int[], int)
public void drawPolygon(Polygon p)
Polygon
对象定义多边形的轮廓。
p
-多边形的绘制。
fillPolygon(int[], int[], int)
,
drawPolyline(int[], int[], int)
public abstract void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
此方法绘制的nPoint
线段定义的多边形,其中第一nPoint - 1
线段线段的(xPoints[i - 1], yPoints[i - 1])
到(xPoints[i], yPoints[i])
,1 ≤ 空我 ≤ nPoints
。图由图连接的最后一点到第一点线自动关闭,如果这些点是不同的。
该多边形内的区域被定义使用一个偶数奇数填充规则,也被称为交替规则。
xPoints
-一系列的
x
坐标。
yPoints
-一系列的
y
坐标。
nPoints
-总点数。
drawPolygon(int[], int[], int)
public void fillPolygon(Polygon p)
该多边形内的区域被定义使用一个偶数奇数填充规则,也被称为交替规则。
p
-多边形填充。
drawPolygon(int[], int[], int)
public abstract void drawString(String str, int x, int y)
str
-要绘制的字符串。
x
- nullx坐标。
y
- nully坐标。
null
str
NullPointerException
。
drawBytes(byte[], int, int, int, int)
,
drawChars(char[], int, int, int, int)
public abstract void drawString(AttributedCharacterIterator iterator, int x, int y)
TextAttribute
类的规范文本。
最左边字符的基线是在位置(nullx, nully)在这个图形中的坐标系统。
iterator
-迭代器的文本要画
x
- nullx坐标。
y
- nully坐标。
null
iterator
NullPointerException
。
drawBytes(byte[], int, int, int, int)
,
drawChars(char[], int, int, int, int)
public void drawChars(char[] data, int offset, int length, int x, int y)
data
-被绘制字符数组
offset
的起始偏移量的数据
length
-字符数可以得出
x
-文本的基线nullx坐标
y
-文本的基线nully坐标
null
data
NullPointerException
。
IndexOutOfBoundsException
-如果
offset
或
length
is小于零,或者
offset+length
大于数组长度的
data
。
drawBytes(byte[], int, int, int, int)
,
drawString(java.lang.String, int, int)
public void drawBytes(byte[] data, int offset, int length, int x, int y)
使用这种方法是不推荐的每个字节解释为在范围0到255码点,所以只能用在那个范围画拉丁字符。
data
-要绘制的数据
offset
-在数据的起始偏移量
length
-字节数,绘制
x
-文本的基线nullx坐标
y
-文本的基线nully坐标
null
data
NullPointerException
。
IndexOutOfBoundsException
-如果
offset
或
length
is小于零,或者
offset+length
大于数组长度的
data
。
drawChars(char[], int, int, int, int)
,
drawString(java.lang.String, int, int)
public abstract boolean drawImage(Image img, int x, int y, ImageObserver observer)
此方法立即返回在所有情况下,即使完成图像尚未加载,它没有抖动和转换为电流输出装置。
如果图像已经完全加载,其像素不被改变,那么drawImage
返回true
。否则,drawImage
返回false
和更多的图像可用或是时间去画一帧动画的过程,加载图像通知指定的图像观察。
img
-指定要绘制的图像。如果这个方法不
img
是空的。
x
- nullx坐标。
y
- nully坐标。
observer
对象有更多的图像转换通知。
false
如果图像像素仍在改变;
true
否则。
Image
,
ImageObserver
,
ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
public abstract boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
该图像被绘制在这个图形上下文的坐标空间的指定的矩形内,并在必要时进行缩放。透明像素不影响任何已经存在的像素。
此方法立即返回在所有情况下,即使整个图像尚未攀登,抖动,并转换为电流输出装置。如果当前的输出表示尚未完成,然后drawImage
返回false
。提供更多的图像时,过程加载图像通知图像观测器通过调用它的imageUpdate
方法。
一个缩小版的图像不一定立即可用,只是因为对图像的缩放版本已构建的输出装置。每个图像的大小可以分别缓存,并在一个单独的图像生产序列中产生的原始数据。
img
-指定要绘制的图像。如果这个方法不
img
是空的。
x
- nullx坐标。
y
- nully坐标。
width
-矩形的宽度。
height
-矩形的高度。
observer
对象有更多的图像转换通知。
false
如果图像像素仍在改变;
true
否则。
Image
,
ImageObserver
,
ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
public abstract boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
此操作相当于将指定的图像的宽度和高度填充一个给定的颜色的矩形,然后在它上面绘制图像,但可能更有效。
此方法立即返回在所有情况下,即使完成图像尚未加载,它没有抖动和转换为电流输出装置。
如果图像已经完全加载,其像素不被改变,那么drawImage
返回true
。否则,drawImage
返回false
和更多的图像可用或是时间去画一帧动画的过程,加载图像通知指定的图像观察。
img
-指定要绘制的图像。如果这个方法不
img
是空的。
x
- nullx坐标。
y
- nully坐标。
bgcolor
-背景颜色来画图像的透明部分下。
observer
对象有更多的图像转换通知。
false
如果图像像素仍在改变;
true
否则。
Image
,
ImageObserver
,
ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
public abstract boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
该图像被绘制在这个图形上下文的坐标空间的指定的矩形内,并在必要时进行缩放。透明像素绘制在指定的背景颜色。此操作相当于将指定的图像的宽度和高度填充一个给定的颜色的矩形,然后在它上面绘制图像,但可能更有效。
此方法立即返回在所有情况下,即使整个图像尚未攀登,抖动,并转换为电流输出装置。如果当前的输出表示尚未完成,然后drawImage
返回false
。为获得更多的图像时,过程加载图像通知指定的图像观察。
一个缩小版的图像不一定立即可用,只是因为对图像的缩放版本已构建的输出装置。每个图像的大小可以分别缓存,并在一个单独的图像生产序列中产生的原始数据。
img
-指定要绘制的图像。如果这个方法不
img
是空的。
x
- nullx坐标。
y
- nully坐标。
width
-矩形的宽度。
height
-矩形的高度。
bgcolor
-背景颜色来画图像的透明部分下。
observer
对象有更多的图像转换通知。
false
如果图像像素仍在改变;
true
否则。
Image
,
ImageObserver
,
ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
public abstract boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
此方法立即返回在所有情况下,即使图像区域被吸引尚未攀登,抖动,并转换为电流输出装置。如果当前的输出表示尚未完成,然后drawImage
返回false
。为获得更多的图像时,过程加载图像通知指定的图像观察。
这种方法通常使用图像的缩放版本渲染缩放矩形和执行的飞行所需的尺度。它不使用缓存,缩放版本的图像为这个操作。从源到目的地的图像缩放执行,使得源矩形的第一坐标被映射到目标矩形的第一坐标,并且第二源坐标被映射到第二目标坐标。图像缩放、翻转来保存这些映射。
img
-指定要绘制的图像。如果这个方法不
img
是空的。
dx1
-目标矩形的第一个角nullx坐标。
dy1
-目标矩形的第一个角nully坐标。
dx2
-目标矩形的第二角nullx坐标。
dy2
-目标矩形的第二角nully坐标。
sx1
-源矩形的第一个角nullx坐标。
sy1
-源矩形的第一个角nully坐标。
sx2
-源矩形的第二角nullx坐标。
sy2
-源矩形的第二角nully坐标。
observer
对象有更多的图像缩放和转换的通知。
false
如果图像像素仍在改变;
true
否则。
Image
,
ImageObserver
,
ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
public abstract boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
透明像素绘制在指定的背景颜色。此操作相当于将指定的图像的宽度和高度填充一个给定的颜色的矩形,然后在它上面绘制图像,但可能更有效。
此方法立即返回在所有情况下,即使图像区域被吸引尚未攀登,抖动,并转换为电流输出装置。如果当前的输出表示尚未完成,然后drawImage
返回false
。为获得更多的图像时,过程加载图像通知指定的图像观察。
这种方法通常使用图像的缩放版本渲染缩放矩形和执行的飞行所需的尺度。它不使用缓存,缩放版本的图像为这个操作。从源到目的地的图像缩放执行,使得源矩形的第一坐标被映射到目标矩形的第一坐标,并且第二源坐标被映射到第二目标坐标。图像缩放、翻转来保存这些映射。
img
-指定要绘制的图像。如果这个方法不
img
是空的。
dx1
-目标矩形的第一个角nullx坐标。
dy1
-目标矩形的第一个角nully坐标。
dx2
-目标矩形的第二角nullx坐标。
dy2
-目标矩形的第二角nully坐标。
sx1
-源矩形的第一个角nullx坐标。
sy1
-源矩形的第一个角nully坐标。
sx2
-源矩形的第二角nullx坐标。
sy2
-源矩形的第二角nully坐标。
bgcolor
-背景颜色来画图像的透明部分下。
observer
对象有更多的图像缩放和转换的通知。
false
如果图像像素仍在改变;
true
否则。
Image
,
ImageObserver
,
ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
public abstract void dispose()
Graphics
对象后不能使用
dispose
has被称为。
一个java程序运行时,大量的Graphics
对象可以在很短的时间内创造了。虽然垃圾收集器的定型过程也是同样的系统资源,最好是手动释放相关的资源,通过调用此方法而不是依靠定型过程可能没有运行完成的很长一段时间。
这是提供组件的paint
和update
方法的参数是由系统自动释放这些方法返回时,图形对象。为了提高效率,程序员应该叫dispose
完成时只有直接从一个组件或对象创建另一个Graphics
使用Graphics
对象。
public String toString()
Graphics
对象的值
String
对象。
@Deprecated public Rectangle getClipRect()
getClipBounds()
。
null
如果没有夹套。
public boolean hitClip(int x, int y, int width, int height)
x
的x坐标的矩形对夹测试
y
-矩形对芯片测试的y坐标
width
-矩形的宽度对夹测试
height
-矩形的对夹测试高度
true
如果指定矩形相交当前剪辑的界限;
false
否则。
public Rectangle getClipBounds(Rectangle r)
getClipBounds
在现有的矩形代替分配一个新的。此方法是指用户剪辑,这是独立的剪辑与设备的边界和窗口的可见性。如果没有剪辑已被设置,或者如果剪辑已经被使用
setClip(null)
,此方法返回指定的
Rectangle
。
r
-矩形,当前剪辑区域复制到。在这个矩形的任何电流值覆盖。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.