Below is a full, short code example. I purposely used angles of 90 and
180, which seemed like the simplest case.
There seems to be a one pixel discrepancy between the fill and the
drawn line that extends roughly through the lower right quadrant.
Image of the problem: http://www.bounceswoosh.org/misc/pie.png
Is there something I should be doing differently in order to get the
line to exactly match the edge of the fill?
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class SimpleArcTest extends JPanel
{
protected int angles[] = {90, 90, 180};
protected Color colors[] = {Color.BLUE, Color.MAGENTA, Color.DARK_GRAY};
public static void main(String[] args)
{
JFrame frame = new JFrame();
JPanel panel = new SimpleArcTest();
panel.setBackground(Color.WHITE);
panel.setPreferredSize(new Dimension(400,400));
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
int startAngle = 0;
for (int i = 0; i < angles.length; i++)
{
g.setColor(colors[i]);
g.fillArc(getX(), getY(), getWidth(), getHeight(),
startAngle, angles[i]);
g.setColor(Color.BLACK);
g.drawArc(getX(), getY(), getWidth(), getHeight(),
startAngle, angles[i]);
startAngle += angles[i];
}
}
}

Signature
monique
Help us help you:
http://www.catb.org/~esr/faqs/smart-questions.html
Monique Y. Mudama - 25 Apr 2006 19:27 GMT
> Below is a full, short code example. I purposely used angles of 90
> and 180, which seemed like the simplest case.
[quoted text clipped - 6 lines]
> Is there something I should be doing differently in order to get the
> line to exactly match the edge of the fill?
It looks like most bug reports for the fillArc() and drawArc() methods
of Graphics have been closed, saying to use Arc2D instead.
Arc2D seems not to have these issues, so I guess that's my route.

Signature
monique
Help us help you:
http://www.catb.org/~esr/faqs/smart-questions.html