1 24 package info.monitorenter.gui.chart.demos; 25 26 import info.monitorenter.gui.chart.Chart2D; 27 import info.monitorenter.gui.chart.ITrace2D; 28 import info.monitorenter.gui.chart.layout.ChartPanel; 29 import info.monitorenter.gui.chart.traces.Trace2DSimple; 30 31 import java.awt.BorderLayout ; 32 import java.awt.Color ; 33 import java.awt.event.WindowAdapter ; 34 import java.awt.event.WindowEvent ; 35 36 import javax.swing.JFrame ; 37 import javax.swing.JPanel ; 38 39 60 public final class MinimalStaticChart extends JPanel { 61 64 private static final long serialVersionUID = 3257009847668192306L; 65 66 73 public static void main(final String [] args) { 74 for (int i = 0; i < 1; i++) { 75 JFrame frame = new JFrame ("SampleChart"); 76 frame.getContentPane().add(new MinimalStaticChart()); 77 frame.addWindowListener(new WindowAdapter () { 78 public void windowClosing(final WindowEvent e) { 79 System.exit(0); 80 } 81 }); 82 frame.setSize(600, 600); 83 frame.setLocation(i % 3 * 200, i / 3 * 100); 84 frame.setVisible(true); 85 } 86 } 87 88 91 private MinimalStaticChart() { 92 this.setLayout(new BorderLayout ()); 93 Chart2D chart = new Chart2D(); 94 95 ITrace2D trace = new Trace2DSimple(); 100 trace.setColor(Color.RED); 101 102 double time = System.currentTimeMillis(); 104 for (int i = 0; i < 100; i++) { 105 trace.addPoint(time + i, i * 1000); 106 } 107 chart.addTrace(trace); 109 110 this.add(new ChartPanel(chart), BorderLayout.CENTER); 112 113 } 114 115 } 116 | Popular Tags |