LineChart.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package psoAlgoCode;
  2. import java.awt.BorderLayout;
  3. import java.awt.FlowLayout;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import java.util.Vector;
  7. import javax.swing.JButton;
  8. import javax.swing.JDialog;
  9. import javax.swing.JPanel;
  10. /**
  11. * COmpletely unnecessary if not used anymore in the new Version
  12. * @author egert.rolf
  13. *
  14. */
  15. public class LineChart extends JDialog {
  16. private static final long serialVersionUID = 1L;
  17. // XYSeriesCollection collections = new XYSeriesCollection();
  18. /*public LineChart(String applicationTitle, String chartTitle) {
  19. JPanel chartPanel = plotStuff(chartTitle);
  20. JPanel bottomPanel = new JPanel();
  21. setTitle(applicationTitle);
  22. setBounds(400, 100, 800, 800);
  23. setModal(true);
  24. getContentPane().setLayout(new BorderLayout());
  25. getContentPane().add(chartPanel, BorderLayout.CENTER);
  26. chartPanel.setLayout(null);
  27. bottomPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
  28. getContentPane().add(bottomPanel, BorderLayout.SOUTH);
  29. JButton close = new JButton("Close");
  30. close.addActionListener(new ActionListener() {
  31. @Override
  32. public void actionPerformed(ActionEvent e) {
  33. dispose();
  34. }
  35. });
  36. bottomPanel.add(close);
  37. }
  38. */
  39. /* public JPanel plotStuff(String chartTitle) {
  40. XYDataset dataset = collections;
  41. JFreeChart lineChart = ChartFactory.createXYLineChart(chartTitle, "Iterations", "Global Best", dataset,
  42. PlotOrientation.VERTICAL, false, true, false);
  43. return new ChartPanel(lineChart);
  44. }
  45. public void createDataSet(Vector<Double> data, int round) {
  46. final XYSeries series = new XYSeries("Round " + (round), false);
  47. int steps = Constants.MAX_ITERATION;
  48. for (int i = 0; i < steps; i++) {
  49. double temp = data.get(i);
  50. series.add(i + 1, temp);
  51. }
  52. collections.addSeries(series);
  53. }
  54. */
  55. }