private static Shape generateStar(double x,double y,double innerRadius,double outerRadius,int pointsCount){
  GeneralPath path=new GeneralPath();
  double outerAngleIncrement=2 * Math.PI / pointsCount;
  double outerAngle=0.0;
  double innerAngle=outerAngleIncrement / 2.0;
  x+=outerRadius;
  y+=outerRadius;
  float x1=(float)(Math.cos(outerAngle) * outerRadius + x);
  float y1=(float)(Math.sin(outerAngle) * outerRadius + y);
  float x2=(float)(Math.cos(innerAngle) * innerRadius + x);
  float y2=(float)(Math.sin(innerAngle) * innerRadius + y);
  path.moveTo(x1,y1);
  path.lineTo(x2,y2);
  outerAngle+=outerAngleIncrement;
  innerAngle+=outerAngleIncrement;
  for (int i=1; i < pointsCount; i++) {
    x1=(float)(Math.cos(outerAngle) * outerRadius + x);
    y1=(float)(Math.sin(outerAngle) * outerRadius + y);
    path.lineTo(x1,y1);
    x2=(float)(Math.cos(innerAngle) * innerRadius + x);
    y2=(float)(Math.sin(innerAngle) * innerRadius + y);
    path.lineTo(x2,y2);
    outerAngle+=outerAngleIncrement;
    innerAngle+=outerAngleIncrement;
  }
  path.closePath();
  return path;
}

private static Shape generateStar ( double x , double y , double innerRadius , double outerRadius , int pointsCount ) { GeneralPath path = new GeneralPath ( ) ; double outerAngleIncrement = 2 * Math . PI / pointsCount ; double outerAngle = 0.0 ; double innerAngle = outerAngleIncrement / 2.0 ; x += outerRadius ; y += outerRadius ; float x1 = ( float ) ( Math . cos ( outerAngle ) * outerRadius + x ) ; float y1 = ( float ) ( Math . sin ( outerAngle ) * outerRadius + y ) ; float x2 = ( float ) ( Math . cos ( innerAngle ) * innerRadius + x ) ; float y2 = ( float ) ( Math . sin ( innerAngle ) * innerRadius + y ) ; path . moveTo ( x1 , y1 ) ; path . lineTo ( x2 , y2 ) ; outerAngle += outerAngleIncrement ; innerAngle += outerAngleIncrement ; for ( int i = 1 ; i < pointsCount ; i ++ ) { x1 = ( float ) ( Math . cos ( outerAngle ) * outerRadius + x ) ; y1 = ( float ) ( Math . sin ( outerAngle ) * outerRadius + y ) ; path . lineTo ( x1 , y1 ) ; x2 = ( float ) ( Math . cos ( innerAngle ) * innerRadius + x ) ; y2 = ( float ) ( Math . sin ( innerAngle ) * innerRadius + y ) ; path . lineTo ( x2 , y2 ) ; outerAngle += outerAngleIncrement ; innerAngle += outerAngleIncrement ; } path . closePath ( ) ; return path ; }
generates a star shape from the given location , radii , and points parameters . the shape is created by constructing a generalpath that moves between the inner and outer rings .
