在用 Java
D 進行畫圖時可以非常方便的設置線條的粗細及接頭的形狀
下面是一個簡單的例子供大家參考
float thick =
f; //設置畫刷的粗細為
BufferedImage bi = new BufferedImage(
BufferedImage
TYPE_INT_RGB);
Graphics
D g = (Graphics
D)bi
getGraphics();
Stroke stroke = g
getStroke(); //得到當前的畫刷
g
setStroke(new BasicStroke(thick
BasicStroke
CAP_SQUARE
BasicStroke
JOIN_ROUND)); //設置新的畫刷
g
draw(new Line
D
Float(x
y
x
y
)); 畫線
g
setStroke( stroke ); //將畫刷復原
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19150.html