view raw
Emil Emil - 6 months ago 68
Java Question

Drawing Arc in Java

I need to draw a Pie Arc in Java with start angle 350 and end angle 20.The cordinate system I follow is as follows:-


The problem here is that the start angle is greater than the end angle.For the other way round I have managed to draw the arc.Any help would be great.


You will have a start angle and an 'extent' angle and not an end angle. So, I don't think you would be having problem drawing an arc.

import java.awt.Graphics;
import javax.swing.JFrame;

public class Test extends JFrame{
    public static void main(String[] args){
        new Test();
    public Test(){
    public void paint(Graphics g) {
        g.fillArc(100, 100, 100, 100, 70, 30);

enter image description here

Alternatively, you can use the Arc2D class as well. One more thing to note that in java, this is the default co-ordinate mechanism.