Search in sources :

Example 1 with CPURealTimeChart

use of com.tencent.wstt.apt.chart.CPURealTimeChart in project GT by Tencent.

the class CPUView method createChartPanel.

/**
	 * 初始化jfreechart
	 * @param rootFrame
	 */
private void createChartPanel(Composite parent) {
    // 放置图表的容器对象
    chartComposite = new Composite(parent, SWT.NO_BACKGROUND | SWT.EMBEDDED);
    FormData formData = new FormData();
    formData.left = new FormAttachment(0, Constant.VIEW_MARGIN_WIDTH);
    formData.right = new FormAttachment(cpuViewer.getTable(), -Constant.VIEW_MARGIN_WIDTH);
    formData.top = new FormAttachment(0, Constant.VIEW_MARGIN_WIDTH);
    formData.bottom = new FormAttachment(100, -Constant.VIEW_MARGIN_WIDTH);
    chartComposite.setLayoutData(formData);
    // AWT的根容器
    Frame frame = SWT_AWT.new_Frame(chartComposite);
    // 据说加入这个Panel可以无闪烁
    Panel panel = new Panel(new BorderLayout()) {

        private static final long serialVersionUID = 1L;

        public void update(java.awt.Graphics g) {
            /* Do not erase the background */
            paint(g);
        }
    };
    frame.add(panel);
    JRootPane root = new JRootPane();
    panel.add(root);
    java.awt.Container contentPane = root.getContentPane();
    cpuRealTimeChart = new CPURealTimeChart();
    contentPane.add(cpuRealTimeChart);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Panel(java.awt.Panel) Frame(java.awt.Frame) Composite(org.eclipse.swt.widgets.Composite) BorderLayout(java.awt.BorderLayout) JRootPane(javax.swing.JRootPane) FormAttachment(org.eclipse.swt.layout.FormAttachment) CPURealTimeChart(com.tencent.wstt.apt.chart.CPURealTimeChart)

Aggregations

CPURealTimeChart (com.tencent.wstt.apt.chart.CPURealTimeChart)1 BorderLayout (java.awt.BorderLayout)1 Frame (java.awt.Frame)1 Panel (java.awt.Panel)1 JRootPane (javax.swing.JRootPane)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 Composite (org.eclipse.swt.widgets.Composite)1