Search in sources :

Example 1 with PieChart

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

the class PMAPView method createChartPanel.

/**
	 * 生成饼图
	 * @param parent
	 * @param data
	 */
private void createChartPanel(Composite parent, Map<String, Integer> data) {
    Composite composite = new Composite(parent, SWT.NO_BACKGROUND | SWT.EMBEDDED);
    Frame frame = SWT_AWT.new_Frame(composite);
    // 据说加入这个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();
    PieChart chart = new PieChart();
    int showItemNum = 0;
    try {
        showItemNum = Integer.parseInt(showDataItemCountText.getText());
    } catch (NumberFormatException e) {
        e.printStackTrace();
        showItemNum = 10;
    }
    chart.setDataset(getPieChartDataFromMap(data, showItemNum));
    contentPane.add(chart);
}
Also used : Panel(java.awt.Panel) Frame(java.awt.Frame) Composite(org.eclipse.swt.widgets.Composite) BorderLayout(java.awt.BorderLayout) PieChart(com.tencent.wstt.apt.chart.PieChart) JRootPane(javax.swing.JRootPane)

Aggregations

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