private void drawCircleBar(Graphics g, int pullToTheLeftPixels, int angleToStartOn, int angleToEndOn, int colour)
{
GeneralPath pathDynamic = new GeneralPath();
strokeWidth= myWidth/17;
g.setColor(0xffffff);
if (stroke == null)
{
stroke = new Stroke(strokeWidth, Stroke.CAP_BUTT, Stroke.JOIN_ROUND, 1f);
}
//for testing
/*
if (progress++>=100)
{
progress=0;
}*/
//debug:
//g.drawRect(getX(),getY(), myWidth, myHeight);
//draw in centre so we can see where it is
//g.drawRect( getX()+(myWidth/2)-5,getY()+(myHeight/2)-5, 10, 10);
g.setFont(f);
g.setAntiAliased(true);
int pixelsToMoveTextAndImageDown = getHeight()/14;
//draw full arc
int sideAngle = 50; //the amount of degrees less than a semi circle (180)
double startAngle = Math.toRadians(angleToStartOn+sideAngle);//180 for perfect semi circle, but it isnt, so 220
double angleComplete = Math.toRadians(angleToEndOn-sideAngle);
int circleW = myHeight;
if (circleW>myWidth)
{
circleW=myWidth;
}
/////no need circleW-=strokeWidth*2;
circleW+=strokeWidth*3;
int circleH = circleW;
int xPos = getX()+((myWidth/2)-(circleW/2))-pullToTheLeftPixels;
int yPos = getY()+(myHeight/4);//getY()+myHeight/2;//getY()+strokeWidth;
pathStatic.arc(xPos, yPos, circleW, circleH , startAngle, angleComplete);
g.drawShape(pathStatic, stroke);
//_("progress:"+progress+" which is "+(progress*3.6));
String percentageStr = ""+progress+"%";
int stringWidth = f.stringWidth("XXX");
Image thumbImage = thumbsUp;
Image thumbImageSelected = thumbsUpSelected;
switch (myPos)
{
case PROGRESS_BAR_LEFT:
break;
case PROGRESS_BAR_RIGHT:
pullToTheLeftPixels = -(int)(stringWidth/1.1f);//so it sits a bit more right
thumbImage = thumbsDown;
thumbImageSelected = thumbsDownSelected;
pixelsToMoveTextAndImageDown = thumbsUp.getHeight()/3;
break;
}
//tweaks for different rews,
int yForThumb = f.getHeight()/3+yPos+thumbsUp.getHeight()/2;//(((getY()+myHeight/2)-f.getHeight()*2))-thumbsUp.getHeight()/2;//-thumbsUp.getHeight()/3)+pixelsToMoveTextAndImageDown;
//thumbsUp or down
g.drawImage(thumbImage, (((getX()+myWidth/2)-thumbsUp.getWidth()/2)-pullToTheLeftPixels)+stringWidth/3, yForThumb );
if (isSelected) //draw the pressed version if we know we have pressed it.
{
g.drawImage(thumbImageSelected, (((getX()+myWidth/2)-thumbsUp.getWidth()/2)-pullToTheLeftPixels)+stringWidth/3, yForThumb );
}
switch (myPos)
{
case PROGRESS_BAR_LEFT:
pixelsToMoveTextAndImageDown = thumbsDown.getHeight();//-thumbsDown.getHeight()/8;
break;
case PROGRESS_BAR_RIGHT:
pullToTheLeftPixels = -(int)(stringWidth/1.1f);//so it sits a bit more right
pixelsToMoveTextAndImageDown = -((thumbsDown.getHeight()/3)+f.getHeight()/4);//*2; // the text is above the thumb
break;
}
//add +stringWidth/3 here to nudge it to the right a touch, same with thumbs up image (since the circle is pulled left and we dont want
//this stuff to loook too close to edge
g.setColor(0xffffff);
g.drawString(percentageStr, (((getX()+myWidth/2)-stringWidth/2)-pullToTheLeftPixels)+stringWidth/3, yForThumb+pixelsToMoveTextAndImageDown);//(getY()+myHeight/2)+pixelsToMoveTextAndImageDown);
//blue progress bit
float progressAngle = (float)((progress*1.3f));
angleComplete = Math.toRadians(progressAngle);
g.setColor(colour);
pathDynamic.arc(xPos, yPos, circleW, circleH , startAngle, angleComplete);
//draw actual progress arc
g.drawShape(pathDynamic, stroke);