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 4 of 4

Thread: Creating a Triagular Wave in Java

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Creating a Triagular Wave in Java

    I was assign to do produce two graphs using Java. One is the Triangular Wave funtion that look like this:
    Fourier Series Examples: Triangle Wave

    and another for the half-wave rectifier.

    The professor suggested us to used the Fourier Series to approximate the graph of the triangular wave by using that series. The function for the Fourier Series can be found here:
    PlanetMath: common Fourier series

    My big problem is that I don't have any experience whatsoever in graphing functions using Java. I would like some of you to please give me some suggestions ( where should I start, which java library should I look at, what method would you use).

    I would really appreciate it.

    Thanks in advance.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Creating a Triagular Wave in Java

    Unfortunately, I don't think there's any standard API support for graphing a function directly. However, it is fairly simple to write your own swing utility to plot data given to it. Create your own class that extends JPanel, give it a list of points, and have it plot the data it is given. To plot, over-write the paint method, and draw lines that connect a point with it's two neighboring points (note that to plot the point, you will have to convert the coordinates because the standard x-y access has 0,0 as bottom left, while in Java 0,0 is top left).

    If your program must plot the data over any range and zoom, you can have your panel compute the data itself, and use the same data plotter to automatically update to the new graph.

    There might be some API packages other users have created, in which case you can probably do a google search to find some.

  3. #3
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts
    Last edited by Darryl.Burke; March 8th, 2010 at 10:12 PM.

  4. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Creating a Triagular Wave in Java

    Inadvertently double posted, removed.
    db
    Last edited by Darryl.Burke; March 8th, 2010 at 04:19 AM.

Similar Threads

  1. Creating program Blackjack - Dr.Java
    By TheUntameable in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 20th, 2010, 12:54 PM
  2. Creating new instance
    By vluong in forum Object Oriented Programming
    Replies: 2
    Last Post: November 28th, 2009, 11:35 PM
  3. Replies: 2
    Last Post: October 29th, 2009, 06:13 PM
  4. creating a gui
    By rsala004 in forum AWT / Java Swing
    Replies: 2
    Last Post: July 21st, 2009, 02:17 AM
  5. Creating A Count Matrix In Java
    By statsman5 in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: July 14th, 2009, 04:40 PM