[英]JSVGCanvas svg is blurry
I have pretty much copy pasted the code from http://people.apache.org/~clay/batik/svgcanvas.html but the svg that is outputing is blurry. 我使用了 fontawesome 和材质 ui svg 但两者都很模糊。 我究竟做错了什么? 这是我的代码:
public class GUI extends JFrame{
public void init(){
initFrame();
CardLayout cl = new CardLayout();
JPanel panel = new JPanel(cl);
panel.add(createHome(), "HOME");
panel.setBackground(new Color(200, 0, 50));
cl.show(panel, "HOME");
add(panel);
setSize(1280, 720);
setVisible(true);
}
private JPanel createHome(){
JPanel p = new JPanel(new BorderLayout());
{
JPanel d = new JPanel(new FlowLayout(FlowLayout.LEFT));
d.setBackground(new Color(0, 0, 0, 0));
p.add(d, BorderLayout.PAGE_START);
JSVGCanvas svg = new JSVGCanvas();
d.setSize(this.getWidth(), 50);
d.add(svg);
String s = new File("images/userIcon3.svg").toURI().toString();
svg.setMySize(new Dimension(200, 200));
svg.setURI(s);
}
p.setBackground(new Color(0, 50, 200));
p.setSize(this.getWidth(), this.getHeight());
return p;
}
private void initFrame(){
int width = 1280, height = 720;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int swidth = screenSize.width, sheight = screenSize.height;
setTitle("Travelling Agency");
setLocation((swidth - width) / 2, (sheight - height) / 2); //Position it in the center
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
因此,在我的另一个问题(在这里)的帮助下,我得出了这个结论。
由于我正在使用 14 英寸屏幕的笔记本电脑,Windows 建议将我的屏幕缩放到 125% 以提高可读性。
因此,在此答案的帮助下(此处),我将 java.exe 的“高 DPI 缩放覆盖”设置为“系统” 。
但即使它修复了 svg 的显示方式,它的文本也存在问题。 所以我添加了 System.setProperty("awt.useSystemAAFontSettings","on"); System.setProperty("swing.aatext", "true"); @JustanotherJavaprogrammer 在评论中提到,现在一切似乎都已修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.