public class BasicStroke extends Object implements Stroke
BasicStroke
类定义为图形元素的轮廓渲染属性的基本设置,呈现一
Graphics2D
对象有其笔画属性设置为该
BasicStroke
。渲染属性定义的
BasicStroke
描述用钢笔绘制沿一个
Shape
和装饰应用轮廓两端和
Shape
路径段的加入使标志的形状。这些属性包括:
SEG_CLOSE
。三种不同的装饰:
CAP_BUTT
,
CAP_ROUND
,和
CAP_SQUARE
。
SEG_CLOSE
端点相交的装饰应用。三种不同的装饰:
JOIN_BEVEL
,
JOIN_MITER
,和
JOIN_ROUND
。
Shape
论点。当一个
Graphics2D
对象使用一个
Stroke
对象重新定义路径的一
draw
方法的执行过程中,几何是在其原来的形式提供在
Graphics2D
变换属性应用。因此,属性如笔的宽度在
Graphics2D
对象的用户空间坐标系统的解释和进行缩放和剪切作用的用户空间设备空间的变换,特别
Graphics2D
。例如,一个呈现的形状轮廓的宽度不仅取决于这
BasicStroke
宽度属性,而且在
Graphics2D
对象的变换属性。考虑下面的代码:
// sets the Graphics2D object's Transform attribute g2d.scale(10, 10); // sets the Graphics2D object's Stroke attribute g2d.setStroke(new BasicStroke(1.5f));假设没有其他缩放转换添加到
Graphics2D
对象,由此将约15像素宽。作为示例代码演示,浮点线提供了更好的精度,尤其是当大的变换是用一个
Graphics2D
对象。当一条对角线是对角线时,精确的宽度取决于渲染管线如何选择哪个像素来填充,因为它可以追溯到理论加宽的轮廓。选择象素打开受抗锯齿属性因为抗锯齿渲染管线,可以选择部分覆盖的像素的颜色。
在用户空间坐标系统和渲染过程的更多信息,见Graphics2D
类注释。
Graphics2D
Modifier and Type | Field and Description |
---|---|
static int |
CAP_BUTT
端未闭合的子路径冲段没有添加装饰。
|
static int |
CAP_ROUND
端未闭合的子路径冲段与圆形装饰,有一个半径相等的钢笔宽度的一半。
|
static int |
CAP_SQUARE
端未闭合的子路径冲段方形投影延伸段距离相等的线宽度一半的结束。
|
static int |
JOIN_BEVEL
连接路径段通过连接其宽轮廓的外角与一个直线段。
|
static int |
JOIN_MITER
通过将它们的外部边缘延伸,直到它们满足的路径段连接。
|
static int |
JOIN_ROUND
通过在一个行宽的半径圆角处的圆角连接路径段。
|
Constructor and Description |
---|
BasicStroke()
构建与所有属性默认值的一个新的
BasicStroke 。
|
BasicStroke(float width)
构建了一个坚实的
BasicStroke 与指定线宽与盖的默认值和加入方式。
|
BasicStroke(float width, int cap, int join)
构建了一个具有指定属性的固体
BasicStroke 。
|
BasicStroke(float width, int cap, int join, float miterlimit)
构建了一个具有指定属性的固体
BasicStroke 。
|
BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase)
构建具有指定属性的新
BasicStroke 。
|
Modifier and Type | Method and Description |
---|---|
Shape |
createStrokedShape(Shape s)
返回一个
Shape 其内部定义的抚摸轮廓指定
Shape 。
|
boolean |
equals(Object obj)
如果一个测试指定的对象是否等于这
BasicStroke 首先通过测试它是否是一个
BasicStroke 然后比较其宽度、加入、帽、斜接限制,短跑,并与这
BasicStroke 冲刺阶段属性。
|
float[] |
getDashArray()
返回表示虚线段的长度的数组。
|
float |
getDashPhase()
返回当前的冲刺阶段。
|
int |
getEndCap()
返回结束盖样式。
|
int |
getLineJoin()
返回行连接样式。
|
float |
getLineWidth()
返回行的宽度。
|
float |
getMiterLimit()
返回斜接限制加入。
|
int |
hashCode()
返回此行程hashCode。
|
@Native public static final int JOIN_MITER
@Native public static final int JOIN_ROUND
@Native public static final int JOIN_BEVEL
@Native public static final int CAP_BUTT
@Native public static final int CAP_ROUND
@Native public static final int CAP_SQUARE
@ConstructorProperties(value={"lineWidth","endCap","lineJoin","miterLimit","dashArray","dashPhase"}) public BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase)
BasicStroke
。
width
-这
BasicStroke
宽度。宽度必须大于或等于0.0f。如果宽度设置为0.0f,笔画呈现为目标设备和反薄的线提示设置。
cap
-一个
BasicStroke
两端的装饰
join
-装饰应用路径段相遇
miterlimit
-极限平衡人字加入。的miterlimit必须大于或等于1.0f。
dash
代表潇洒的阵列模式
dash_phase
-偏移量开始冲刺模式
IllegalArgumentException
-如果
width
是负的
IllegalArgumentException
-如果
cap
不是cap_butt,cap_round或cap_square
IllegalArgumentException
-如果
miterlimit
小于1,
join
是join_miter
IllegalArgumentException
-如果
join
不是join_round,join_bevel,或join_miter
IllegalArgumentException
-如果
dash_phase
是负的,
dash
不
null
IllegalArgumentException
-如果
dash
长度为零
IllegalArgumentException
如果破折号长度为零。
public BasicStroke(float width, int cap, int join, float miterlimit)
BasicStroke
。
width
的
BasicStroke
宽度
cap
-一个
BasicStroke
两端的装饰
join
-装饰应用路径段相遇
miterlimit
-极限平衡人字加入
IllegalArgumentException
-如果
width
是负的
IllegalArgumentException
-如果
cap
不是cap_butt,cap_round或cap_square
IllegalArgumentException
-如果
miterlimit
小于1,
join
是join_miter
IllegalArgumentException
-如果
join
不是join_round,join_bevel,或join_miter
public BasicStroke(float width, int cap, int join)
BasicStroke
。
miterlimit
参数的情况下,默认是允许或是不必要的和没有被指定为join_miter。
width
的
BasicStroke
宽度
cap
-一个
BasicStroke
两端的装饰
join
-装饰应用路径段相遇
IllegalArgumentException
-如果
width
是负的
IllegalArgumentException
-如果
cap
不是cap_butt,cap_round或cap_square
IllegalArgumentException
-如果
join
不是join_round,join_bevel,或join_miter
public BasicStroke(float width)
BasicStroke
与指定线宽与盖的默认值和加入方式。
width
的
BasicStroke
宽度
IllegalArgumentException
-如果
width
是负的
public BasicStroke()
BasicStroke
。默认属性是一个坚实的线宽度为1,cap_square,join_miter,10个斜接限制。
public Shape createStrokedShape(Shape s)
Shape
其内部定义的抚摸轮廓指定
Shape
。
createStrokedShape
接口
Stroke
s
-
Shape
边抚摸
Shape
的抚摸。
public float getLineWidth()
Graphics2D
类注释。
BasicStroke
线宽。
Graphics2D
public int getEndCap()
BasicStroke
端盖式作为一个可能的端帽样式定义静态
int
值。
public int getLineJoin()
BasicStroke
风格作为一个定义可能加入方式的静态
int
值。
public float getMiterLimit()
BasicStroke
。
public float[] getDashArray()
Shape
抚摸,用户空间的距离,笔旅行积累。将距离值用于索引到数组中。该笔是不透明的,当其目前的累积距离映射到一个偶数的数组元素,而透明的,否则。
public float getDashPhase()
float
价值。
public int hashCode()
hashCode
方法重写,继承类
Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public boolean equals(Object obj)
BasicStroke
首先通过测试它是否是一个
BasicStroke
然后比较其宽度、加入、帽、斜接限制,短跑,并与这
BasicStroke
冲刺阶段属性。
equals
方法重写,继承类
Object
obj
-指定的对象来比较这
BasicStroke
true
如果宽度、加入、帽、斜接限制,冲,冲相位是相同的两个对象;
false
否则。
Object.hashCode()
,
HashMap
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.