【发布时间】:2016-07-01 22:44:20
【问题描述】:
我正在尝试在饼图的一段(弧)和它的中心之间添加一些距离(例如 10px),但没有成功,这是我迄今为止尝试过的:
int value = 20; // example
double arcAngle = (value * 360 / 100);
double angle = 360 - (arcAngle / 2); // direction to add the distance to (center of arc)
double newX = pieCenterX + Math.cos(angle * Math.PI / 180.0) * 10;
double newY = pieCenterY + Math.sin(angle * Math.PI / 180.0) * 10;
// then drawing the arc with new x and y
g.fill(new Arc2D.Double(newX, newY, bounds.getWidth(), bounds.getHeight(), startAngle, arcAngle, Arc2D.PIE));
理想情况下,我应该得到这样的结果:
我不太了解如何解决这个问题,所以我的代码取自我在其他地方找到的示例。
【问题讨论】:
-
张贴minimal reproducible example 并在第二张图片中说明 10px 间隙应该在哪里..
标签: java geometry 2d pie-chart