Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package LisajousApp; import java.awt.Color; import java.awt.Shape; import java.awt.geom.Ellipse2D; import javax.swing.JPanel; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.ui.RectangleInsets; /** * * @author Hubert */ public class Draw { private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createScatterPlot("Lissajous", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.lightGray); XYPlot plot = (XYPlot) chart.getPlot(); plot.getRenderer().setSeriesPaint(0, Color.blue); // ta linia niej odpowiada za grubo punktw Shape shape = new Ellipse2D.Double(0, 0, 0.5, 0.5); plot.getRenderer().setSeriesShape(0, shape); return chart; } private static XYDataset createDataset() { XYSeries s1 = new XYSeries(""); for (double t = 0; t <= 2 * Math.PI; t = t + 0.0005) { double x = Main.a * Math.sin(Main.n * t + Main.c); double y = Main.b * Math.sin(t); s1.add(x, y); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); return dataset; } public static JPanel createWoPanel() { JFreeChart chart = createChart(createDataset()); return new ChartPanel(chart); } }