How do I make a sinus graph GUI

Hey! Anyone know how a script that easily makes a sinus graph using GUI. I use Eclipse as editor!

Using JFreeChart
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.*;
import org.jfree.ui.*;
public class SinChart extends JFrame
    public SinChart(String s)
        super(s);
        XYDataset xyDataset = createDataset();
        JFreeChart jfreechart = createChart(xyDataset);
        ChartPanel chartpanel = new ChartPanel(jfreechart);
        chartpanel.setPreferredSize(new Dimension(800, 400));
        setContentPane(chartpanel);
    private static XYDataset createDataset()
        XYSeries sinSeries = new XYSeries("Sin");
        XYSeries cosSeries = new XYSeries("Cos");
        for (double x = 0.0; x < 720; x += 10)
            sinSeries.add(x, Math.sin(Math.toRadians(x)));
            cosSeries.add(x, Math.cos(Math.toRadians(x)));
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        seriesCollection.addSeries(sinSeries);
        seriesCollection.addSeries(cosSeries);
        return seriesCollection;
    private static JFreeChart createChart(XYDataset xydataset)
        JFreeChart jfreechart = ChartFactory.createXYLineChart("Sin Curve Demo", "Angle (Deg)", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false);
        jfreechart.setBackgroundPaint(Color.white);
        XYPlot xyplot = (XYPlot)jfreechart.getPlot();
        xyplot.setBackgroundPaint(Color.lightGray);
        xyplot.setDomainGridlinePaint(Color.white);
        xyplot.setRangeGridlinePaint(Color.white);
        return jfreechart;
    public static JPanel createDemoPanel()
        JFreeChart jfreechart = createChart(createDataset());
        return new ChartPanel(jfreechart);
    public static void main(String args[])
        SinChart sinCosChart = new SinChart("Sin & Cos Curve Demo");
        sinCosChart.pack();
        sinCosChart.setVisible(true);
}If this is homework then I bet this solution is not acceptable to the person marking the homework!

Similar Messages

  • How can I make a waveform graph store the entire wave, not just the current time period and how can I save the actual graph?

    I am taking temp readings with a 4 channel DAQ, sending them to a waveform graph and exporting the data to excel, how do I manipulate the graph to take a continuous reading as opposed to losing the previous GUI and how can I save the entire graph?
    Using LabVIEW 2011 operating on Windows 7 professional. 

    That is the nature of the chart -- everything not in the history is lost (it is a FIFO buffer of length=1024 samples by default).
    The scroll bar is probably grayed out because you're show all of the data.
    Attached is a program that will add 5 random points to a graph and prompt you for a file location where to save a JPG snapshot of the graph.  It's not particularly good programming style, but it has all of the elements/concepts you're after. 
    Attachments:
    graph.vi ‏14 KB

  • Using the report generation toolkit, how do I make a bar graph verticle instead of horizontle?

    The attached vi is similar to what I am using, and it produces an Excel bar chart. I would really like to create the same chart, only vertically instead of horizontly. I have tried all kinds of things that don't work. Is there a way to do this that does work. I want a result similar to rotating the produced chart 90 degrees CCW.
    Thank you!
    Attachments:
    Chart Test.vi ‏20 KB

    you want to use a xy-graph.
    you can right click the plot legend to make a bar graph vertical.
    Harold Timmis
    [email protected]
    Orlando,Fl
    *Kudos always welcome
    Attachments:
    bargraph2.jpg ‏91 KB

  • How do I make an XY-Graph plot points over time?

    I am building a program to plot and take data of a relationship between two voltages.  One is voltage is uniquely dependent on the other.  So far I have successfully built an XY-Graph to plot the voltages against each other (Voltage1 along the x-axis and Voltage2 along the y-axis).  However, the XY-Graph only diplays the point (V1, V2) at the instantaneous time I am looking at it, and does not continuously plot different points as I vary the independent voltage.  I need the graph to display all the points that occur as I vary the independent voltage.  As of right now, all I see is one little cursor that moves all over the graph as I vary it.  My program consists of a While Loop that contains all of the following:  two seperate data anolog input functions that take both voltage separately from my board.  The the output samples from each 'AI Sample' function are then bundled into one cluster using the 'bundle' function.  The cluster output from the 'bundle' function is then wired to a 'build array' function.  The 1-D array output from the 'build array' function is then wired to my 'XY-Graph'.  How do I get the XY-Graph to plot a point every millisecond or so?

    Bundling and then using the Build Array is not correct. Yuo can see the correct method in the help for an XY Graph below. In order to use the normal XY Grpah, you would have two shif registers. One for the X array and one for the Y. Bundle the two arrays and then wire to the graph.
    The other way is to use the Express XY Graph. With that, you can just wire your scalars to the X and Y inputs and set the Reset input to false.
    Message Edited by Dennis Knutson on 11-12-2007 06:32 PM
    Attachments:
    XY Graph 1.PNG ‏21 KB
    XY Graph 2.PNG ‏6 KB

  • How do I make a line graph that shows temperature readings taken on specific dates?

    I need to make a chart of my wife's temperatures taken via ovulation thermometer. All I need is a line graph that shows the temperatures on the y axis and the dates the measurements were taken on the x axis.
    What is the easiest way to do this? Please explain in detail as I have almost no knowledge regarding Numbers. Thanks.

    You can construct a Line graph or a Scatter graph to display this.
    The two are similar, but require the data to be set up differently.
    A Line graph is a Category graph.
    Each 'date' is a text value that names a category. The categories are equally spaced along the category axis. Measurements taken on day 1, day 2 and day 4 would be equally spaced with respect to the category axis.
    Each temperature reading is a numerical value, and is represented on the graph by the distance it is placed from (and usually above) the category axis.
    A Scatter graph has two value axes.
    Each Date is a Date and Time value. The position of these values depends on the value itself. Measurements taken on February 1, February 2 and February 4 wound not be equally spaced. Along the Date axis, the space between the second and third dates would be twice as wide as that between the first and second cates.
    Each temperature reading is a numerical value, and is represented on the graph in the same manner as in the Line graph.
    Here's an example of each, using the same data set.
    For the Line graph (left), the Category labels (dates) are placed in a Header column, and the temperatures in a non-header column,
    For the Scatter graph, both the dates and the temperatures are in non-header columns. The Chart Inspector was used to Connect the data points with straight line segments, and the weight of these lines (and size of the data point markers) was increased to more closely match the weights and sizes in the Line graph.
    Data on the graphs is not intended to have any similarity to temperatures measured for your purposes.
    The construct the line graph:
    Set up the data and labels as described.
    Select the cells containing the data (column B in my case).
    Click the Chart button and choose the Line Chart.
    To construct the scatter chart:
    Set up the data as described.
    Select the cells containing the date and temperature data (columns A and B for mine)
    Click the Chart button, and select the Scatter Chart button (third from the bottom),
    In the Chart inspector, click the Series button, then set the Connection Points menu to Straight. Change the Data Point size yo 15.
    Click anywhere on the line to select it, then in the Stroke section of the Format bar, set the line weight to 4 points.
    Click on the box containing the dates (under the chart), then click the ruler icon in the Inspector to show the metrics inspector. Use the Rotate control to set the angle for the dates to about 75°.
    Click on the label for this axis (Dates) and drag it to a position below the date labels.
    Regards,
    Barry

  • How can i make a bar graph in numbers to track trends

    I have a table with columns A-K. All the columns have needed data for other things.  I need to track trends of incorrect input by staff.  Column A has the date and column K has a 1 if incorrect or it's blank if correct.   I only need to use the month as I need to track total incorrect for the month to see if there is a downward or upward trend as training progresses.  (i need to create a line graph that shows the total incorrect per month)  I will be tracking for a long period of time so would be nice if the graph updated as I input more info into the table.

    Jan 1, 2014 12:00:00 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Meyers, Rebecka - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 2, 2014 7:33:59 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Meyers, Rebecka - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 3, 2014 7:56:00 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Skarda, David - Pediatric Surgery
    CONTAMINATED
    540.9
    Jan 3, 2014 4:17:00 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Skarda, David - Pediatric Surgery
    DIRTY
    540.0
    Jan 5, 2014 9:05:59 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Skarda, David - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 5, 2014 10:22:59 AM
    APPENDECTOMY (PEDS)
    Skarda, David - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 6, 2014 11:06:00 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Skarda, David - Pediatric Surgery
    CONTAMINATED
    540.1
    Jan 7, 2014 8:38:00 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Scaife, Eric - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 8, 2014 7:42:59 PM
    APPENDECTOMY (PEDS)
    Black, Richard - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 9, 2014 4:31:00 PM
    APPENDECTOMY (PEDS)#1
    Black, Richard - Pediatric Surgery
    CONTAMINATED
    541.0
    Jan 10, 2014 9:14:00 AM
    APPENDECTOMY (PEDS)#2
    Black, Richard - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.0
    1
    Jan 10, 2014 3:23:00 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)#3
    Barnhart, Douglas - Pediatric Surgery
    CONTAMINATED
    540.9
    Jan 12, 2014 11:09:00 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)#4
    Barnhart, Douglas - Pediatric Surgery
    CONTAMINATED
    540.0
    1
    Jan 12, 2014 3:52:00 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)#5
    Barnhart, Douglas - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 12, 2014 9:28:59 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)#6
    Barnhart, Douglas - Pediatric Surgery
    CONTAMINATED
    540.9
    Jan 13, 2014 5:47:00 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Scaife, Eric - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 13, 2014 7:19:00 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Scaife, Eric - Pediatric Surgery
    CONTAMINATED
    540.9
    Jan 14, 2014 12:52:00 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Scaife, Eric - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.0
    1
    Jan 16, 2014 7:33:00 AM
    APPENDECTOMY (PEDS)
    Black, Richard - Pediatric Surgery
    DIRTY
    540.9
    Jan 16, 2014 8:25:00 AM
    APPENDECTOMY (PEDS)
    Black, Richard - Pediatric Surgery
    DIRTY
    540.0
    Jan 16, 2014 10:51:00 AM
    APPENDECTOMY (PEDS)
    Black, Richard - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 17, 2014 7:58:59 AM
    APPENDECTOMY (PEDS)
    Barnhart, Douglas - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 18, 2014 4:49:00 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Scaife, Eric - Pediatric Surgery
    CONTAMINATED
    540.9
    Jan 19, 2014 8:19:00 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Scaife, Eric - Pediatric Surgery
    CONTAMINATED
    540.9
    Jan 20, 2014 7:30:00 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Scaife, Eric - Pediatric Surgery
    CLEAN-CONTAMINATED
    540.9
    1
    Jan 20, 2014 9:43:00 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Scaife, Eric - Pediatric Surgery
    CONTAMINATED
    540.9
    Jan 20, 2014 11:16:00 AM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Scaife, Eric - Pediatric Surgery
    DIRTY
    540.0
    Jan 20, 2014 12:48:00 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Scaife, Eric - Pediatric Surgery
    NWCA
    540.9
    1
    Jan 20, 2014 9:48:59 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Rollins, Michael - Pediatric Surgery
    CONTAMINATED
    540.9
    Jan 22, 2014 12:08:00 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Barnhart, Douglas - Pediatric Surgery
    CLEAN
    540.9
    1
    Jan 22, 2014 5:38:00 PM
    APPENDECTOMY LAPAROSCOPY (PEDS)
    Rollins, Michael - Pediatric Surgery
    DIRTY
    540.0

  • How do i make a line graph

    i have tried to make scater plots, but it wont let input idividual information on to it

    Select the chart.
    Open the inspector.
    Choose Chart Inspector.
    Click Edit Data...
    This will open the data table feeding the chart.
    Click on a cell to select and edit the data in that cell.
    Changes will be updated on the chart as they are made.
    Regards,
    Barry

  • How to make a all new gui in java

    I am fed up of using metal motif and windows look and feel gui in java...........how can i make a more fancy gui.......
    the one like ym or gtalk.......

    See The Java&#8482; tutorials: [The Synth Look and Feel|http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/synth.html]
    db

  • My Adobe Acrobat 10 Pro creates PDFs with a graph background.  How do I make the background white?

    My Adobe Acrobat 10 Pro creates PDFs with a GRAPH background.  How do I make the scanned documents have a normal white background?

    This particular forum (sharing and storage) was created to help those transitioning from Photoshop.com to Adobe Revel. I will move your post to the correct forum so that it can get proper attention.
    We also have many other forums relating to other Adobe products at: http://forums.adobe.com.
    Out of curiosity, can you tell me how you found our forum page?

  • How can i make a plot in a 3d graph invisible

    hello all,
    attached is a half-way completed vi which shows how i would make the plot/plots in the 3d graph invisible. unfortunatly i do not know how "item" can refer to the plot i want to make invisible.
    any ideas?
    Solved!
    Go to Solution.
    Attachments:
    remove plot in 3d graph.vi ‏27 KB

    You are almost correct.
    The Item input is a string whose value is the name of the target plot. You can view all the plots names from shortcut menu->"CWGraph3D" group->"Properties" item->"Plots" tab ->"Plots" list.
    Attachments:
    remove plot in 3d graph.vi ‏20 KB

  • HT202060 How can I make Activity Monitor show one graph instead of four for MacBook Air?

    How can I make Activity Monitor show one graph instead of four for MacBook Air?

    Learn about OS X: Activity Monitor shows one CPU Usage graph on systems with more than four cores
    Copied and pasted from top of the page.

  • How can i make a graph y is unmber pasing from UDP port,x is the time stamp.and in the same time this graph can display several numbers to compare.

    how can i make a graph
    y is number(the blue wire)pasing from UDP port,
    x is the time stamp.
    plus in the same time this graph can display several differenr numbers to compare.

  • How do I make a continuous X-Y graph with an array as input?

    I want to create an X-Y graph with a reference time (double) as one variable and the other is a double data type. How can I create a continuous graph on an X-Y graph with these variables? I have only been using Labview for 2 months so if you have any suggestions please go easy on the technical terms.
    TIA,
    Kevin

    LabVIEW what several options for displaying data. A waveform chart is great if you receive one point at a time and want to plot the data in series. A waveform graph is good for plotting arrays in a time series fashion. An xy plot is good for connecting points that do not occur in a series. This plot offers the most flexibility in graphing points with different x values.
    It is often hard to keep what structure goes two what display option. As a cheat, I right click on the chart in the block diagram and slide the mouse to create >> (either a constant or control). This way you can get a model for the data you want to input.
    You may also want to look at the shipping examples that come with LabVIEW. In LabVIEW 6.1, goto help >> find examples >> fundamen
    tals >> graphs and charts.
    Jeremy Braden
    National Instruments

  • How can I make a FlashAlbumExporter background transparent?

    I really like the very cool FAE (as suggested on this most excellent forum) but the gui offers no choice as for background opacity. A little search on the net reveals a few ideas but none of them seem to work. I am using the following iframe code in iWeb:
    <iframe src=
    "http://www.bostruyephotos.com/Paso_Robles/index.html"
    style="width:1000px; height:900px;
    border-width:0px;
    border-color:#990033;
    border-style:solid;"
    scrolling="auto" >
    </iframe>
    I don't know if the bg transparency is controlled in this iframe code, in the index.html file created by FAE or in the xml file created by FAE. So far I have tried:
    Remove the background-color: #181818; from the index.html didn't make any difference.
    Adding <bgcolor transparency="0"> in the xml made simpleviewer not display at all.
    Another web site was discussing using html in the HTML snippet widget instead of iframe and it seems to address the transparency issue. But it seems rather old and is setup to use a movie instead of a photo album so I'm not sure how to convert it. Here is that code:
    <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#v ersion=6,0,40,0"
    WIDTH="700" HEIGHT="700" id="MyMovieName">
    <PARAM NAME=movie VALUE="MyFlashMovie.swf">
    <param name="wmode" value="transparent">
    <PARAM NAME=quality VALUE=high>
    <PARAM NAME=base VALUE=".">
    <EMBED src="MyFlashMovie.swf" quality=high WIDTH="700" HEIGHT="700"
    NAME="MyMovieName" ALIGN="" TYPE="application/x-shockwave-flash" wmode="transparent" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" base=".">
    </EMBED>
    </OBJECT>
    Any idea how I can make this bg transparent so my bg will show behind the photos instead of the default dark grey?
    The current version is here in case that helps:
    http://www.bostruyephotos.com/Gallery/Cruising.html
    Thanks for any help.
    Bo

    If that's what you're doing, then just turn off the visibility of the layer that you made the selection on - most likely the BG layer by clicking on the eye icon in the layer's pallet.  You change the bg layer, as I mentioned above, and after you make your selection, click on the add layer mask icon in the layer's pallet,  This will add a layer mask with your selection.  If you hold alt/opt while doing this, it will create a inverse layer mask.

  • How do you make an array of image icons and then call them?

    How do you make an array of image icons and then call them, i have searched all over the internet for making an array of icons, but i have
    found nothing. Below is my attempt at making an array of icons, but i cant seem to make it work. Basically, i want the image to match the value of the roll of the dice (rollVal)
    Any help would be greatly appreciated, some code or link to tuturial, ect.
    /** DiceRoller.java
    * Roll, print, Gui
    import javax.swing.*;
    public class DiceRoller extends JFrame
         private ImageIcon[] image  ;
         public String[] images = { "empty", "dice1.jpg",
                   "dice2.jpg", "dice3.jpg", "dice4.jpg",
                   "dice5.jpg", "dice6.jpg" };
         public Dice die;
         private int rollVal;
         public int rollNum;
         private JLabel j1;
         public DiceRoller(){
              j1= new JLabel("");
           die =new Dice();
           int rollVal;
           rollVal = die.roll();     
           image = new  ImageIcon[images.length];
         for(int i = 0; i < images.length; i++){
          image[i] = new ImageIcon(images);
         if (image!=null){
              j1.setIcon(image[rollVal]);
         System.out.println("Roll = "+die.roll());

    Demo:
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class IconExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch();
        static void launch() {
            try {
                Icon[] icons = new Icon[6];
                for(int i=0; i<icons.length; ++i) {
                    String url = "http://www.eureka-puzzle.be/cast/images/dice" + (i + 1) + ".jpg";
                    icons[i] = new ImageIcon(new URL(url));
                display(icons);
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
        static void display(Icon[] icons) {
            JPanel cp = new JPanel();
            for(Icon icon : icons) {
                cp.add(new JLabel(icon));
            JFrame f = new JFrame();
            f.setContentPane(cp);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

Maybe you are looking for

  • Maximum Size of Hard Drive in Mac Pro (Early 2008)

    What is the Maximum size of Hard Drive that I can install in drive bay 3 or 4? Computer info below: Model Name: Mac Pro (Early 2008) Model Identifier: MacPro3,1 Processor Name: Quad-Core Intel Xeon Processor Speed: 2.8 GHz Number Of Processors: 2 Tot

  • How to change data usage for email?

    Is there a way to change the email settings from Push to Pull, and also email advance settings as far as deleting emails from the servers? In the current email settings the data is set to Automatic (push) without being able to change it. Any suggesti

  • How to get the date format yyyy-mm-dd?

    Hi, I have an iphone (3.1.2) and would like to use the date format yyyy-mm-dd (international date format). Is the possible? If yes, how? Cheers

  • EM & Owner User ID?? Why?

    Guys, Im struggling with Owner User ID and Extension mobility. It seems to me that unless we set Owner user ID on every single hardware phone, it uses an extra license.  Why would you set owner user ID when you are using extension mobility? The whole

  • Error in scheduler agent

    Hi Folks, I'm getting below error whenever I lunched the scheduleragent.Please give me the valuable inputs on same Error com.sunopsis.tools.core.exception.SnpsRuntimeException: java.sql.SQLException: socket creation error at com.sunopsis.dwg.cmd.n.a(