File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes HOW to draw an ARC on a Frame / Panel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "HOW to draw an ARC on a Frame / Panel" Watch "HOW to draw an ARC on a Frame / Panel" New topic
Author

HOW to draw an ARC on a Frame / Panel

Vaibhav Manwatkar
Greenhorn

Joined: Mar 20, 2005
Posts: 7
Hello Friends,
I want to draw a pie chart in which I am using fillArc() to draw the PIE chart. but I have to use Frame or Panel for it, I can't Use Applets because the values using which I will draw the arc are in DataBase and Applets can't access databases. So what to do if I want to draw an arc on Frame or Panel...

Its urgent... please reply if you know...


------------<br />Regards,<br />Vaibhav..<br />SCJP 1.4<br />------------
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
You mention Frame and Panel which are AWT components so I assume you want to work in the AWT vis–a–vis Swing. Some suggestions:
1 — create a class that extends either Canvas or Panel and override its paint method to do your drawing

2 — import the java.awt.geom package which gives access to the Arc2D class. You will need the Graphics2D context (g2) to draw/fill your arcs.

3 — consider basing all drawing calculations relative to the center of the drawing surface. Math.atan2(y1 - y2, x1 - x2) is a convenient way to get the angle of rotation for any pie slice.

4 — it takes a little experimenting to figure out how to use Arc2D; the Arc2D api is a starting point. The java2D tutorial has an example on the Stroking and Filling Graphics Primitives page.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HOW to draw an ARC on a Frame / Panel
 
Similar Threads
unreported jdbc exception
GIF encoding in JSP
create chart application in java
applets - pie charts
EventHandling on pi-chart