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 / JDPLayout25.java < prev    next >
Encoding:
Text File  |  1999-04-09  |  6.4 KB  |  221 lines

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