jeraldmuthu 0 Newbie Poster

In this class for each case i'm generating XML (XML creation code is in last)

in Xhtml i added javascript

<tr> 
           <td align='center'>
				<div id="chart1Div">
				  This text is replaced by chart.
				</div>
				<script type="text/javascript">
					var chart1 = new FusionCharts("Charts/MSColumn3D.swf", "ChId1", "600", "600", "0", "1");
					chart1.setXMLUrl("Charts/test.xml");
				   chart1.render("chart1Div");
				</script>
			  </td>
            </tr>

for this javascript i need to feed that xml. how can i get the case 1 value as 1 in javascript

for each case i have created selectone combo box

<ice:selectOneMenu value="#{chart01.chartType}" disabled="#{chart01 == null}" 
onchange="iceSubmit(form, this, event);return false;">
						<f:selectItems value="#{analysisBean.chartSelectionTypes}" />
					</ice:selectOneMenu>

Now the Problem is the xml generating for each case but i want to get that output means i need to refresh the folder by manually.
So how can i refresh the file by coding
Help me to Fix


XML Generating Code

package com.distilinfo.chart;
//Contributor: i18n : Pedro Casals Fradera (2006/06/22)
import java.awt.Color;
import java.awt.Font;
import java.awt.Paint;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;

import javax.faces.context.FacesContext;

import org.apache.log4j.Logger;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.PieToolTipGenerator;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.labels.StandardPieToolTipGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.MultiplePiePlot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.category.AreaRenderer;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.chart.renderer.category.StackedAreaRenderer;
import org.jfree.chart.renderer.category.StackedBarRenderer;
import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.urls.CategoryURLGenerator;
import org.jfree.chart.urls.PieURLGenerator;
import org.jfree.chart.urls.StandardPieURLGenerator;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.ui.RectangleInsets;
import org.jfree.util.TableOrder;
import org.jfree.util.UnitType;

import com.distilinfo.analysis.Analysis;
import com.distilinfo.olap.drillthrough.CustomDrillthroughUI;
import com.distilinfo.project.ProjectContext;
import com.distilinfo.web.ui.jsf.util.FacesUtils;
import com.distilinfo.xmla.DatasetAdapter;
import com.tonbeller.jpivot.chart.ChartFactory;
import com.tonbeller.jpivot.olap.model.Cell;
import com.tonbeller.jpivot.olap.model.OlapException;
import com.tonbeller.jpivot.olap.model.OlapModel;
import com.tonbeller.jpivot.olap.model.Result;
import com.tonbeller.jpivot.olap.navi.DrillThrough;
import com.tonbeller.wcf.controller.Dispatcher;
import com.tonbeller.wcf.controller.DispatcherSupport;
import com.tonbeller.wcf.utils.DomUtils;


//for Xml added by jerald

import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import java.io.*;
//upto dis



/**
 * This is a badly needed an extracted factory class to properly test chart creation.
 * Before was couple with the chart component.
 *
 */
public class EnhancedChartFactory extends ChartFactory {
	private static Logger logger = Logger.getLogger(EnhancedChartFactory.class);

	protected static Result result;
	protected static OlapModel olapModel;
	protected static Dispatcher dispatcher = new DispatcherSupport();

	public EnhancedChartFactory() {
		super();
	}

	/**
	 * wrapper method that uses distil domain objects as input, returns chart.
	 *
	 * @param analysis
	 * @param dataset
	 * @return
	 * @throws Exception 
	 */
	/*public static MaaniChart createChart(Analysis analysis,
			OlapModel olapModel, Locale locale, List colorPalette, CategoryURLGenerator urlGenerator, String webControllerURL, int width, int height, boolean suppressCrowdedLabels) throws OlapException {
		logger.debug("creating chart for analysis: " + analysis.getAnalysisTitle());
		
		MaaniChart chart = EnhancedChartFactory.createChart(olapModel, 
				analysis.getChartType(), analysis.getChartTitle(),
				analysis.getHorizAxisLabel(), analysis.getVertAxisLabel(), 
				analysis.isShowLegend(), true, 
				analysis.isDrillThroughEnabled(), 
				new Font(analysis.getFontName(), analysis.getFontStyle(), analysis.getFontSize()), 
				new Color(analysis.getBgColorR(), analysis.getBgColorG(), analysis.getBgColorB()), 
				new Font(analysis.getSlicerFontName(), analysis.getSlicerFontStyle(), analysis.getSlicerFontSize()), 
				new Font(analysis.getAxisFontName(), analysis.getAxisFontStyle(), analysis.getAxisFontSize()), 
				new Font(analysis.getAxisTickFontName(), analysis.getAxisTickFontStyle(), analysis.getAxisTickFontSize()), 
				new Font(analysis.getLegendFontName(), analysis.getLegendFontStyle(), analysis.getLegendFontSize()), 
				analysis.getLegendPosition(), 
				analysis.getTickLabelRotate(), 
				1.0f, 
				analysis.isShowSlicer(), 
				analysis.getSlicerPosition(), 
				analysis.getSlicerAlignment(), 
				analysis.getShowPareto(), 
				locale, colorPalette,urlGenerator, webControllerURL, width, height, suppressCrowdedLabels);

		return chart;
	}*/
	
	
	
	public static JFreeChart createChart(Analysis analysis,
			OlapModel olapModel, Locale locale, List colorPalette, CategoryURLGenerator urlGenerator, String webControllerURL, int width, int height, boolean suppressCrowdedLabels) throws Exception {
		logger.debug("creating chart for analysis: " + analysis.getAnalysisTitle());
		
		JFreeChart chart = EnhancedChartFactory.createChart(olapModel, 
				analysis.getChartType(), analysis.getChartTitle(),
				analysis.getHorizAxisLabel(), analysis.getVertAxisLabel(), 
				analysis.isShowLegend(), true, 
				analysis.isDrillThroughEnabled(), 
				new Font(analysis.getFontName(), analysis.getFontStyle(), analysis.getFontSize()), 
				new Color(analysis.getBgColorR(), analysis.getBgColorG(), analysis.getBgColorB()), 
				new Font(analysis.getSlicerFontName(), analysis.getSlicerFontStyle(), analysis.getSlicerFontSize()), 
				new Font(analysis.getAxisFontName(), analysis.getAxisFontStyle(), analysis.getAxisFontSize()), 
				new Font(analysis.getAxisTickFontName(), analysis.getAxisTickFontStyle(), analysis.getAxisTickFontSize()), 
				new Font(analysis.getLegendFontName(), analysis.getLegendFontStyle(), analysis.getLegendFontSize()), 
				analysis.getLegendPosition(), 
				analysis.getTickLabelRotate(), 
				1.0f, 
				analysis.isShowSlicer(), 
				analysis.getSlicerPosition(), 
				analysis.getSlicerAlignment(), 
				analysis.getShowPareto(), 
				locale, colorPalette,urlGenerator, webControllerURL, width, height, suppressCrowdedLabels);

		return chart;
	}

	/**
	 * method used to stream chart directly to the output stream.
	 * Intended for use in a servlet (e.g. - dashboard servlet).
	 *
	 * @param out
	 * @param analysis
	 * @param dataset
	 * @param width
	 * @param height
	 * @throws Exception 
	 */

	/*public static void createChart(OutputStream out, Analysis analysis,
			OlapModel olapModel, int width, int height, Locale locale, List colorPalette, CategoryURLGenerator urlGenerator, String webControllerURL, boolean suppressCrowdedLabels)
	throws Exception {

		logger.debug("writing chart for analysis: " + analysis.getAnalysisTitle() + " " + width + "x" + height);
		logger.debug("to stream type: " + out.getClass().getName());

		float quality = 1.0f;
		MaaniChart chart = EnhancedChartFactory.createChart(analysis, olapModel, locale, colorPalette, urlGenerator, webControllerURL, width , height, suppressCrowdedLabels);
		//ChartUtilities.writeChartAsJPEG(out, quality, chart, width, height);
		//MaaniChartUtility.writeChartScript(out, quality, chart, width, height);
		MaaniChartUtility.writeChartXML(out, quality, chart, width, height);
	}*/
	public static void createChart(OutputStream out, Analysis analysis,
			OlapModel olapModel, int width, int height, Locale locale, List colorPalette, CategoryURLGenerator urlGenerator, String webControllerURL, boolean suppressCrowdedLabels)
	throws Exception {

		logger.debug("writing chart for analysis: " + analysis.getAnalysisTitle() + " " + width + "x" + height);
		logger.debug("to stream type: " + out.getClass().getName());

		float quality = 1.0f;
		JFreeChart chart = EnhancedChartFactory.createChart(analysis, olapModel, locale, colorPalette, urlGenerator, webControllerURL, width , height, suppressCrowdedLabels);
		ChartUtilities.writeChartAsJPEG(out, quality, chart, width, height);
	}
	
	/**
	 * factory method used in the wcf EnhancedChartComponent, also used internally by
	 * other wrapper createChart methods
	 *
	 * @return
	 * @throws OlapException
	 */
	/*public static MaaniChart createChart(OlapModel olapModel, 
			int chartType, String chartTitle,
			String horizAxisLabel, 
			String vertAxisLabel, 
			boolean showLegend, 
			boolean showTooltips, 
			boolean drillThroughEnabled, 
			Font titleFont, 
			Paint bgPaint, 
			Font slicerFont, 
			Font axisFont, 
			Font axisTickFont, 
			Font legendFont, 
			int legendPosition, 
			double tickLabelRotate, 
			float foregroundAlpha, 
			boolean showSlicer, 
			int slicerPosition, 
			int slicerAlignment, 
			boolean showPareto, 
			Locale locale, 
			List colorPalette, 
			CategoryURLGenerator urlGenerator,
			String webControllerURL, int chartWidth, int chartHeight, boolean suppressCrowdedLabels) throws OlapException {
		logger.debug("trying to create chartType: " + chartType + " with locale=" + locale.getLanguage());

		//JFreeChart chart = null;
		MaaniChart chart = null;

		//jpivotPieURLGenerator pieUrlgenerator = new jpivotPieURLGenerator(PiePlot.PER_ROW);
		//CategoryURLGenerator urlGenerator = null;

		DatasetAdapter adapter = new DatasetAdapter(locale);
		MaaniCategoryDataset dataset = null;

		if(chartType < 1 || chartType > 19){
			throw new OlapException("An unknown Chart Type was requested: " +
					chartType);
		}

		dataset = adapter.buildCategoryDataset(olapModel);
		chart = new MaaniChart(chartTitle, 
				titleFont, 
				horizAxisLabel, 
				vertAxisLabel, 
				dataset, 
				chartType, 
				showLegend, 
				showTooltips, 
				drillThroughEnabled, 
				urlGenerator);
		MaaniChartCustomizer customizer = new MaaniChartCustomizer(bgPaint, axisFont, 
				axisTickFont, legendFont, legendPosition, tickLabelRotate, foregroundAlpha, colorPalette, chartWidth, chartHeight, suppressCrowdedLabels);
		chart.setCustomizer(customizer);

		[--TODO Needs to explore Pareto
		 * if(showPareto){
			if(chart.getPlot() instanceof CategoryPlot){
				customizer.generatePareto((CategoryPlot)chart.getPlot());
			}
		}

		TODO Formatting based on locale
		if(chart.getPlot() instanceof CategoryPlot){
			if(FacesContext.getCurrentInstance() !=null ){
			ProjectContext projCtx = (ProjectContext)FacesUtils.getBean(FacesContext.getCurrentInstance(), "projectContext");
			Locale loc  = projCtx.getUser().getLocale();
			customizer.formatNumberAxis(NumberFormat.getInstance(loc), (CategoryPlot)chart.getPlot());
			}
		}

		TODO Slicer
		logger.debug("showSlicer=" + showSlicer);
		if(showSlicer){customizer.customizeSlicer(
				chart, 
				olapModel,
				slicerFont, 
				slicerPosition, 
				slicerAlignment,
				locale); 
		}--]        
		return chart;
	}*/
	
	//added by Jerald 
	

	


	
	public static JFreeChart createChart(OlapModel olapModel, 
			int chartType, String chartTitle,
			String horizAxisLabel, 
			String vertAxisLabel, 
			boolean showLegend, 
			boolean showTooltips, 
			boolean drillThroughEnabled, 
			Font titleFont, 
			Paint bgPaint, 
			Font slicerFont, 
			Font axisFont, 
			Font axisTickFont, 
			Font legendFont, 
			int legendPosition, 
			double tickLabelRotate, 
			float foregroundAlpha, 
			boolean showSlicer, 
			int slicerPosition, 
			int slicerAlignment, 
			boolean showPareto, 
			Locale locale, 
			List colorPalette, 
			CategoryURLGenerator urlGenerator,
			String webControllerURL, int chartWidth, int chartHeight, boolean suppressCrowdedLabels) throws OlapException,Exception {
		logger.debug("trying to create chartType: " + chartType + " with locale=" + locale.getLanguage());

		JFreeChart chart = null;

		//jpivotPieURLGenerator pieUrlgenerator = new jpivotPieURLGenerator(PiePlot.PER_ROW);
		//CategoryURLGenerator urlGenerator = null;

		DatasetAdapter adapter = new DatasetAdapter(locale);
		DefaultCategoryDataset dataset = null;

		switch (chartType) {
		case 1:
			
			  DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
		        DocumentBuilder docBuilder = builderFactory.newDocumentBuilder();
		        //creating a new instance of a DOM to build a DOM tree.
		        Document doc = docBuilder.newDocument();
		        
			
			
			dataset = adapter.buildCategoryDataset(olapModel);
			System.out.println("chart type One "+dataset);
			System.out.println("EnhancedChartFactory.java returning dataset for case 1"+dataset);
			String st = dataset.getColumnKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getColumnkeys for case 1 "+st);
			String st1 = dataset.getRowKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getRowkeys for case 1 "+st1);
				
			//dataset.getValue(st1,st);
			//String st2 = dataset.getValue(st1,st).toString();
			//System.out.println("EnhancedChartFactory.java returning dataset getValues for case 1 "+st2);
			String cols1 = st.replace("[", "");
			String rows1 = st1.replace("[", "");
			String cols = cols1.replace("]", "");
			String rows = rows1.replace("]", "");
			Number values;
			String values1;
			String casevalue1="1";
			//int values = Integer.parseInt(st2);
			
			 String strXML;
			 String chartId = "basicChart";
			 String url = "Charts/test.xml";
			 //String jsonUrl = "Data/Data.json";
			 String width = "600";
			 String height = "300";
			 String folderPath="Charts/FusionCharts.js";
			 String swfFilename = "Charts/Column3D.swf";
			 String uniqueId = "";

			 
			 
			
			String[] tempCols=new String[250];
			String[] tempRows=new String[250];
			String[] tempValues=new String[250];
			 strXML = "<chart caption='My first chart'>";
			//Element root = doc.createElement(strXML);
			String delimiter = ", ";

			tempCols = cols.split(delimiter);
			
			strXML += "<categories>";
			//Element cat = doc.createElement(strXML);
			
			for(int i=0 ; i < tempCols.length; i++) {
				strXML += "<category label = '";// now run
				strXML += tempCols[i];
				//cat.setAttribute("label",strXML);
				//root.appendChild(cat);
				strXML += "'/>";
			}
			strXML +="</categories>";
			tempRows = rows.split(delimiter);
			
			for(int j = 0; j < tempRows.length; j++) {
				
				strXML += "<dataset seriesname='";
				//Element dat = doc.createElement(strXML);
				strXML += tempRows[j];
				//dat.setAttribute("seriessname", strXML);
				strXML += "'>";
				
				for(int l=0 ; l < tempCols.length; l++)
				{
					
				
				
				// write query here to retrieve values, by passing both the columns and the rows as parameters
				values = (dataset.getValue(tempRows[j], tempCols[l]));
				String values2=values.toString();
				//values1 = (dataset.getValue(tempRows[j], tempCols[j])).toString();
				tempValues = values2.split(delimiter);
				for(int k = 0; k < tempValues.length; k++) {
					strXML += "<set value = '";
					//Element set = doc.createElement(strXML);
					strXML += tempValues[k];
					//set.setAttribute("value",strXML);
					//root.appendChild(set);
					strXML += "'/>";
				}
				
				//root.appendChild(dat);
			}
				strXML += "</dataset>";
			}
			
		

			strXML += "</chart>";
			
			
				// write the strXML to the console.
				System.out.println(strXML);
	
				Writer output = null;
				File file = new File("C:\\Users\\ssss\\Desktop\\Boom\\WebContent\\Charts\\test.xml");
				
				//File file = new File(System.getProperty("user.home")+"\\Charts\\test.xml);
				 output = new BufferedWriter(new FileWriter(file));
				 output.write(strXML);
				 output.flush();
				 output.close();
				 
				 
				 
				 
				 //for creating file
				 
				 
				 Writer outp = null;
					File Cfile = new File("C:\\Users\\sbabu\\Desktop\\distil-web1.3\\WebContent\\Charts\\casefile.txt");
					outp = new BufferedWriter(new FileWriter(Cfile));
					System.out.println("file create");
					 outp.write("1");
					 System.out.println("file write");
					 outp.flush();
					 outp.close();
				 
				 
				 
				 
				 
				
				
				
				/*
				TransformerFactory factory = TransformerFactory.newInstance();
		        Transformer transformer = factory.newTransformer();
		       
		        transformer.setOutputProperty(OutputKeys.INDENT, "yes");

		        // create string from xml tree
		        StringWriter sw = new StringWriter();
		        StreamResult result = new StreamResult(sw);
		        DOMSource source = new DOMSource(doc);
		        transformer.transform(source, result);
		        String xmlString = sw.toString();

		        File file = new File("c:/newxml.xml");
		        BufferedWriter bw = new BufferedWriter
		                      (new OutputStreamWriter(new FileOutputStream(file)));
		        bw.write(xmlString);
		        bw.flush();
		        bw.close();
		      
				*/
				
				
				
				
				
			chart = EnhancedChartFactory.createBarChart(chartTitle, 
					titleFont,
					horizAxisLabel, 
					vertAxisLabel, 
					dataset,
					PlotOrientation.VERTICAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 2:
			dataset = adapter.buildCategoryDataset(olapModel);
			
			//Fusion Chart Coding Added
			
			//dataset = adapter.buildCategoryDataset(olapModel);
			System.out.println("chart type One "+dataset);
			System.out.println("EnhancedChartFactory.java returning dataset for case 2"+dataset);
			String st4 = dataset.getColumnKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getColumnkeys for case 2 "+st4);
			String st5 = dataset.getRowKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getRowkeys for case 2 "+st5);
				
			//dataset.getValue(st1,st);
			//String st2 = dataset.getValue(st1,st).toString();
			//System.out.println("EnhancedChartFactory.java returning dataset getValues for case 1 "+st2);
			String cols3 = st4.replace("[", "");
			String rows3 = st5.replace("[", "");
			String cols2 = cols3.replace("]", "");
			String rows2 = rows3.replace("]", "");
			Number values3;
			String values4;
			//int values = Integer.parseInt(st2);
			
			 String strXML1;
			 String chartId1 = "basicChart";
			 String url1 = "Charts/test.xml";
			 //String jsonUrl = "Data/Data.json";
			 String width1 = "600";
			 String height1 = "300";
			 String folderPath1="Charts/FusionCharts.js";
			 String swfFilename1 = "Charts/Column3D.swf";
			 String uniqueId1 = "";

			 
			 
			
			String[] tempCols1=new String[250];
			String[] tempRows1=new String[250];
			String[] tempValues1=new String[250];
			 strXML = "<chart caption='My first chart'>";
			//Element root = doc.createElement(strXML);
			String delimiter1 = ", ";

			tempCols = cols2.split(delimiter1);
			
			strXML += "<categories>";
			//Element cat = doc.createElement(strXML);
			
			for(int i=0 ; i < tempCols.length; i++) {
				strXML += "<category label = '";// now run
				strXML += tempCols[i];
				//cat.setAttribute("label",strXML);
				//root.appendChild(cat);
				strXML += "'/>";
			}
			strXML +="</categories>";
			tempRows = rows2.split(delimiter1);
			
			for(int j = 0; j < tempRows.length; j++) {
				
				strXML += "<dataset seriesname='";
				//Element dat = doc.createElement(strXML);
				strXML += tempRows[j];
				//dat.setAttribute("seriessname", strXML);
				strXML += "'>";
				
				for(int l=0 ; l < tempCols.length; l++)
				{
					
				
				
				// write query here to retrieve values, by passing both the columns and the rows as parameters
				values = (dataset.getValue(tempRows[j], tempCols[l]));
				String values2=values.toString();
				//values1 = (dataset.getValue(tempRows[j], tempCols[j])).toString();
				tempValues = values2.split(delimiter1);
				for(int k = 0; k < tempValues.length; k++) {
					strXML += "<set value = '";
					//Element set = doc.createElement(strXML);
					strXML += tempValues[k];
					//set.setAttribute("value",strXML);
					//root.appendChild(set);
					strXML += "'/>";
				}
				
				//root.appendChild(dat);
			}
				strXML += "</dataset>";
			}
			
		

			strXML += "</chart>";
			
			
				// write the strXML to the console.
				System.out.println(strXML);
	
				Writer output1 = null;
				File file1 = new File("C:\\Users\\ssss\\Desktop\\Boom\\WebContent\\Charts\\test2.xml");
				
				 output = new BufferedWriter(new FileWriter(file1));
				 output.write(strXML);
				 output.flush();
				 output.close();
				 
				 
				 //Till This
			
			System.out.println("EnhancedChartFactory.java returning dataset for case 2"+dataset);
			chart = EnhancedChartFactory.createBarChart3D(chartTitle,
					titleFont, 
					horizAxisLabel, 
					vertAxisLabel, 
					dataset,
					PlotOrientation.VERTICAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 3:
			dataset = adapter.buildCategoryDataset(olapModel);
			
//Fusion Chart Coding Added
			
			
			System.out.println("chart type One "+dataset);
			System.out.println("EnhancedChartFactory.java returning dataset for case 3"+dataset);
			String st6 = dataset.getColumnKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getColumnkeys for case 3 "+st6);
			String st7 = dataset.getRowKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getRowkeys for case 3 "+st7);
				
			//dataset.getValue(st1,st);
			//String st2 = dataset.getValue(st1,st).toString();
			//System.out.println("EnhancedChartFactory.java returning dataset getValues for case 1 "+st2);
			String cols5 = st6.replace("[", "");
			String rows5 = st7.replace("[", "");
			String cols4 = cols5.replace("]", "");
			String rows4 = rows5.replace("]", "");
			Number values6;
			String values7;
			//int values = Integer.parseInt(st2);
			
			 String strXML2;
			 String chartId2 = "basicChart";
			 String url2 = "Charts/test.xml";
			 //String jsonUrl = "Data/Data.json";
			 String width2 = "600";
			 String height2 = "300";
			 String folderPath2="Charts/FusionCharts.js";
			 String swfFilename2 = "Charts/Column3D.swf";
			 String uniqueId2 = "";

			 
			 
			
			String[] tempCols2=new String[250];
			String[] tempRows2=new String[250];
			String[] tempValues2=new String[250];
			 strXML2 = "<chart caption='My first chart'>";
			//Element root = doc.createElement(strXML);
			String delimiter2 = ", ";

			tempCols2 = cols4.split(delimiter2);
			
			strXML2 += "<categories>";
			//Element cat = doc.createElement(strXML);
			
			for(int i=0 ; i < tempCols2.length; i++) {
				strXML2 += "<category label = '";// now run
				strXML2 += tempCols2[i];
				//cat.setAttribute("label",strXML);
				//root.appendChild(cat);
				strXML2 += "'/>";
			}
			strXML2 +="</categories>";
			tempRows2 = rows4.split(delimiter2);
			
			for(int j = 0; j < tempRows2.length; j++) {
				
				strXML2 += "<dataset seriesname='";
				//Element dat = doc.createElement(strXML);
				strXML2 += tempRows2[j];
				//dat.setAttribute("seriessname", strXML);
				strXML2 += "'>";
				
				for(int l=0 ; l < tempCols2.length; l++)
				{
					
				
				
				// write query here to retrieve values, by passing both the columns and the rows as parameters
				values = (dataset.getValue(tempRows2[j], tempCols2[l]));
				String values2=values.toString();
				//values1 = (dataset.getValue(tempRows[j], tempCols[j])).toString();
				tempValues = values2.split(delimiter2);
				for(int k = 0; k < tempValues.length; k++) {
					strXML2 += "<set value = '";
					//Element set = doc.createElement(strXML);
					strXML2 += tempValues[k];
					//set.setAttribute("value",strXML);
					//root.appendChild(set);
					strXML2 += "'/>";
				}
				
				//root.appendChild(dat);
			}
				strXML2 += "</dataset>";
			}
			
		

			strXML2 += "</chart>";
			
			
				// write the strXML to the console.
				System.out.println(strXML2);
	
				Writer output2 = null;
				File file2 = new File("C:\\Users\\ssss\\Desktop\\Boom\\WebContent\\Charts\\test3.xml");
				 output = new BufferedWriter(new FileWriter(file2));
				 output.write(strXML2);
				 output.flush();
				 output.close();
				 
				 
				 
				 
				 //for creating file
				 
 
				 
				 
				 
				 
				 
				 
				 
				 
				 //Till This
			
			System.out.println("EnhancedChartFactory.java returning dataset for case 3"+dataset);
			chart = EnhancedChartFactory.createBarChart(chartTitle, 
					titleFont,
					horizAxisLabel, 
					vertAxisLabel, 
					dataset,
					PlotOrientation.HORIZONTAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 4:
			dataset = adapter.buildCategoryDataset(olapModel);
			
			//Coding For Fusion Chart Added Here
			
			System.out.println("chart type One "+dataset);
			System.out.println("EnhancedChartFactory.java returning dataset for case 4"+dataset);
			String st8 = dataset.getColumnKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getColumnkeys for case 4 "+st8);
			String st9 = dataset.getRowKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getRowkeys for case 4 "+st9);
				
			String cols7 = st8.replace("[", "");
			String rows7 = st9.replace("[", "");
			String cols6 = cols7.replace("]", "");
			String rows6= rows7.replace("]", "");
			Number values8;
			String values9;
			//int values = Integer.parseInt(st2);
			
			 String strXML4;
			 String chartId4 = "basicChart";
			 String url4 = "Charts/test.xml";
			 //String jsonUrl = "Data/Data.json";
			 String width4 = "600";
			 String height4 = "300";
			 String folderPath4="Charts/FusionCharts.js";
			 String swfFilename4 = "Charts/Column3D.swf";
			 String uniqueId4 = "";

			 
			 
			
			String[] tempCols4=new String[250];
			String[] tempRows4=new String[250];
			String[] tempValues4=new String[250];
			 strXML4 = "<chart caption='My first chart'>";
			
			String delimiter4 = ", ";

			tempCols4 = cols6.split(delimiter4);
			
			strXML4 += "<categories>";
			
			
			for(int i=0 ; i < tempCols4.length; i++) {
				strXML4 += "<category label = '";// now run
				strXML4 += tempCols4[i];
				strXML4 += "'/>";
			}
			strXML4 +="</categories>";
			tempRows4 = rows6.split(delimiter4);
			
			for(int j = 0; j < tempRows4.length; j++) {
				
				strXML4 += "<dataset seriesname='";
				strXML4 += tempRows4[j];
				strXML4 += "'>";
				
				for(int l=0 ; l < tempCols4.length; l++)
				{
								
				// write query here to retrieve values, by passing both the columns and the rows as parameters
				values8 = (dataset.getValue(tempRows4[j], tempCols4[l]));
				String values10=values8.toString();
				//values1 = (dataset.getValue(tempRows[j], tempCols[j])).toString();
				tempValues = values10.split(delimiter4);
				for(int k = 0; k < tempValues.length; k++) {
					strXML4 += "<set value = '";
					strXML4 += tempValues[k];
					strXML4 += "'/>";
				}
				
				//root.appendChild(dat);
			}
				strXML4 += "</dataset>";
			}
			
		

			strXML4 += "</chart>";
			
			
				// write the strXML to the console.
				System.out.println(strXML4);
	
				Writer output4 = null;
				File file4 = new File("C:\\Users\\ssss\\Desktop\\Boom\\WebContent\\Charts\\test4.xml");
				 output = new BufferedWriter(new FileWriter(file4));
				 output.write(strXML4);
				 output.close();

				 //Till This
			
			System.out.println("EnhancedChartFactory.java returning dataset for case 4"+dataset);
			chart = EnhancedChartFactory.createBarChart3D(chartTitle,
					titleFont, 
					horizAxisLabel, 
					vertAxisLabel, 
					dataset, 
					PlotOrientation.HORIZONTAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 5:
			dataset = adapter.buildCategoryDataset(olapModel);
			
//Coding For Fusion Chart Added Here
			
			System.out.println("chart type One "+dataset);
			System.out.println("EnhancedChartFactory.java returning dataset for case 17"+dataset);
			String st10 = dataset.getColumnKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getColumnkeys for case 17 "+st10);
			String st11 = dataset.getRowKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getRowkeys for case 17 "+st11);
				
			//dataset.getValue(st1,st);
			//String st2 = dataset.getValue(st1,st).toString();
			//System.out.println("EnhancedChartFactory.java returning dataset getValues for case 1 "+st2);
			String cols9 = st10.replace("[", "");
			String rows9 = st11.replace("[", "");
			String cols8 = cols9.replace("]", "");
			String rows8= rows9.replace("]", "");
			Number values11;
			String values12;
			//int values = Integer.parseInt(st2);
			
			 String strXML5;
			 String chartId5 = "basicChart";
			 String url5 = "Charts/test.xml";
			 //String jsonUrl = "Data/Data.json";
			 String width5 = "600";
			 String height5 = "300";
			 String folderPath5="Charts/FusionCharts.js";
			 String swfFilename5 = "Charts/Column3D.swf";
			 String uniqueId5 = "";

			 
			 
			
			String[] tempCols5=new String[250];
			String[] tempRows5=new String[250];
			String[] tempValues5=new String[250];
			 strXML5 = "<chart caption='My first chart'>";
			String delimiter5 = ", ";

			tempCols5 = cols8.split(delimiter5);
			
			strXML5 += "<categories>";
			
			
			for(int i=0 ; i < tempCols5.length; i++) {
				strXML5 += "<category label = '";// now run
				strXML5 += tempCols5[i];
				strXML5 += "'/>";
			}
			strXML5 +="</categories>";
			tempRows5 = rows8.split(delimiter5);
			
			for(int j = 0; j < tempRows5.length; j++) {
				
				strXML5 += "<dataset seriesname='";
				strXML5 += tempRows5[j];
				strXML5 += "'>";
				
				for(int l=0 ; l < tempCols5.length; l++)
				{
					
				
				
				// write query here to retrieve values, by passing both the columns and the rows as parameters
				values11 = (dataset.getValue(tempRows5[j], tempCols5[l]));
				String values13=values11.toString();
				//values1 = (dataset.getValue(tempRows[j], tempCols[j])).toString();
				tempValues = values13.split(delimiter5);
				for(int k = 0; k < tempValues.length; k++) {
					strXML5 += "<set value = '";
					strXML5 += tempValues[k];
					strXML5 += "'/>";
				}
				
				
			}
				strXML5 += "</dataset>";
			}
			
		

			strXML5 += "</chart>";
			
			
				// write the strXML to the console.
				System.out.println(strXML5);
	
				Writer output5 = null;
				File file5 = new File("C:\\Users\\ssss\\Desktop\\Boom\\Charts\\test5.xml");
				 output5 = new BufferedWriter(new FileWriter(file5));
				 output5.write(strXML5);
				 output5.close();
				 
				 
 
				 

				System.out.println("EnhancedChartFactory.java returning dataset for case 5"+dataset);
			chart = EnhancedChartFactory.createStackedBarChart(chartTitle,
					titleFont, 
					horizAxisLabel, 
					vertAxisLabel, 
					dataset,
					PlotOrientation.VERTICAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 6:
			dataset = adapter.buildCategoryDataset(olapModel);
			

			
			System.out.println("EnhancedChartFactory.java returning dataset for case 6"+dataset);
			chart = EnhancedChartFactory.createStackedBarChart3D(chartTitle,
					titleFont, 
					horizAxisLabel, 
					vertAxisLabel, 
					dataset, 
					PlotOrientation.VERTICAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 7:
			dataset = adapter.buildCategoryDataset(olapModel);
			System.out.println("EnhancedChartFactory.java returning dataset for case 7"+dataset);
			chart = EnhancedChartFactory.createStackedBarChart(chartTitle,
					titleFont, 
					horizAxisLabel, 
					vertAxisLabel, 
					dataset,
					PlotOrientation.HORIZONTAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 8:
			dataset = adapter.buildCategoryDataset(olapModel);
			System.out.println("EnhancedChartFactory.java returning dataset for case 8"+dataset);
			chart = EnhancedChartFactory.createStackedBarChart3D(chartTitle,
					titleFont, 
					horizAxisLabel, 
					vertAxisLabel, 
					dataset,
					PlotOrientation.HORIZONTAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 9:
			dataset = adapter.buildCategoryDataset(olapModel);
			
//Coding For Fusion Chart Added Here
			
			System.out.println("chart type One "+dataset);
			System.out.println("EnhancedChartFactory.java returning dataset for case 6"+dataset);
			String st12 = dataset.getColumnKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getColumnkeys for case 6 "+st12);
			String st13 = dataset.getRowKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getRowkeys for case 6 "+st13);
				
			//dataset.getValue(st1,st);
			//String st2 = dataset.getValue(st1,st).toString();
			//System.out.println("EnhancedChartFactory.java returning dataset getValues for case 1 "+st2);
			String cols11 = st12.replace("[", "");
			String rows11 = st13.replace("[", "");
			String cols10 = cols11.replace("]", "");
			String rows10= rows11.replace("]", "");
			Number values14;
			String values15;
			//int values = Integer.parseInt(st2);
			
			 String strXML6;
			 String chartId6 = "basicChart";
			 String url6 = "Charts/test.xml";
			 //String jsonUrl = "Data/Data.json";
			 String width6 = "600";
			 String height6 = "300";
			 String folderPath6="Charts/FusionCharts.js";
			 String swfFilename6 = "Charts/Column3D.swf";
			 String uniqueId6 = "";

			 
			 
			
			String[] tempCols6=new String[250];
			String[] tempRows6=new String[250];
			String[] tempValues6=new String[250];
			 strXML6 = "<chart caption='My first chart'>";
			//Element root = doc.createElement(strXML);
			String delimiter6 = ", ";

			tempCols6 = cols10.split(delimiter6);
			
			strXML6 += "<categories>";
			//Element cat = doc.createElement(strXML);
			
			for(int i=0 ; i < tempCols6.length; i++) {
				strXML6 += "<category label = '";// now run
				strXML6 += tempCols6[i];
				//cat.setAttribute("label",strXML);
				//root.appendChild(cat);
				strXML6 += "'/>";
			}
			strXML6 +="</categories>";
			tempRows6 = rows10.split(delimiter6);
			
			for(int j = 0; j < tempRows6.length; j++) {
				
				strXML6 += "<dataset seriesname='";
				//Element dat = doc.createElement(strXML);
				strXML6 += tempRows6[j];
				//dat.setAttribute("seriessname", strXML);
				if(j==tempRows6.length-1)
					strXML6 +="' parentYAxis='S'>";
				else
					strXML6 += "'>";
				
				for(int l=0 ; l < tempCols6.length; l++)
				{
								
				// write query here to retrieve values, by passing both the columns and the rows as parameters
				values14 = (dataset.getValue(tempRows6[j], tempCols6[l]));
				String values16=values14.toString();
				//values1 = (dataset.getValue(tempRows[j], tempCols[j])).toString();
				tempValues = values16.split(delimiter6);
				for(int k = 0; k < tempValues.length; k++) {
					strXML6 += "<set value = '";
					//Elemet set = doc.createElement(strXML);
					strXML6 += tempValues[k];
					//set.setAttribute("value",strXML);
					//root.appendChild(set);
					strXML6 += "'/>";
				}
				
				//root.appendChild(dat);
			}
				strXML6 += "</dataset>";
			}
			
		

			strXML6 += "</chart>";
			
			
				// write the strXML to the console.
				System.out.println(strXML6);
	
				Writer output6 = null;
				File file6 = new File("C:\\Users\\ssss\\Desktop\\Boom\\Charts\\test6.xml");

				 output = new BufferedWriter(new FileWriter(file6));
				 output.write(strXML6);
				 output.close();

				 //Till This
			
			System.out.println("EnhancedChartFactory.java returning dataset for case 9"+dataset);
			chart = EnhancedChartFactory.createLineChart(chartTitle, 
					titleFont,
					horizAxisLabel, 
					vertAxisLabel, 
					dataset,
					PlotOrientation.VERTICAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 10:
			dataset = adapter.buildCategoryDataset(olapModel);
			
			System.out.println("chart type One "+dataset);
			System.out.println("EnhancedChartFactory.java returning dataset for case 10"+dataset);
			String st14 = dataset.getColumnKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getColumnkeys for case 10 "+st14);
			String st15 = dataset.getRowKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getRowkeys for case 10 "+st15);
				
			//dataset.getValue(st1,st);
			//String st2 = dataset.getValue(st1,st).toString();
			//System.out.println("EnhancedChartFactory.java returning dataset getValues for case 1 "+st2);
			String cols14 = st14.replace("[", "");
			String rows14 = st15.replace("[", "");
			String cols13 = cols14.replace("]", "");
			String rows13 = rows14.replace("]", "");
			Number values17;
			String values18;
			//int values = Integer.parseInt(st2);
			
			 String strXML7;
			 String chartId7 = "basicChart";
			 String url7 = "Charts/test.xml";
			 //String jsonUrl = "Data/Data.json";
			 String width7 = "600";
			 String height7 = "300";
			 String folderPath7="Charts/FusionCharts.js";
			 String swfFilename7 = "Charts/Column3D.swf";
			 String uniqueId7 = "";

			 
			 
			
			String[] tempCols7=new String[250];
			String[] tempRows7=new String[250];
			String[] tempValues7=new String[250];
			 strXML7 = "<chart caption='My first chart'>";
			//Element root = doc.createElement(strXML);
			String delimiter7 = ", ";

			tempCols7 = cols13.split(delimiter7);
			
			strXML7 += "<categories>";
			//Element cat = doc.createElement(strXML);
			
			for(int i=0 ; i < tempCols7.length; i++) {
				strXML7 += "<category label = '";// now run
				strXML7 += tempCols7[i];
				//cat.setAttribute("label",strXML);
				//root.appendChild(cat);
				strXML7 += "'/>";
			}
			strXML7 +="</categories>";
			tempRows7 = rows13.split(delimiter7);
			
			for(int j = 0; j < tempRows7.length; j++) {
				
				strXML7 += "<dataset seriesname='";
				//Element dat = doc.createElement(strXML);
				strXML7 += tempRows7[j];
				//dat.setAttribute("seriessname", strXML);
				strXML7 += "'>";
				
				for(int l=0 ; l < tempCols7.length; l++)
				{
								
				// write query here to retrieve values, by passing both the columns and the rows as parameters
				values17 = (dataset.getValue(tempRows7[j], tempCols7[l]));
				String values19=values17.toString();
				//values1 = (dataset.getValue(tempRows[j], tempCols[j])).toString();
				tempValues7 = values19.split(delimiter7);
				for(int k = 0; k < tempValues7.length; k++) {
					strXML7 += "<set value = '";
					//Elemet set = doc.createElement(strXML);
					strXML7 += tempValues7[k];
					//set.setAttribute("value",strXML);
					//root.appendChild(set);
					strXML7 += "'/>";
				}
				
				//root.appendChild(dat);
			}
				strXML7 += "</dataset>";
			}
			
		

			strXML7 += "</chart>";
			
			
				// write the strXML to the console.
				System.out.println(strXML7);
	
				Writer output7 = null;
				File file7 = new File("C:\\Users\\ssss\\Desktop\\Boom\\Charts\\test7.xml");
				 output7 = new BufferedWriter(new FileWriter(file7));
				 output7.write(strXML7);
				 output7.close();
			
			
			System.out.println("EnhancedChartFactory.java returning dataset for case 10"+dataset);
			chart = EnhancedChartFactory.createLineChart(chartTitle, 
					titleFont,
					horizAxisLabel, 
					vertAxisLabel, 
					dataset, 
					PlotOrientation.HORIZONTAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 11:
			dataset = adapter.buildCategoryDataset(olapModel);
			
			
			
//Coding For Fusion Chart Added Here
			
			System.out.println("chart type One "+dataset);
			System.out.println("EnhancedChartFactory.java returning dataset for case 8"+dataset);
			String st16 = dataset.getColumnKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getColumnkeys for case 8 "+st16);
			String st17 = dataset.getRowKeys().toString();
			System.out.println("EnhancedChartFactory.java returning dataset getRowkeys for case 8 "+st17);
				
			//dataset.getValue(st1,st);
			//String st2 = dataset.getValue(st1,st).toString();
			//System.out.println("EnhancedChartFactory.java returning dataset getValues for case 1 "+st2);
			String cols16 = st16.replace("[", "");
			String rows16 = st17.replace("[", "");
			String cols15 = cols16.replace("]", "");
			String rows15 = rows16.replace("]", "");
			Number values20;
			String values21;
			//int values = Integer.parseInt(st2);
			
			 String strXML8;
			 String chartId8 = "basicChart";
			 String url8 = "Charts/test.xml";
			 //String jsonUrl = "Data/Data.json";
			 String width8 = "600";
			 String height8 = "300";
			 String folderPath8="Charts/FusionCharts.js";
			 String swfFilename8 = "Charts/Column3D.swf";
			 String uniqueId8 = "";

			 
			 
			
			String[] tempCols8=new String[250];
			String[] tempRows8=new String[250];
			String[] tempValues8=new String[250];
			 strXML8 = "<chart caption='Numberofconversions' showValue='1'>";
			String delimiter8 = ", ";

			tempCols8 = cols15.split(delimiter8);
			
						
			for(int i=0 ; i < tempCols8.length; i++) {
				strXML8 += "<category label = '";// now run
				strXML8 += tempCols8[i];
				
				strXML8 += "'>";
			//}
			//strXML8 +="</categories>";
			tempRows8 = rows15.split(delimiter8);
			
			for(int j = 0; j < tempRows8.length; j++) {
				
			strXML8 += "<category label='";
			
			strXML8 += tempRows8[j];
			//strXML8 += "'>";
			strXML8 += "'";
				
			//	for(int l=0 ; l < tempCols8.length; l++)
				//{
				
					//strXML8 += "<category label='";
					//Element dat = doc.createElement(strXML);
				//taken by jerald	strXML8 += tempRows8[j];
					//dat.setAttribute("seriessname", strXML);
					//strXML8 += "'>";
					
					
					
					
					
				// write query here to retrieve values, by passing both the columns and the rows as parameters
				values20 = (dataset.getValue(tempRows8[j], tempCols8[i]));
				String values22=values20.toString();
				//values1 = (dataset.getValue(tempRows[j], tempCols[j])).toString();
				tempValues8 = values22.split(delimiter8);
				for(int k = 0; k < tempValues8.length; k++) {
					strXML8 += " value = '";
					
					strXML8 += tempValues8[k];
					
					
					strXML8 += "'/>";
			//	}
				}
				}
			
				strXML8 += "</category>";
			}
			
		

			strXML8 += "</chart>";
			
			

				System.out.println(strXML8);
	
				Writer output8 = null;
				File file8 = new File("C:\\Users\\ssss\\Desktop\\Boom\\Charts1\\test8.xml");
				 output = new BufferedWriter(new FileWriter(file8));
				 output.write(strXML8);
				 output.close();
			
			
			
			
			//System.out.println("EnhancedChartFactory.java returning dataset for case 11"+dataset);
			chart = EnhancedChartFactory.createAreaChart(chartTitle, 
					titleFont,
					horizAxisLabel, 
					vertAxisLabel, 
					dataset,
					PlotOrientation.VERTICAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 12:
			dataset = adapter.buildCategoryDataset(olapModel);
			System.out.println("EnhancedChartFactory.java returning dataset for case 12"+dataset);
			chart = EnhancedChartFactory.createAreaChart(chartTitle, 
					titleFont,
					horizAxisLabel, 
					vertAxisLabel, 
					dataset, 
					PlotOrientation.HORIZONTAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 13:
			dataset = adapter.buildCategoryDataset(olapModel);
			System.out.println("EnhancedChartFactory.java returning dataset for case 13"+dataset);
			chart = EnhancedChartFactory.createStackedAreaChart(chartTitle,
					titleFont, 
					horizAxisLabel, 
					vertAxisLabel, 
					dataset,
					PlotOrientation.VERTICAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

		case 14:
			dataset = adapter.buildCategoryDataset(olapModel);
			System.out.println("EnhancedChartFactory.java returning dataset for case 14"+dataset);
			chart = EnhancedChartFactory.createStackedAreaChart(chartTitle,
					titleFont, 
					horizAxisLabel, 
					vertAxisLabel, 
					dataset,
					PlotOrientation.HORIZONTAL, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					urlGenerator);

			break;

			//pie by column
		case 15:
			dataset = adapter.buildCategoryDataset(olapModel);
			System.out.println("EnhancedChartFactory.java returning dataset for case 15"+dataset);
			chart = EnhancedChartFactory.createPieChart(chartTitle, 
					titleFont,
					dataset, 
					TableOrder.BY_COLUMN, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					new jpivotPieURLGenerator(TableOrder.BY_COLUMN,dataset, webControllerURL, olapModel)
			);

			break;

			//pie by row
		case 16:
			dataset = adapter.buildCategoryDataset(olapModel);
			System.out.println("EnhancedChartFactory.java returning dataset for case 16"+dataset);
			chart = EnhancedChartFactory.createPieChart(chartTitle, 
					titleFont,
					dataset, 
					TableOrder.BY_ROW, 
					showLegend, 
					showTooltips,
					drillThroughEnabled, 
					new jpivotPieURLGenerator(TableOrder.BY_ROW, dataset, webControllerURL, olapModel)
			);

			break;

		case 17:
			dataset = adapter.buildCategoryDataset(olapModel);
			

			
			
			System.out.println("EnhancedChartFactory.java returning dataset for case 17"+dataset);
			chart = EnhancedChartFactory.create3DPieChart(chartTitle,
					titleFont, 
					dataset, 
					TableOrder.BY_COLUMN, 
					showLegend,
					showTooltips, 
					drillThroughEnabled, 
					new jpivotPieURLGenerator(TableOrder.BY_COLUMN, dataset, webControllerURL,olapModel)
			);

			break;

		case 18:
			dataset = adapter.buildCategoryDataset(olapModel);
			System.out.println("EnhancedChartFactory.java returning dataset for case 18"+dataset);
			chart = EnhancedChartFactory.create3DPieChart(chartTitle,
					titleFont, 
					dataset, 
					TableOrder.BY_ROW, 
					showLegend,
					showTooltips, 
					drillThroughEnabled, 
					new jpivotPieURLGenerator(TableOrder.BY_ROW, dataset, webControllerURL, olapModel)
			);

			break;

		case 19:
			chart = EnhancedChartFactory.createTimeChart(chartTitle,
					horizAxisLabel, 
					vertAxisLabel,
					new DatasetAdapter(locale).buildXYDataset(olapModel));
			break;

		default:
			throw new OlapException("An unknown Chart Type was requested: " +
					chartType);
		}

		// chart.setTitle("customized title");
		ChartCustomizer customizer = new ChartCustomizer();
		customizer.customizeChart(chart, bgPaint, axisFont, 
				axisTickFont, legendFont, legendPosition, tickLabelRotate, foregroundAlpha, colorPalette, chartWidth, chartHeight, suppressCrowdedLabels);

		if(showPareto){
			if(chart.getPlot() instanceof CategoryPlot){
				customizer.generatePareto((CategoryPlot)chart.getPlot());
			}
		}

		if(chart.getPlot() instanceof CategoryPlot){
			if(FacesContext.getCurrentInstance() !=null ){
			ProjectContext projCtx = (ProjectContext)FacesUtils.getBean(FacesContext.getCurrentInstance(), "projectContext");
			Locale loc  = projCtx.getUser().getLocale();
			customizer.formatNumberAxis(NumberFormat.getInstance(loc), (CategoryPlot)chart.getPlot());
			}
		}


		logger.debug("showSlicer=" + showSlicer);
		if(showSlicer){customizer.customizeSlicer(
				chart, 
				olapModel,
				slicerFont, 
				slicerPosition, 
				slicerAlignment,
				locale); 
		}        
		return chart;
	}

	public static JFreeChart createTimeChart(String title,
			String horizAxisLabel, String vertAxisLabel, XYDataset dataset) {
		logger.debug("creating time series chart");

		JFreeChart chart = org.jfree.chart.ChartFactory.createTimeSeriesChart(title,
				horizAxisLabel, vertAxisLabel, dataset, true, true, false);

		chart.setBackgroundPaint(Color.white);
		LegendTitle sl = (LegendTitle) chart.getLegend();

		XYPlot plot = chart.getXYPlot();
		plot.setBackgroundPaint(Color.lightGray);
		plot.setDomainGridlinePaint(Color.white);
		plot.setRangeGridlinePaint(Color.white);
		//plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
		plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
		plot.setDomainCrosshairVisible(false);
		plot.setRangeCrosshairVisible(false);

		XYItemRenderer renderer = plot.getRenderer();

		if (renderer instanceof StandardXYItemRenderer) {
			StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
			//rr.setPlotShapes(true);
			rr.setPlotImages(true);
			rr.setShapesFilled(true);
			rr.setItemLabelsVisible(true);
		}

		DateAxis axis = (DateAxis) plot.getDomainAxis();
		axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

		return chart;
	}

	public static JFreeChart createLineChart(String title,
			java.awt.Font titleFont, String categoryAxisLabel,
			String valueAxisLabel, CategoryDataset data,
			PlotOrientation orientation, boolean legend, boolean tooltips,
			boolean urls, CategoryURLGenerator urlGenerator) {
		CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
		ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

		LineAndShapeRenderer renderer = new LineAndShapeRenderer();

		// renderer.setLinesVisible(true);
		// renderer.setShapesVisible(false);
		if (tooltips) {
			if(FacesContext.getCurrentInstance()==null){
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
			}
			else{
				ProjectContext prjCtx = (ProjectContext)FacesUtils.getBean(FacesContext.getCurrentInstance(), "projectContext");
				Locale locale = prjCtx.getUser().getLocale();
				NumberFormat nf = NumberFormat.getInstance(locale);
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator("{0},{1}={2}",nf));
			}
		}

		if (urls) {
			renderer.setItemURLGenerator(urlGenerator);
		}

		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);

		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;
	}

	/*public static MaaniChart createBarChart(String title,
			java.awt.Font titleFont,
			String categoryAxisLabel,
			String valueAxisLabel,
			MaaniCategoryDataset data,
			PlotOrientation orientation,
			boolean legend,
			boolean tooltips,
			boolean urls,
			CategoryURLGenerator urlGenerator) {
		MaaniChart chart = new MaaniChart(title, titleFont, categoryAxisLabel, valueAxisLabel, data, orientation, legend, tooltips, urls, urlGenerator);
		
		return chart;

	}*/
	
	//Code added for fusion Chart integration
	/*
	public static JFreeChart createFusion(String strXML,
			String chartId,
			String url,
			String width,
			String height, 
			String folderPath,
			String swfFilename, 
			String uniqueId,
			java.awt.Font titleFont) {
		CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
		ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
		BarRenderer renderer = new BarRenderer();

		if (tooltips) {
			if(FacesContext.getCurrentInstance()==null){
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
			}
			else{
				ProjectContext prjCtx = (ProjectContext)FacesUtils.getBean(FacesContext.getCurrentInstance(), "projectContext");
				Locale locale = prjCtx.getUser().getLocale();
				NumberFormat nf = NumberFormat.getInstance(locale);
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator("{0},{1}={2}",nf));
			}
		}
		if (urls) {
			renderer.setItemURLGenerator(urlGenerator);
		}
		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);
		JFreeChart chart = new JFreeChart(chartId, titleFont, plot, legend);

		return chart;

	}
//Upto this Code
	
	*/
	
	
	public static JFreeChart createBarChart(String title,
			java.awt.Font titleFont,
			String categoryAxisLabel,
			String valueAxisLabel,
			CategoryDataset data,
			PlotOrientation orientation,
			boolean legend,
			boolean tooltips,
			boolean urls,
			CategoryURLGenerator urlGenerator) {
		CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
		ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
		BarRenderer renderer = new BarRenderer();

		if (tooltips) {
			if(FacesContext.getCurrentInstance()==null){
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
			}
			else{
				ProjectContext prjCtx = (ProjectContext)FacesUtils.getBean(FacesContext.getCurrentInstance(), "projectContext");
				Locale locale = prjCtx.getUser().getLocale();
				NumberFormat nf = NumberFormat.getInstance(locale);
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator("{0},{1}={2}",nf));
			}
		}
		if (urls) {
			renderer.setItemURLGenerator(urlGenerator);
		}
		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);
		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;

	}
	public static JFreeChart createStackedBarChart(String title,
			java.awt.Font titleFont,
			String domainAxisLabel,
			String rangeAxisLabel,
			CategoryDataset data,
			PlotOrientation orientation,
			boolean legend,
			boolean tooltips,
			boolean urls,
			CategoryURLGenerator urlGenerator) {

		CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
		ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);

		// create the renderer...
		StackedBarRenderer renderer = new StackedBarRenderer();
		if (tooltips) {
			if(FacesContext.getCurrentInstance()==null){
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
			}
			else{
				ProjectContext prjCtx = (ProjectContext)FacesUtils.getBean(FacesContext.getCurrentInstance(), "projectContext");
				Locale locale = prjCtx.getUser().getLocale();
				NumberFormat nf = NumberFormat.getInstance(locale);
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator("{0},{1}={2}",nf));
			}
		}
		if (urls) {
			renderer.setItemURLGenerator(urlGenerator);
		}

		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);
		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;

	} 

	public static JFreeChart createAreaChart(String title,
			java.awt.Font titleFont,
			String categoryAxisLabel,
			String valueAxisLabel,
			CategoryDataset data,
			PlotOrientation orientation,
			boolean legend,
			boolean tooltips,
			boolean urls,
			CategoryURLGenerator urlGenerator) {

		CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
		categoryAxis.setCategoryMargin(0.0);
		ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
		AreaRenderer renderer = new AreaRenderer();
		if (tooltips) {
			if(FacesContext.getCurrentInstance()==null){
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
			}
			else{
				ProjectContext prjCtx = (ProjectContext)FacesUtils.getBean(FacesContext.getCurrentInstance(), "projectContext");
				Locale locale = prjCtx.getUser().getLocale();
				NumberFormat nf = NumberFormat.getInstance(locale);
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator("{0},{1}={2}",nf));
			}
		}
		if (urls) {
			renderer.setItemURLGenerator(urlGenerator);
		}
		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);
		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;

	}

	/**
	 * Creates a chart containing multiple pie charts, from a TableDataset.
	 *
	 * @param title  the chart title.
	 * @param data  the dataset for the chart.
	 * @param extractType  <code>PER_ROW</code> or <code>PER_COLUMN</code> (defined in 
	 *                     {@link PiePlot}).
	 * @param legend  a flag specifying whether or not a legend is required.
	 * @param tooltips  configure chart to generate tool tips?
	 * @param urls  configure chart to generate URLs?
	 *
	 * @return a pie chart.
	 */
	public static JFreeChart createPieChart(String title, 
			java.awt.Font titleFont,
			CategoryDataset data,
			TableOrder order,
			boolean legend, 
			boolean tooltips, 
			boolean urls,
			PieURLGenerator urlGenerator) {

		MultiplePiePlot plot = new MultiplePiePlot(data);         
		plot.setDataExtractOrder(order);

		PiePlot pp= (PiePlot) plot.getPieChart().getPlot();		
		//pp.setInsets(new Insets(0, 5, 5, 5));
		pp.setBackgroundPaint(null);
		// no outline around each piechart
		pp.setOutlineStroke(null);
		//plot.setOutlineStroke(null);
		PieToolTipGenerator tooltipGenerator = null;
		if (tooltips) {
			if(FacesContext.getCurrentInstance()==null){
				tooltipGenerator=new StandardPieToolTipGenerator();
			}
			else{
				ProjectContext prjCtx = (ProjectContext)FacesUtils.getBean(FacesContext.getCurrentInstance(), "projectContext");
				Locale locale = prjCtx.getUser().getLocale();
				NumberFormat nf = NumberFormat.getInstance(locale);
				tooltipGenerator=new StandardPieToolTipGenerator("{0}=({1};{2})",nf,nf);
			}
		}

		//PieURLGenerator urlGenerator = null;
		if (!urls) {
			urlGenerator = null;
		}

		pp.setToolTipGenerator(tooltipGenerator);
		pp.setLabelGenerator(null);
		pp.setURLGenerator(urlGenerator);

		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;

	}    

	public static JFreeChart create3DPieChart(String title,
			java.awt.Font titleFont, CategoryDataset data, TableOrder order,
			boolean legend, boolean tooltips, boolean urls,
			PieURLGenerator urlGenerator) {
		MultiplePiePlot plot = new MultiplePiePlot(data);
		plot.setDataExtractOrder(order);

		//plot.setOutlineStroke(null);
		JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
		pieChart.setBackgroundPaint(null);
		plot.setPieChart(pieChart);

		PiePlot3D pp = (PiePlot3D) plot.getPieChart().getPlot();
		pp.setBackgroundPaint(null);
		//pp.setInsets(new Insets(0, 5, 5, 5));

		// no outline around each piechart
		pp.setOutlineStroke(null);

		PieToolTipGenerator tooltipGenerator = null;

		if (tooltips) {
			// tooltipGenerator = new StandardPieToolTipGenerator();
		}

		if (!urls) {
			urlGenerator = null;
		}

		pp.setToolTipGenerator(tooltipGenerator);
		pp.setLabelGenerator(null);
		pp.setURLGenerator(urlGenerator);

		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;
	}
	
	/**
	 * Creates a stacked area chart with default settings.
	 *
	 * @param title  the chart title.
	 * @param categoryAxisLabel  the label for the category axis.
	 * @param valueAxisLabel  the label for the value axis.
	 * @param data  the dataset for the chart.
	 * @param legend  a flag specifying whether or not a legend is required.
	 * @param tooltips  configure chart to generate tool tips?
	 * @param urls  configure chart to generate URLs?
	 *
	 * @return an area chart.
	 */


	public static JFreeChart createStackedAreaChart(String title,
													java.awt.Font titleFont,
													String categoryAxisLabel,
													String valueAxisLabel,
													CategoryDataset data,
													PlotOrientation orientation,
													boolean legend,
													boolean tooltips,
													boolean urls,
	CategoryURLGenerator urlGenerator) {

		CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
		ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

		StackedAreaRenderer renderer = new StackedAreaRenderer();
		if (tooltips) {
			if(FacesContext.getCurrentInstance()==null){
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
			}
			else{
				ProjectContext prjCtx = (ProjectContext)FacesUtils.getBean(FacesContext.getCurrentInstance(), "projectContext");
				Locale locale = prjCtx.getUser().getLocale();
				NumberFormat nf = NumberFormat.getInstance(locale);
				renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator("{0},{1}={2}",nf));
			}
		}
		if (urls) {
			renderer.setItemURLGenerator(urlGenerator);
		}

		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);
		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;

	}


	/**
	 * A URLGenerator class to generate pie urls that work with jpivot
	 * @author ati
	 *
	 */
	public static class jpivotPieURLGenerator extends StandardPieURLGenerator {

		/** Prefix to the URL */
		private String prefix = "";			
		private List cells = null;			
		private int rowCount;	        
		OlapModel olapModel = null;	
		private TableOrder order;  // COLUMN or ROW  - used to calculate cell Position

		jpivotPieURLGenerator() {
		}

		jpivotPieURLGenerator(String prefix) {
			this.prefix = prefix;
		}

		/*
		 * Use this constructor to set dataExtraction type (PER_COLUMN/PER_ROW), and allow for
		 * rowcount of current dataset  (could be changed to just take rowCount)
		 */
		jpivotPieURLGenerator(TableOrder order, DefaultCategoryDataset dataset){
			this.order= order;
			this.rowCount=dataset.getRowCount();
		}

		/*
		 * As above with web controller URL
		 */
		jpivotPieURLGenerator(TableOrder order, DefaultCategoryDataset dataset, String controllerURL, OlapModel olapModel){
			this(order, dataset);
			this.prefix = controllerURL;

			try {
				this.olapModel = olapModel ;
				this.cells = olapModel.getResult().getCells();
			} catch (OlapException e) {
				e.printStackTrace();
			}

		}

		/**
		 * Implementation of generateURL that integrates with jpivot/wcf framework.
		 * A request handler is added for each cell/item.
		 * No test is done to see if a cell is drillable, since the url has to added (I think, like an all or nothing ?)
		 * Generates a URL for a particular item within a series.
		 *
		 * @param data  the dataset.
		 * @param key  the data item key.
		 * @param pieIndex the index of the pie containing key (zero-based).
		 *
		 * @return the generated URL
		 */

		public String generateURL(PieDataset data, Comparable key, int pieIndex) {
			String url = prefix;
			int index = data.getIndex(key);
			int cellpos;
			if (order == TableOrder.BY_COLUMN){
				cellpos = (pieIndex*rowCount)+index;
			} else {
				cellpos = pieIndex+(rowCount*index);
			}

			if ( EnhancedChartFactory.canDrillThrough((Cell) cells.get(cellpos), olapModel ) && (!((Cell) cells.get(cellpos)).isNull())) {
				String id = DomUtils.randomId();
				dispatcher.addRequestListener(
						id,
						null,
						new CustomDrillthroughUI.DrillThroughHandler((Cell) cells.get(cellpos), olapModel));

				url += id;
				return url;
			}
			else {
				return null;
			}
		}
	}

	protected static boolean canDrillThrough(Cell cell, OlapModel olapModel) {
		return ((DrillThrough) olapModel.getExtension(DrillThrough.ID)).canDrillThrough((Cell) cell.getRootDecoree());
	}

}