home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / Applications / Layouts / JDPLayout15.java < prev    next >
Encoding:
Text File  |  1999-04-09  |  6.3 KB  |  219 lines

  1. \*    //
  2.     //  Main initialization method
  3.     //
  4.     public void <compName>Main() {
  5.  
  6.         <compName>SetChartParms();
  7.         <compName>LoadData(null);
  8.  
  9.     }
  10.  
  11. \*    //
  12.     //  Load the chart with the specified parameters and selected data
  13.     //
  14.     public void <compName>LoadDataFromWhereClause(String whereClause) {
  15.  
  16.         int fPos = whereClause.indexOf("WHERE ");
  17.         whereClause = " AND" + whereClause.substring(fPos+5);
  18.         String[] keys = new String[0];
  19.  
  20.         <compName>LoadDataMain(keys, whereClause);
  21.     }
  22.  
  23. \*    //
  24.     //  Load the chart with the specified parameters and selected data
  25.     //
  26.     public void <compName>LoadData(String[] keys) {
  27.  
  28.         <compName>LoadDataMain(keys, null);
  29.     }
  30.  
  31. \*R    //
  32.     //  Load the chart with the specified parameters and selected data
  33.     //
  34.     void <compName>LoadDataMain(String[] keys, String whereClauseParm) {
  35.  
  36.         JDPChartParms p = <compName>.p;
  37.  
  38.         StringTokenizer stok;
  39.         int recCount = 0;
  40.         Vector results = new Vector();
  41.         String sep = jaggSQL.getSEP();
  42.         int actualRows = 0;
  43.         String row;
  44. >161        String whereClause = "<(1=1)>";
  45.  
  46. >130        int groupCount = <>;
  47. >131        int seriesCount = <>;
  48.  
  49. >133        <whereClause>;
  50.         if (whereClauseParm != null) {
  51.             whereClause += whereClauseParm;
  52.         }
  53. >132        String SQL = <SELECT >;
  54.  
  55.  
  56.         user.mainmsg.setStatusMsg(JDPLang.get("Message0"), 0);
  57.  
  58. <jaggPrefs>
  59.         recCount = jaggSQL.execSQL(SQL, results);
  60.  
  61.         if(recCount == -1) {
  62.             user.u.setSqlMessage(jaggSQL,SQL);
  63.             return;
  64.         }
  65.         if(recCount == 0) {
  66.             user.mainmsg.setStatusMsg(JDPLang.get("Message10"),10);
  67.             <compName>.hide();
  68.             return;
  69.         }
  70.         <compName>.show();
  71.  
  72.         //
  73.         //  Initialise result arrays
  74.         //
  75.         int columnCount = jaggSQL.getColumnCount();
  76.         actualRows = jaggSQL.getRowCount();
  77.  
  78.         if (seriesCount <= 0) {
  79.             p.chartData = new float[columnCount-groupCount][actualRows];
  80.             p.xaxisLabel = new String[actualRows];
  81.             p.piechartData = new float[actualRows];
  82.             p.pieSplitSegment = new boolean[actualRows];
  83.             p.pieLabel = new String[actualRows];
  84.             if (p.chartType == JDPChart.PIE ||
  85.                 p.chartType == JDPChart.GANTT) {
  86.                 p.elementColor = new Color[actualRows];
  87.                 p.elementBorderColor = new Color[actualRows];
  88.                  p.elementLegend = new String[actualRows];
  89.             }
  90.             for (int ix=0; ix<actualRows; ix++) {
  91.                 row = (String)results.elementAt(ix);
  92.                 stok = new StringTokenizer(row,sep);
  93.                 p.xaxisLabel[ix] = "";
  94.                 if (groupCount > 0) p.xaxisLabel[ix] = stok.nextToken().trim();
  95.                 for (int iz=0; iz<columnCount-groupCount; iz++) {
  96.                     if (p.chartType == JDPChart.GANTT) {
  97.                         long val = (Long.valueOf(stok.nextToken()).longValue())/(86400000);
  98.                         p.chartData[iz][ix] = (float)val;
  99.                     } else {
  100.                         p.chartData[iz][ix] = Float.valueOf(stok.nextToken().trim()).floatValue();
  101.                     }
  102.                 }
  103.                 p.pieLabel[ix] = p.xaxisLabel[ix];
  104.                 p.piechartData[ix] = p.chartData[0][ix];
  105.                 if (p.chartType == JDPChart.PIE ||
  106.                     p.chartType == JDPChart.GANTT) {
  107.                     p.elementColor[ix] = JDPUtils.colorList[ix%12];
  108.                     p.elementBorderColor[ix] = Color.black;
  109.                      p.elementLegend[ix] = p.pieLabel[ix];
  110.                 }
  111.             }
  112.         } else {
  113.             float[][] tempchartData = new float[1000][actualRows];
  114.             p.xaxisLabel = new String[actualRows];
  115.             Vector group = new Vector();
  116.             if (groupCount == 0) group.addElement("");
  117.             Vector series = new Vector();
  118.             for (int ix=0; ix<actualRows; ix++) {
  119.                 row = (String)results.elementAt(ix);
  120.                 stok = new StringTokenizer(row,sep);
  121.                 p.xaxisLabel[ix] = "";
  122.                 int groupIndex = 0;
  123.                 if (groupCount > 0) {
  124.                     String groupValue = stok.nextToken().trim();
  125.                     groupIndex = group.indexOf(groupValue);
  126.                     if (groupIndex < 0) {
  127.                         group.addElement(groupValue);
  128.                         groupIndex = group.indexOf(groupValue);
  129.                         p.xaxisLabel[groupIndex] = groupValue;
  130.                     }
  131.                 }
  132.                 String seriesValue = stok.nextToken().trim();
  133.                 int seriesIndex = series.indexOf(seriesValue);
  134.                 if (seriesIndex < 0) {
  135.                     series.addElement(seriesValue);
  136.                     seriesIndex = series.indexOf(seriesValue);
  137.                 }
  138.                 tempchartData[seriesIndex][groupIndex] = Float.valueOf(stok.nextToken().trim()).floatValue();
  139.             }
  140.  
  141.             int numbars = series.size();
  142.             p.chartData = new float[numbars][group.size()];
  143.             for (int ix=0; ix<numbars; ix++) {
  144.                 for (int iy=0; iy<group.size(); iy++) {
  145.                     p.chartData[ix][iy] = tempchartData[ix][iy];
  146.                 }
  147.             }
  148.             p.elementColor = new Color[numbars];
  149.             p.elementBorderColor = new Color[numbars];
  150.              p.elementLegend = new String[numbars];
  151.             for (int ix=0; ix<numbars; ix++) {
  152.                 p.elementColor[ix] = JDPUtils.colorList[ix%12];
  153.                 p.elementBorderColor[ix] = Color.black;
  154.                  p.elementLegend[ix] = (String)series.elementAt(ix);
  155.             }
  156.         }
  157.         <compName>.calculateScaling();
  158.         <compName>.repaint();
  159.  
  160.         user.mainmsg.clearStatusMsg();
  161.     }
  162.  
  163. \*R    //
  164.     //  Load the parameters for the selected chart
  165.     //
  166.     public void <compName>SetChartParms() {
  167.  
  168.         JDPChartParms p;
  169.         if (<compName> == null) {
  170.             p = new JDPChartParms();
  171.             <compName> = new JDPChart(user, p);
  172.         } else {
  173.             p = <compName>.p;
  174.         }
  175.  
  176. >158        p.chartType = <>;
  177. >159        p.autoscale = <>;
  178. >160        p.autozoom = <>;
  179.  
  180. >141        p.chartTitle = "<>";
  181.         p.chartTitleFont = user.boldFont.getName();
  182. >142        p.chartTitleColor = user.u._cvtcolor("<>");
  183.  
  184. >143        p.xaxisTitle = "<>";
  185.         p.xaxisTitleFont = user.boldFont.getName();
  186. >144        p.xaxisTitleColor = user.u._cvtcolor("<>");
  187.  
  188.         p.yaxisLabel = new String[10];
  189.  
  190.         p.elementLegendFont = user.boldFont.getName();
  191.  
  192. >145        p.xaxisLabelColor = user.u._cvtcolor("<>");
  193. >146        p.yaxisLabelColor = user.u._cvtcolor("<>");
  194. >147        p.chartFrameColor = user.u._cvtcolor("<>");
  195.  
  196. >148        p.elementLegend = new String[<>];
  197. >148        p.elementColor = new Color[<>];
  198. >148        p.elementBorderColor = new Color[<>];
  199. >149        p.elementLegend[<iy>] = "<selectChartDef.elementLegend[ix]>";
  200. >150        p.elementColor[<iy>] = user.u._cvtcolor("<>");
  201. >151        p.elementBorderColor[<iy>] = user.u._cvtcolor("<selectChartDef.elementBorderColor[ix]>");
  202.  
  203. >152        p.gridLineSetting = <JDPChart.HORIZONTAL + JDPChart.VERTICAL + JDPChart.FOREGROUND + JDPChart.BACKGROUND>;
  204. >153        p.gridColor = user.u._cvtcolor("<>");
  205.  
  206. >156        p.maxPlotValue = <>;
  207. >157        p.minPlotValue = <>;
  208.  
  209.         if ((p.chartType == JDPChart.COLUMN) || (p.chartType == JDPChart.BAR) ||
  210.             (p.chartType == JDPChart.AREA)) {
  211.             p.autozoom = false;
  212.         }
  213.  
  214.         p.pieLabel = p.elementLegend;
  215.         p.pieLabelColor = p.xaxisTitleColor;
  216.  
  217.     }
  218.  
  219.