1 22 package info.monitorenter.gui.chart.layout.demos; 23 24 import info.monitorenter.gui.chart.Chart2D; 25 import info.monitorenter.gui.chart.ITrace2D; 26 import info.monitorenter.gui.chart.io.AStaticDataCollector; 27 import info.monitorenter.gui.chart.io.PropertyFileStaticDataCollector; 28 import info.monitorenter.gui.chart.layout.ChartPanel; 29 import info.monitorenter.gui.chart.layout.LayoutFactory; 30 import info.monitorenter.gui.chart.layout.views.ChartCoordinateView; 31 import info.monitorenter.gui.chart.traces.Trace2DLtd; 32 33 import java.awt.Container ; 34 import java.awt.Dimension ; 35 import java.awt.GridBagConstraints ; 36 import java.awt.GridBagLayout ; 37 import java.awt.event.WindowAdapter ; 38 import java.awt.event.WindowEvent ; 39 import java.io.IOException ; 40 41 import javax.swing.JFrame ; 42 43 44 52 public class CoordinateViewChart extends JFrame { 53 54 55 private Chart2D m_chart; 56 57 67 public CoordinateViewChart(final Chart2D chart) { 68 super("View coordinates"); 69 this.m_chart = chart; 70 71 ChartCoordinateView viewChartValue = new ChartCoordinateView(this.m_chart); 72 new LayoutFactory.BasicPropertyAdaptSupport(viewChartValue, this.m_chart); 74 75 Container contentPane = this.getContentPane(); 76 contentPane.setLayout(new GridBagLayout ()); 77 new LayoutFactory.BasicPropertyAdaptSupport(contentPane, this.m_chart); 78 79 GridBagConstraints gbc = new GridBagConstraints (); 81 gbc.gridx = 0; 82 gbc.gridy = 0; 83 gbc.gridheight = 1; 84 gbc.gridwidth = 1; 85 gbc.weightx = 1; 86 gbc.weighty = 1.0; 87 gbc.insets.bottom = 8; 88 gbc.anchor = GridBagConstraints.NORTH; 89 gbc.fill = GridBagConstraints.BOTH; 90 contentPane.add(new ChartPanel(this.m_chart), gbc); 91 92 gbc.gridy = 1; 94 gbc.weighty = 0.0; 95 gbc.insets.bottom = 0; 96 gbc.anchor = GridBagConstraints.NORTH; 97 gbc.fill = GridBagConstraints.NONE; 98 contentPane.add(viewChartValue, gbc); 99 100 this.addWindowListener(new WindowAdapter () { 101 public void windowClosing(final WindowEvent e) { 102 System.exit(0); 103 } 104 }); 105 106 this.setSize(new Dimension (400, 300)); 107 this.setVisible(true); 108 109 } 110 111 120 public static void main(final String [] args) throws IOException { 121 Chart2D chart = new Chart2D(); 122 123 ITrace2D trace = new Trace2DLtd(400); 124 AStaticDataCollector collector = new PropertyFileStaticDataCollector(trace, 125 CoordinateViewChart.class.getResourceAsStream("data.properties")); 126 collector.collectData(); 127 chart.addTrace(trace); 128 new CoordinateViewChart(chart); 129 130 } 131 132 } 133 | Popular Tags |