home *** CD-ROM | disk | FTP | other *** search
- \* //
- // Main initialization method
- //
- public void <compName>Main() {
-
- <compName>SetChartParms();
- <compName>LoadData(null);
- <compName>WhereClauseMain();
- <compName>SearchResultsMain();
-
- }
-
- \* //
- // Load the chart with the specified parameters and selected data
- //
- public void <compName>LoadDataFromWhereClause(String whereClause) {
-
- int fPos = whereClause.indexOf("WHERE ");
- whereClause = " AND" + whereClause.substring(fPos+5);
- String[] keys = new String[0];
-
- <compName>LoadDataMain(keys, whereClause);
- }
-
- \* //
- // Load the chart with the specified parameters and selected data
- //
- public void <compName>LoadData(String[] keys) {
-
- <compName>LoadDataMain(keys, null);
- }
-
- \*R //
- // Load the chart with the specified parameters and selected data
- //
- void <compName>LoadDataMain(String[] keys, String whereClauseParm) {
-
- JDPChartParms p = <compName>CL1.p;
-
- StringTokenizer stok;
- int recCount = 0;
- Vector results = new Vector();
- String sep = jaggSQL.getSEP();
- int actualRows = 0;
- String row;
- >161 String whereClause = "<(1=1)>";
-
- >130 int groupCount = <>;
- >131 int seriesCount = <>;
-
- >133 <whereClause>;
- if (whereClauseParm != null) {
- whereClause += whereClauseParm;
- }
- >132 String SQL = <SELECT >;
-
-
- user.mainmsg.setStatusMsg(JDPLang.get("Message0"), 0);
-
- <jaggPrefs>
- recCount = jaggSQL.execSQL(SQL, results);
-
- if(recCount == -1) {
- user.u.setSqlMessage(jaggSQL,SQL);
- return;
- }
- if(recCount == 0) {
- user.mainmsg.setStatusMsg(JDPLang.get("Message10"),10);
- <compName>CL1.hide();
- return;
- }
- <compName>CL1.show();
-
- //
- // Initialise result arrays
- //
- int columnCount = jaggSQL.getColumnCount();
- actualRows = jaggSQL.getRowCount();
-
- if (seriesCount <= 0) {
- p.chartData = new float[columnCount-groupCount][actualRows];
- p.xaxisLabel = new String[actualRows];
- p.piechartData = new float[actualRows];
- p.pieSplitSegment = new boolean[actualRows];
- p.pieLabel = new String[actualRows];
- if (p.chartType == JDPChart.PIE ||
- p.chartType == JDPChart.GANTT) {
- p.elementColor = new Color[actualRows];
- p.elementBorderColor = new Color[actualRows];
- p.elementLegend = new String[actualRows];
- }
- for (int ix=0; ix<actualRows; ix++) {
- row = (String)results.elementAt(ix);
- stok = new StringTokenizer(row,sep);
- p.xaxisLabel[ix] = "";
- if (groupCount > 0) p.xaxisLabel[ix] = stok.nextToken().trim();
- for (int iz=0; iz<columnCount-groupCount; iz++) {
- if (p.chartType == JDPChart.GANTT) {
- long val = (Long.valueOf(stok.nextToken()).longValue())/(86400000);
- p.chartData[iz][ix] = (float)val;
- } else {
- p.chartData[iz][ix] = Float.valueOf(stok.nextToken().trim()).floatValue();
- }
- }
- p.pieLabel[ix] = p.xaxisLabel[ix];
- p.piechartData[ix] = p.chartData[0][ix];
- if (p.chartType == JDPChart.PIE ||
- p.chartType == JDPChart.GANTT) {
- p.elementColor[ix] = JDPUtils.colorList[ix%12];
- p.elementBorderColor[ix] = Color.black;
- p.elementLegend[ix] = p.pieLabel[ix];
- }
- }
- } else {
- float[][] tempchartData = new float[1000][actualRows];
- p.xaxisLabel = new String[actualRows];
- Vector group = new Vector();
- if (groupCount == 0) group.addElement("");
- Vector series = new Vector();
- for (int ix=0; ix<actualRows; ix++) {
- row = (String)results.elementAt(ix);
- stok = new StringTokenizer(row,sep);
- p.xaxisLabel[ix] = "";
- int groupIndex = 0;
- if (groupCount > 0) {
- String groupValue = stok.nextToken().trim();
- groupIndex = group.indexOf(groupValue);
- if (groupIndex < 0) {
- group.addElement(groupValue);
- groupIndex = group.indexOf(groupValue);
- p.xaxisLabel[groupIndex] = groupValue;
- }
- }
- String seriesValue = stok.nextToken().trim();
- int seriesIndex = series.indexOf(seriesValue);
- if (seriesIndex < 0) {
- series.addElement(seriesValue);
- seriesIndex = series.indexOf(seriesValue);
- }
- tempchartData[seriesIndex][groupIndex] = Float.valueOf(stok.nextToken().trim()).floatValue();
- }
-
- int numbars = series.size();
- p.chartData = new float[numbars][group.size()];
- for (int ix=0; ix<numbars; ix++) {
- for (int iy=0; iy<group.size(); iy++) {
- p.chartData[ix][iy] = tempchartData[ix][iy];
- }
- }
- p.elementColor = new Color[numbars];
- p.elementBorderColor = new Color[numbars];
- p.elementLegend = new String[numbars];
- for (int ix=0; ix<numbars; ix++) {
- p.elementColor[ix] = JDPUtils.colorList[ix%12];
- p.elementBorderColor[ix] = Color.black;
- p.elementLegend[ix] = (String)series.elementAt(ix);
- }
- }
- <compName>CL1.calculateScaling();
- <compName>CL1.repaint();
-
- user.mainmsg.clearStatusMsg();
- }
-
- \*R //
- // Load the parameters for the selected chart
- //
- public void <compName>SetChartParms() {
-
- JDPChartParms p;
- if (<compName>CL1 == null) {
- p = new JDPChartParms();
- <compName>CL1 = new JDPChart(user, p);
- } else {
- p = <compName>CL1.p;
- }
-
- >158 p.chartType = <>;
- >159 p.autoscale = <>;
- >160 p.autozoom = <>;
-
- >141 p.chartTitle = "<>";
- p.chartTitleFont = user.boldFont.getName();
- >142 p.chartTitleColor = user.u._cvtcolor("<>");
-
- >143 p.xaxisTitle = "<>";
- p.xaxisTitleFont = user.boldFont.getName();
- >144 p.xaxisTitleColor = user.u._cvtcolor("<>");
-
- p.yaxisLabel = new String[10];
-
- p.elementLegendFont = user.boldFont.getName();
-
- >145 p.xaxisLabelColor = user.u._cvtcolor("<>");
- >146 p.yaxisLabelColor = user.u._cvtcolor("<>");
- >147 p.chartFrameColor = user.u._cvtcolor("<>");
-
- >148 p.elementLegend = new String[<>];
- >148 p.elementColor = new Color[<>];
- >148 p.elementBorderColor = new Color[<>];
- >149 p.elementLegend[<iy>] = "<selectChartDef.elementLegend[ix]>";
- >150 p.elementColor[<iy>] = user.u._cvtcolor("<>");
- >151 p.elementBorderColor[<iy>] = user.u._cvtcolor("<selectChartDef.elementBorderColor[ix]>");
-
- >152 p.gridLineSetting = <JDPChart.HORIZONTAL + JDPChart.VERTICAL + JDPChart.FOREGROUND + JDPChart.BACKGROUND>;
- >153 p.gridColor = user.u._cvtcolor("<>");
-
- >156 p.maxPlotValue = <>;
- >157 p.minPlotValue = <>;
-
- if ((p.chartType == JDPChart.COLUMN) || (p.chartType == JDPChart.BAR) ||
- (p.chartType == JDPChart.AREA)) {
- p.autozoom = false;
- }
-
- p.pieLabel = p.elementLegend;
- p.pieLabelColor = p.xaxisTitleColor;
-
- }
-
-