int iAngle = 0;
double currentPerimeter = 0;
double angle,r;
for(int i = 0 ; i < nbPeers ; i++) {
PEPeer peer = sortedPeers[i];
do {
angle = angles[iAngle];
r = rs[iAngle];
currentPerimeter += r;
if(iAngle + 1 < NB_ANGLES) iAngle++;
} while( currentPerimeter < i * perimeter / nbPeers);
angle = (4 * i - nbPeers) * Math.PI / (2 * nbPeers) - Math.PI / 2;
int[] triangle = new int[6];
int percent_received = peer.getPercentDoneOfCurrentIncomingRequest();
int percent_sent = peer.getPercentDoneOfCurrentOutgoingRequest();
// set up base line state
boolean drawLine = false;
// unchoked
if ( !peer.isChokingMe() || percent_received >= 0 ){
gcBuffer.setForeground(Colors.blues[1] );
drawLine = true;
}
// unchoking
if ( !peer.isChokedByMe() || percent_sent >= 0 ){
gcBuffer.setForeground(Colors.blues[3]);
drawLine = true;
}
// receiving from choked peer (fast request in)
if ( !peer.isChokingMe() && peer.isUnchokeOverride() && peer.isInteresting()){
gcBuffer.setForeground(Colors.green);
drawLine = true;
}
// sending to choked peer (fast request out)
if ( peer.isChokedByMe() && percent_sent >= 0 ){
gcBuffer.setForeground(Colors.green);
drawLine = true;
}
if ( drawLine ){
int x1 = x0 + (int) ( r * deltaYXs[iAngle] );
int y1 = y0 + (int) ( r * deltaYYs[iAngle] );
gcBuffer.drawLine(x0,y0,x1,y1);
}
if(percent_received >= 0) {
gcBuffer.setBackground(Colors.blues[Colors.BLUES_MIDDARK]);
double r1 = r - r * percent_received / 100;
triangle[0] = (int) (x0 + (r1-10) * deltaYXs[iAngle] + 0.5);
triangle[1] = (int) (y0 + (r1-10) * deltaYYs[iAngle] + 0.5);
triangle[2] = (int) (x0 + deltaXXs[iAngle] * 4 + (r1) * deltaYXs[iAngle] + 0.5);
triangle[3] = (int) (y0 + deltaXYs[iAngle] * 4 + (r1) * deltaYYs[iAngle] + 0.5);
triangle[4] = (int) (x0 - deltaXXs[iAngle] * 4 + (r1) * deltaYXs[iAngle] + 0.5);
triangle[5] = (int) (y0 - deltaXYs[iAngle] * 4 + (r1) * deltaYYs[iAngle] + 0.5);
gcBuffer.fillPolygon(triangle);
}
if(percent_sent >= 0) {
gcBuffer.setBackground(Colors.blues[Colors.BLUES_MIDLIGHT]);
double r1 = r * percent_sent / 100;
triangle[0] = (int) (x0 + r1 * deltaYXs[iAngle] + 0.5);
triangle[1] = (int) (y0 + r1 * deltaYYs[iAngle] + 0.5);
triangle[2] = (int) (x0 + deltaXXs[iAngle] * 4 + (r1-10) * deltaYXs[iAngle] + 0.5);
triangle[3] = (int) (y0 + deltaXYs[iAngle] * 4 + (r1-10) * deltaYYs[iAngle] + 0.5);
triangle[4] = (int) (x0 - deltaXXs[iAngle] * 4 + (r1-10) * deltaYXs[iAngle] + 0.5);
triangle[5] = (int) (y0 - deltaXYs[iAngle] * 4 + (r1-10) * deltaYYs[iAngle] + 0.5);
gcBuffer.fillPolygon(triangle);
}
int x1 = x0 + (int) (r * deltaYXs[iAngle]);
int y1 = y0 + (int) (r * deltaYYs[iAngle]);
gcBuffer.setBackground(Colors.blues[Colors.BLUES_MIDDARK]);
if(peer.isSnubbed()) {
gcBuffer.setBackground(Colors.grey);
}
/*int PS = (int) (PEER_SIZE);
if (deltaXY == 0) {
PS = (int) (PEER_SIZE * 2);
} else {
if (deltaYY > 0) {
PS = (int) (PEER_SIZE / deltaXY);
}
}*/
//PieUtils.drawPie(gcBuffer,(x1 - PS / 2),y1 - PS / 2,PS,PS,peer.getPercentDoneInThousandNotation() / 10);
PieUtils.drawPie(gcBuffer,x1 - PEER_SIZE / 2,y1 - PEER_SIZE / 2,PEER_SIZE,PEER_SIZE,peer.getPercentDoneInThousandNotation() / 10);
//gcBuffer.drawText(peer.getIp() , x1 + 8 , y1 , true);
}
gcBuffer.setBackground(Colors.blues[Colors.BLUES_MIDDARK]);