package com.chart;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import twaver.Element;
import twaver.Node;
import twaver.TDataBox;
import twaver.chart.BarChart;
import twaver.chart.PieChart;
/**
* @author 徐彬
*
*/
public class DNSChart extends JFrame{
//利用网格布局管理器GridLayout
GridLayout layout = new GridLayout(2, 2);
//创建一个Twaver 工具箱
private TDataBox box = new TDataBox();
private BarChart barChart = new BarChart(box);//创建一个柱状图
private PieChart pieChart = new PieChart(box);//创建一个饼状图
//设置几个比例块 红绿蓝黑 等等
Element red = new Node();
Element green = new Node();
Element blue = new Node();
Element black = new Node();
public DNSChart(){
//设置全屏显示 Toolkit.getDefaultToolkit().getScreenSize()
this.setSize(700,700);
this.setTitle("Chart");
red.setName("Red");
green.setName("Green");
blue.setName("Blue");
//设置背景色加深
barChart.setBackgroundVisible(true);
pieChart.setBackgroundVisible(true);
//图示付色
red.putChartColor(Color.RED);
green.putChartColor(Color.GREEN);
blue.putChartColor(Color.BLUE);
black.putChartColor(Color.BLACK);
//图示的比例值
red.putChartValue(191);
green.putChartValue(73);
blue.putChartValue(192);
black.putChartValue(292);
box.addElement(red);
box.addElement(green);
box.addElement(blue);
box.addElement(black);
//布局管理
JPanel chartPane = new JPanel(layout);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, pieChart, new JScrollPane());
splitPane.setDividerLocation(700);
chartPane.add(splitPane);
JSplitPane splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, barChart, new JScrollPane());
splitPane1.setDividerLocation(700);
chartPane.add(splitPane1);
this.getContentPane().add(chartPane,BorderLayout.CENTER);
this.setVisible(true);
}
public static void main(String[] args) {
DNSChart dc=new DNSChart();
}
}