【发布时间】:2012-08-01 02:52:37
【问题描述】:
当您使用Graphics2D.scale(); 绘制形状时,轮廓粗细也会被缩放。
有没有办法在不缩放线条粗细的情况下绘制它?除了使用上述函数之外,也许还有另一种有效的方法来扩展它?
【问题讨论】:
标签: java scale draw shape graphics2d
当您使用Graphics2D.scale(); 绘制形状时,轮廓粗细也会被缩放。
有没有办法在不缩放线条粗细的情况下绘制它?除了使用上述函数之外,也许还有另一种有效的方法来扩展它?
【问题讨论】:
标签: java scale draw shape graphics2d
This question is similar。看来您必须弄乱 Stroke 对象才能设置正确的线宽。
【讨论】:
您必须将绘图保存为线向量列表,并以各种尺寸缩放和渲染绘图以保持所需的线条粗细。
【讨论】:
我刚刚找到了解决我自己问题的方法。我不知道它的效率如何,但它按预期工作:
Area area = new Area(myShape); //myShape is the shape I want to scale
AffineTransform at = new AffineTransform();
at.scale(2,2);
area = area.createTransformedArea(at);
graphics2d.draw(area); //graphics2d is the Graphics2D instance to do the drawing
也许有人可以告诉我这是否是一个好方法?
【讨论】: