Java2D:增加线宽
我想增加 Line2D 宽度。我找不到任何方法来做到这一点。我是否需要为此目的实际制作一个小矩形?
I want to increase the Line2D width. I could not find any method to do that. Do I need to actually make a small rectangle for this purpose?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用
setStroke
来设置Graphics2D
对象的笔划。http://www.java2s.com 中的示例给出你一些代码示例。
以下代码生成以下图像:
(请注意,
setStroke
方法是在Graphics
对象中不可用,您必须将其转换为Graphics2D
对象。)这篇文章已被重写为文章 此处。
You should use
setStroke
to set a stroke of theGraphics2D
object.The example at http://www.java2s.com gives you some code examples.
The following code produces the image below:
(Note that the
setStroke
method is not available in theGraphics
object. You have to cast it to aGraphics2D
object.)This post has been rewritten as an article here.
什么是
中风
:https://docs.oracle.com/javase/7 /docs/api/java/awt/BasicStroke.html
请注意,
Stroke
设置:正在设置线宽,因为
BasicStroke(float width)
:而且,它还会影响其他方法,例如 Graphics2D.drawLine(int x1, int y1, int x2, int y2) 和 Graphics2D.drawRect(int x, int y, int width, int height) ):
What is
Stroke
:https://docs.oracle.com/javase/7/docs/api/java/awt/BasicStroke.html
Note that the
Stroke
setting:is setting the line width,since
BasicStroke(float width)
:And, it also effects other methods like
Graphics2D.drawLine(int x1, int y1, int x2, int y2)
andGraphics2D.drawRect(int x, int y, int width, int height)
: