简体   繁体   English

如何在Swing中以高分辨率绘制?

[英]How to draw in high resolution in Swing?

Is there is a way to draw in high resolution in Swing? 是否有办法在Swing中以高分辨率绘制? I tried to draw a simple shapes and the resolution of these shapes is very low. 我试图绘制一个简单的形状,这些形状的分辨率非常低。

You probably can't control the resolution in Swing, but you can use the rendering hints attribute from Graphics2D to tweak on the rendering quality: 您可能无法控制Swing中的分辨率,但您可以使用Graphics2D渲染提示属性来调整渲染质量:

Use the Graphics2D class rendering hints attribute to specify whether you want objects to be rendered as quickly as possible or whether you prefer that the rendering quality be as high as possible. 使用Graphics2D类渲染提示属性指定是否希望尽可能快地渲染对象,或者是否希望渲染质量尽可能高。

Take a look here: Controlling Rendering Quality 看看这里: 控制渲染质量

You can try turning anti-aliasing on. 您可以尝试打开抗锯齿功能。

public void paint(Color c, Polygon p, Graphics g){
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHints(new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setColor(c);
g2d.fillPolygon(p);
}

There is also more documentation here 还有更多的文档在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM