Conical Gradient Paint

Aaaaagggh! It's not an SVG. It's just a Perspective label component with corners radiused at 50% and a conic gradient.

My mistake. I glanced at it pretty quickly as I was heading out into the field.

Regardless, That would be an easy problem to solve with an SVG which is a lot easier to follow (support done by others down the road). That's how I would do it.

I ended up using the BufferedImage idea. Performance on painting the cone has increased a lot by doing that, even with using the ConicalGradientPaint. I also didn't have to do any scaling to get it to show up properly.

if (componentResized) {
  ConicalGradientPaint topConePaint = new ConicalGradientPaint(    false,
                                                          topConeGradientCenter,
                                                          topConeGradientOffset,
                                                          topConeGradientFractions,
                                                          new Color[]{Color.BLACK,binColorDark,binColorLight,binColorDarkish,Color.BLACK});
  
  topConeBufferedImage = new BufferedImage(topCone.getBounds().width,topCone.getBounds().height,BufferedImage.TYPE_INT_ARGB);
  Graphics2D gTopCone = topConeBufferedImage.createGraphics();
  gTopCone.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  gTopCone.setPaint(topConePaint);
  gTopCone.fill(topCone);
}

g.drawImage(topConeBufferedImage,0,0,null);

Thanks again for everyone's input.

5 Likes