Jul 14, 2011

Drawing an Arc in java

Here is a useful example of drawing an arc in java.

final static BasicStroke wideStroke = new BasicStroke(1.0f);
public void init() {
setBackground(Color.white);
setForeground(Color.white);
}

public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);

g2.setPaint(Color.gray);
int x = 5;
int y = 7;

g2.setStroke(wideStroke);
g2.draw(new Arc2D.Double(0, 0, 200, 200, 0, 360, Arc2D.OPEN));
g2.drawString("Arc2D", x, y);
g2.drawString("Here is the rectangular down-right most boundary point", x+200, y+200);
}

Reference
Reference Arc2D

No comments:

Down with the Dictatorship!

    "Let them hate me, so that fear me" - Caligula 41AD