Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: HOW TO CREATE A PIECHART

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default HOW TO CREATE A PIECHART

    I need help in a project in davhid schmidt book . Here's the task :
    Here is the application that does this; test your coding of class PieChartWriter with it.

    import java.awt.*;
    public class TestPieChart
    { public static void main(String[] args)
    { PieChartWriter p = new PieChartWriter();
    p.setTitle("How I spend my day");
    p.setSlice1("Sleep: 7 hours", 7, Color.black);
    p.setSlice4("Recreation: 9 hours", 9, Color.gray);
    p.setSlice2("In class: 3 hours", 3, Color.blue);
    p.setSlice3("Homework: 5 hours", 5, Color.red);
    }
    }

    Please help me as soon as you can.
    Thank you


  2. #2
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: HOW TO CREATE A PIECHART

    Quote Originally Posted by s1mon1980 View Post
    I need help in a project in davhid schmidt book . Here's the task :
    Here is the application that does this; test your coding of class PieChartWriter with it.

    Please help me as soon as you can.
    Personally, I don't have that book ... and I don't know what is the PieChartWriter.
    So, what's your problem/question?
    Andrea, www.andbin.net SCJP 5 (91%) SCWCD 5 (94%)

    Useful links for Java beginners My new project Java Examples on Google Code

  3. #3
    Junior Member
    Join Date
    Jan 2014
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HOW TO CREATE A PIECHART

    PieChartWriter is the class that I should make . My question is how to start with this i have made few piecharts but not close with this one so i need to know how someone tell me a part of it.

  4. #4
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: HOW TO CREATE A PIECHART

    Quote Originally Posted by s1mon1980 View Post
    PieChartWriter is the class that I should make . My question is how to start with this i have made few piecharts but not close with this one so i need to know how someone tell me a part of it.
    Obviously, I know what is a "pie chart". The question is: do you need to generate an image file (e.g. png)? Or do you need to show the pie chart in a window? Or other?
    Andrea, www.andbin.net SCJP 5 (91%) SCWCD 5 (94%)

    Useful links for Java beginners My new project Java Examples on Google Code

  5. #5
    Junior Member
    Join Date
    Jan 2014
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HOW TO CREATE A PIECHART

    I have to show it in a window .

  6. #6
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: HOW TO CREATE A PIECHART

    Quote Originally Posted by s1mon1980 View Post
    I have to show it in a window .
    Ok, and how much do you know about Swing, components and custom painting?
    And are you sure that your PieChartWriter should have methods like setSlice1, setSlice2 etc..? In other words with the pie number "cabled" in the method name? So how many parts you want to have? fixed to 4? Potentially any number?
    Andrea, www.andbin.net SCJP 5 (91%) SCWCD 5 (94%)

    Useful links for Java beginners My new project Java Examples on Google Code

  7. #7
    Junior Member
    Join Date
    Jan 2014
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HOW TO CREATE A PIECHART

    i know a few think like how to put in pane , set visible and few other things . I'm sure it should have these methods , and yes its fixed .
    Here's the photo on how should it look:
    http://postimg.org/image/k8uvojuez/

  8. #8
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: HOW TO CREATE A PIECHART

    Quote Originally Posted by s1mon1980 View Post
    Here's the photo on how should it look:
    View image: Capture
    Ok, now the graphics appearance is clear. What are your further problems/questions? Are you able to create a JFrame that contains a panel in which you draw, for example, an initial circle?
    I can't support you all the day every ten minutes, continuing to ask you things .... you should have some basics, if not, please start at Creating a GUI With JFC/Swing.
    Then ask for specific problems/questions whenever is necessary.
    Andrea, www.andbin.net SCJP 5 (91%) SCWCD 5 (94%)

    Useful links for Java beginners My new project Java Examples on Google Code

  9. #9
    Junior Member
    Join Date
    Jan 2014
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HOW TO CREATE A PIECHART

    I just don't know how to create setSlice methods with three parameters within it(like testchart above) , other part is clear now thank you.

  10. #10
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: HOW TO CREATE A PIECHART

    Quote Originally Posted by s1mon1980 View Post
    I just don't know how to create setSlice methods with three parameters within it(like testchart above) , other part is clear now thank you.
    Before other things, you should understand (and eventually clarify here) what is the role of PieChartWriter class.

    I can think two possibilities:

    a) PieChartWriter is a simple "bean" class, that contains only those informations (with fields for datas and any necessary getter/setter method), and nothing else about graphical aspects. In this sense, PieChartWriter should be named as PieChart since it doesn't "write" anything. Then an instance of PieChart can be passed to a component to display those informations.

    or

    b) PieChartWriter is the panel that shows the pie chart. It still contains those informations (using fields, etc...) but the class also "knows" how to paint the chart into the panel.
    Andrea, www.andbin.net SCJP 5 (91%) SCWCD 5 (94%)

    Useful links for Java beginners My new project Java Examples on Google Code

  11. The Following User Says Thank You to andbin For This Useful Post:

    s1mon1980 (January 14th, 2014)

  12. #11
    Junior Member
    Join Date
    Jan 2014
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HOW TO CREATE A PIECHART

    ah i understand now , and i think it's B but still can't make a link with setSlice .
    But thank you very much i appreciate this

Similar Threads

  1. Why do I have to create a new Scanner?
    By Currahe in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 18th, 2012, 04:31 PM
  2. Trying to create a window...
    By Tedstriker in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 16th, 2012, 11:39 AM
  3. Create Application
    By sahilradotra in forum Java Theory & Questions
    Replies: 3
    Last Post: September 15th, 2012, 09:39 PM
  4. Where do I create my array?
    By SkynetSystems in forum Object Oriented Programming
    Replies: 7
    Last Post: September 2nd, 2011, 05:11 PM
  5. How to create submenu?
    By SHENGTON in forum Java ME (Mobile Edition)
    Replies: 3
    Last Post: January 14th, 2011, 11:55 PM