dcsimg
How can i create a Pie chart with java2D ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ronen_portnoy
Posted On:   Thursday, March 20, 2003 03:01 AM

How can i create a Pie chart with java2D ?

Re: How can i create a Pie chart with java2D ?

Posted By:   Bahman_Barzideh  
Posted On:   Thursday, March 20, 2003 06:21 AM

There are a number of issues involved with your question. I will address
only one, How to do the actual drawing. You need to create your own
custom Component (JComponent if you use Swing) class. This class should supply its own paintComponent () method. This method is called by the
system when the Component (JComponent) is to paint itself. The sole
input into this method is a Graphics object, which can be
used to draw lines, shapes, and text to the screen. The input parameter
is actually of type Graphics2D (a subclass of Graphics). I believe you will end
up using Graphics2D.draw (Shape shape) to draw objects of type Arc2D. With each Arc2D as a piece of your pie.


There are a number of other methods that your custom
Component (JComponent) class should provide (e.g. getPreferredSize (), contains ()) depending on
you application.



You can find a good primer on how Java GUIs work on Sun's web site (http://java.sun.com/docs/books/tutorial/uiswing/). I would
suggest reading through this trail before getting started with your code.
You can also find a number of examples of customized JComponent in this trail.



Finally, I would suggest you use Swing instead of AWT. It is more efficient and provides a larger number of predefined components than
AWT.


About | Sitemap | Contact