Java BasicStroke“模糊”

我正在尝试用Java编写一个简单的绘图applet,但是我遇到了BasicStroke的问题.最初,我的计划是试图以某种方式画一条宽度的线,但API显然不支持这一点.

我尝试使用BasicStroke,但结果只是一个模糊的混乱.我该如何修复这个模糊问题?

private void mousedrag_hook(Point point)
    {
        if(start == null)
            start = point;

            end = point;

            Graphics2D g2d = (Graphics2D)applInstance.buffer_g;
            g2d.setStroke(new BasicStroke(7));

            //g2d.fillOval(point.x - 5, point.y - 5, 10, 10);
            g2d.drawLine(start.x, start.y, end.x, end.y);
            applInstance.repaint();

            start = end;
    }
别忘了RenderingHints

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    g2d.setRenderingHint(
        RenderingHints.KEY_ANTIALIASING,
        RenderingHints.VALUE_ANTIALIAS_ON);
    ...
}
https://stackoverflow.com/questions/6991648/java-basicstroke-fuzzy

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:Java BasicStroke“模糊”