程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> - Draw a pie chart

- Draw a pie chart

編輯:關於JSP

 import java.util.*;
import java.awt.*;
import java.applet.Applet;
public class Graph extends Applet {
  int    depth, radius;
public void init() {
   float value;
   String at = getParameter("width");
   radius = (at != null) ?  Integer.valueOf(at).intValue() : 100;
   at = getParameter("depth");
   depth = (at != null) ? Integer.valueOf(at).intValue() : 20;
   at = getParameter("values");
   PieChartCanvas c = new PieChartCanvas(radius, depth);
   setLayout(new BorderLayout());
   // Create Hashtable to map color name (String) to Color type
   Hashtable colors = new Hashtable();
   colors.put("green", Color.green);
   colors.put("red", Color.red);
   colors.put("blue", Color.blue);
   colors.put("yellow", Color.yellow);
   colors.put("magenta", Color.magenta);
   colors.put("cyan", Color.cyan);
   colors.put("orange", Color.orange);
   colors.put("pink", Color.pink);
   colors.put("white", Color.white);
   colors.put("black", Color.black);
   // "value-color,value-color,..."
   StringTokenizer t = new StringTokenizer(at, ",");
   String s;
   int i;
   while (t.hasMoreTokens()) {
     s = t.nextToken();
     i = s.indexOf('-');
     value = Float.valueOf(s.substring(0, i)).floatValue();

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved