PieChartApplet.java
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:11k
源码类别:

OA系统

开发平台:

Java

  1. // Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov  Date: 2002-12-03 18:44:16
  2. // Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
  3. // Decompiler options: packimports(3) 
  4. // Source File Name:   PieChartApplet.java
  5. package cn.com.fcsoft.chart;
  6. import java.awt.Component;
  7. import java.io.PrintStream;
  8. // Referenced classes of package com.objectplanet.chart:
  9. //            ChartApplet, PieChart, Chart
  10. public class PieChartApplet extends ChartApplet
  11. {
  12.     public PieChartApplet()
  13.     {
  14.     }
  15.     protected Chart createChart(String s)
  16.     {
  17.         if(s == null || s.equals(""))
  18.             s = "cn.com.fcsoft.chart.PieChart";
  19.         try
  20.         {
  21.             Class class1 = Class.forName(s);
  22.             PieChart piechart = (PieChart)class1.newInstance();
  23.             return piechart;
  24.         }
  25.         catch(ClassNotFoundException _ex)
  26.         {
  27.             System.out.println("Class not found: " + s);
  28.         }
  29.         catch(InstantiationException _ex)
  30.         {
  31.             System.out.println("Could not create an instance of teh class: " + s);
  32.         }
  33.         catch(IllegalAccessException _ex)
  34.         {
  35.             System.out.println("Illegal access, could not create an instance of class: " + s);
  36.         }
  37.         catch(ClassCastException _ex)
  38.         {
  39.             System.out.println("The class " + s + ", does not extend from com.objectplanet.chart.PieChart");
  40.         }
  41.         return new PieChart();
  42.     }
  43.     private void initParameter(String s, String s1)
  44.     {
  45.         if(s1 != null)
  46.             setParameter(s, s1);
  47.     }
  48.     public void setParameter(String s, String s1)
  49.     {
  50.         if(s == null)
  51.             return;
  52.         s = s.toLowerCase();
  53.         if(s.equals("angle"))
  54.         {
  55.             if(s1 != null && s1.trim().length() > 0)
  56.                 try
  57.                 {
  58.                     int i = Integer.parseInt(s1);
  59.                     i = Math.max(10, i);
  60.                     i = Math.min(80, i);
  61.                     chart.setAngle(i);
  62.                 }
  63.                 catch(NumberFormatException _ex)
  64.                 {
  65.                     System.out.println("Invalid angle: " + s1);
  66.                     chart.setAngle(20);
  67.                 }
  68.             else
  69.                 chart.setAngle(20);
  70.         } else
  71.         if(s.equals("depth"))
  72.         {
  73.             if(s1 != null && s1.trim().length() > 0)
  74.                 try
  75.                 {
  76.                     double d = (new Float(s1)).floatValue();
  77.                     d = Math.max(0.0D, d);
  78.                     d = Math.min(1.0D, d);
  79.                     chart.setDepth((float)d);
  80.                 }
  81.                 catch(NumberFormatException _ex)
  82.                 {
  83.                     System.out.println("Invalid depth: " + s1);
  84.                     chart.setDepth(0.40000000596046448D);
  85.                 }
  86.             else
  87.                 chart.setDepth(0.40000000596046448D);
  88.         } else
  89.         if(s.equals("serieslabelson"))
  90.             chart.setSeriesLabelsOn(s1 != null && s1.toLowerCase().equals("true"));
  91.         else
  92.         if(s.equals("serieslabelstyle"))
  93.         {
  94.             chart.setSeriesLabelStyle(0);
  95.             if(s1 != null && s1.trim().length() > 0)
  96.                 if(s1.trim().toLowerCase().equals("inside"))
  97.                     chart.setSeriesLabelStyle(1);
  98.                 else
  99.                 if(s1.trim().toLowerCase().equals("outside"))
  100.                     chart.setSeriesLabelStyle(2);
  101.         } else
  102.         if(s.equals("samplelabelson"))
  103.             chart.setSampleLabelsOn(s1 != null && s1.toLowerCase().equals("true"));
  104.         else
  105.         if(s.equals("samplelabelstyle"))
  106.         {
  107.             chart.setSampleLabelStyle(0);
  108.             if(s1 != null && s1.trim().length() > 0)
  109.                 if(s1.trim().toLowerCase().equals("inside"))
  110.                     chart.setSampleLabelStyle(1);
  111.                 else
  112.                 if(s1.trim().toLowerCase().equals("outside"))
  113.                     chart.setSampleLabelStyle(2);
  114.         } else
  115.         if(s.equals("valuelabelson"))
  116.             chart.setValueLabelsOn(s1 != null && s1.toLowerCase().equals("true"));
  117.         else
  118.         if(s.equals("valuelabelstyle"))
  119.         {
  120.             chart.setValueLabelStyle(0);
  121.             if(s1 != null && s1.trim().length() > 0)
  122.                 if(s1.trim().toLowerCase().equals("inside"))
  123.                     chart.setValueLabelStyle(1);
  124.                 else
  125.                 if(s1.trim().toLowerCase().equals("outside"))
  126.                     chart.setValueLabelStyle(2);
  127.         } else
  128.         if(s.equals("percentlabelson"))
  129.             chart.setPercentLabelsOn(s1 != null && s1.toLowerCase().equals("true"));
  130.         else
  131.         if(s.equals("percentlabelstyle"))
  132.         {
  133.             chart.setPercentLabelStyle(0);
  134.             if(s1 != null && s1.trim().length() > 0)
  135.                 if(s1.trim().toLowerCase().equals("inside"))
  136.                     chart.setPercentLabelStyle(1);
  137.                 else
  138.                 if(s1.trim().toLowerCase().equals("outside"))
  139.                     chart.setPercentLabelStyle(2);
  140.         } else
  141.         if(s.equals("pielabelson"))
  142.             chart.setPieLabelsOn(s1 != null && s1.toLowerCase().equals("true"));
  143.         else
  144.         if(s.equals("percentdecimalcount"))
  145.         {
  146.             if(s1 != null && s1.trim().length() > 0)
  147.                 try
  148.                 {
  149.                     chart.setPercentDecimalCount(Integer.parseInt(s1));
  150.                 }
  151.                 catch(NumberFormatException _ex)
  152.                 {
  153.                     System.out.println("Invalid percentDecimalCount: " + s1);
  154.                     chart.setPercentDecimalCount(0);
  155.                 }
  156.             else
  157.                 chart.setPercentDecimalCount(0);
  158.         } else
  159.         if(s.equals("sliceseperatoron"))
  160.             chart.setSliceSeperatorOn(s1 != null && s1.toLowerCase().equals("true"));
  161.         else
  162.         if(s.equals("sliceseperatorcolor"))
  163.         {
  164.             if(s1 != null && s1.length() > 0)
  165.                 chart.setSliceSeperatorColor(ChartApplet.createColor(s1));
  166.             else
  167.                 chart.setSliceSeperatorColor(null);
  168.         } else
  169.         if(s.equals("selectionstyle"))
  170.         {
  171.             byte byte0 = 0;
  172.             if(s1 != null)
  173.                 if(s1.equals("circle"))
  174.                     byte0 = 1;
  175.                 else
  176.                 if(s1.equals("detached"))
  177.                     byte0 = 2;
  178.             chart.setSelectionStyle(byte0);
  179.         } else
  180.         if(s.equals("detacheddistance"))
  181.         {
  182.             chart.setDetachedDistance(0.10000000000000001D);
  183.             if(s1 != null && s1.length() > 0)
  184.                 try
  185.                 {
  186.                     double d1 = (new Double(s1)).doubleValue();
  187.                     chart.setDetachedDistance(Math.max(0.0D, d1));
  188.                 }
  189.                 catch(NumberFormatException _ex)
  190.                 {
  191.                     System.out.println("Invalid detachDistance: " + s1);
  192.                 }
  193.         } else
  194.         if(s.startsWith("detachedslices"))
  195.         {
  196.             int j = s.equals("detachedslices") ? 0 : -1;
  197.             try
  198.             {
  199.                 if(s.length() > 15)
  200.                     j = Integer.parseInt(s.substring(15));
  201.             }
  202.             catch(NumberFormatException _ex)
  203.             {
  204.                 System.out.println("Invalid index in detachedSlices_N parameter: " + s);
  205.             }
  206.             Double adouble[] = ChartApplet.getDoubleValues(s1);
  207.             int k = chart.getSeriesCount();
  208.             int l = chart.getSampleCount();
  209.             if(k == 1)
  210.             {
  211.                 for(int i1 = 0; i1 < l; i1++)
  212.                     chart.setDetachedSlice(0, i1, 0.0D);
  213.                 if(adouble != null)
  214.                 {
  215.                     double d2 = chart.getDetachedDistance();
  216.                     for(int k1 = 0; k1 < adouble.length; k1++)
  217.                     {
  218.                         int i2 = adouble[k1].intValue();
  219.                         if(i2 < l)
  220.                             chart.setDetachedSlice(0, i2, d2);
  221.                     }
  222.                 }
  223.             } else
  224.             if(j < l)
  225.             {
  226.                 for(int j1 = 0; j1 < k; j1++)
  227.                     chart.setDetachedSlice(j1, j, 0.0D);
  228.                 if(adouble != null)
  229.                 {
  230.                     double d3 = chart.getDetachedDistance();
  231.                     for(int l1 = 0; l1 < adouble.length; l1++)
  232.                     {
  233.                         int j2 = adouble[l1].intValue();
  234.                         if(j2 < k)
  235.                             chart.setDetachedSlice(j2, j, d3);
  236.                     }
  237.                 }
  238.             }
  239.         } else
  240.         {
  241.             super.setParameter(s, s1);
  242.         }
  243.     }
  244.     protected void refresh()
  245.     {
  246.         chart.repaint();
  247.     }
  248.     public void init()
  249.     {
  250.         chart = (PieChart)super.theChart;
  251.         super.init();
  252.         String s = getParameterPrefix();
  253.         initParameter("angle", getParameter(s + "angle"));
  254.         initParameter("depth", getParameter(s + "depth"));
  255.         initParameter("seriesLabelsOn", getParameter(s + "seriesLabelsOn"));
  256.         initParameter("seriesLabelStyle", getParameter(s + "seriesLabelStyle"));
  257.         initParameter("sampleLabelsOn", getParameter(s + "sampleLabelsOn"));
  258.         initParameter("sampleLabelStyle", getParameter(s + "sampleLabelStyle"));
  259.         initParameter("valueLabelsOn", getParameter(s + "valueLabelsOn"));
  260.         initParameter("valueLabelStyle", getParameter(s + "valueLabelStyle"));
  261.         initParameter("percentLabelsOn", getParameter(s + "percentLabelsOn"));
  262.         initParameter("percentLabelStyle", getParameter(s + "percentLabelStyle"));
  263.         initParameter("pieLabelsOn", getParameter(s + "pieLabelsOn"));
  264.         initParameter("percentDecimalCount", getParameter(s + "percentDecimalCount"));
  265.         initParameter("sliceSeperatorOn", getParameter(s + "sliceSeperatorOn"));
  266.         initParameter("sliceSeperatorColor", getParameter(s + "sliceSeperatorColor"));
  267.         initParameter("selectionStyle", getParameter(s + "selectionStyle"));
  268.         initParameter("pieLabelFont", getParameter(s + "pieLabelFont"));
  269.         initParameter("insideLabelFont", getParameter(s + "insideLabelFont"));
  270.         initParameter("detachedDistance", getParameter(s + "detachedDistance"));
  271.         initParameter("detachedSlices", getParameter(s + "detachedSlices"));
  272.         int i = chart.getSeriesCount() != 1 ? chart.getSampleCount() : 1;
  273.         for(int j = 0; j < i; j++)
  274.         {
  275.             String s3 = getParameter(s + "detachedSlices_" + j);
  276.             if(s3 != null)
  277.                 initParameter("detachedSlices_" + j, s3);
  278.         }
  279.         String s1 = getParameter(s + "overlay");
  280.         initParameter(s + "overlay", getParameter(s + "overlay"));
  281.         int k = s1 == null ? 0 : 1;
  282.         for(String s2 = getParameter(s + "overlay" + k); s2 != null; s2 = getParameter(s + "overlay" + k))
  283.         {
  284.             initParameter(s + "overlay" + k, getParameter(s + "overlay" + k));
  285.             k++;
  286.         }
  287.         chart.setAutomaticRepaintOn(true);
  288.     }
  289.     public PieChart chart;
  290. }