我正在使用java绘制曲线箭头,
但是我不能把箭头放在正确的位置
请帮助我这是我到目前为止所做的, 图标应该是动态尺寸,所以都应该按照颜色绘制 m_size变量
谢谢
public void paintIcon(Component c, Graphics g, int x, int y){
Graphics2D g2 = (Graphics2D)g;
Object hintOriginal = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int strokeSize = m_size/6;
Stroke strokeOriginal = g2.getStroke();
g2.setStroke(new BasicStroke(strokeSize ,BasicStroke.CAP_SQUARE,BasicStroke.JOIN_MITER));
g2.drawArc(x+(strokeSize/2), y+(strokeSize/2), m_size-(strokeSize*2), m_size-(strokeSize*2), 45, 180);
g2.setStroke(strokeOriginal);
int arrSize = (m_size/4) + strokeSize;
int[] xArr = new int[3];
int[] yArr = new int[3];
xArr[0] = x;
xArr[1] = x + arrSize;
xArr[2] = x + (arrSize/2);
yArr[0] = y;
yArr[1] = y;
yArr[2] = y - (arrSize/2);
AffineTransform origXform = g2.getTransform();
AffineTransform newXform = (AffineTransform)(origXform.clone());
newXform.rotate(Math.toRadians(135) ,x+m_size/2 ,y+m_size/2);
g2.setTransform(newXform);
g2.fillPolygon(xArr ,yArr ,3);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, hintOriginal);
}