2016-07-01 12 views
0

私はいくつかの距離を追加しようとしている(例えば10pxのを)爆発し、それが成功せず、中心だが、ここで私はこれまで試したものです:のJava 2Dは、円グラフのセグメント(弧)の間円グラフセグメント

enter image description here

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)); 

理想的には私はそのようなもので終わる必要があります:私はTHIにアプローチする方法について多くを知らない

enter image description here

私のコードは他の場所にある例から抜粋したものです。

+0

投稿[MCVE]と10pxのギャップがあるべき場所次の写真に説明.. – user1803551

答えて

1

通常、ゼロ角はOX方向(右)です。だから、(あなたのシステムが反時計回りである座標場合)

double angle = 90 + 360 - (arcAngle/2); 
+0

大きな感謝を作品90度で補正をしなければなりません! –