/*	LineChartEngine.java

	Purpose:
		
	Description:
		
	History:
		Oct 18, 2010 2:27:40 PM     2010, Created by henrichen

	Copyright (C) 2010 Potix Corporation. All Rights Reserved.
*/


package org.zkoss.zssex.util;

import java.awt.BasicStroke;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.zkoss.zss.model.SChart;
import org.zkoss.zul.CategoryModel;
import org.zkoss.zul.Chart;

/**
 * A LineChartEngine customized to draw Line Chart for matching Excel line chart style
 * 
 * @author henrichen@zkoss.org
 * @author dennis , refine to new chart model
 */
public class LineChartEngine extends ZssChartEngine {
	private static final long serialVersionUID = 201011011508L;
	private static final BasicStroke STROKE = new BasicStroke(new Integer(2));
	public LineChartEngine(SChart chartInfo) {
		super(chartInfo);
	}
	public boolean prepareJFreeChart(JFreeChart jfchart, Chart chart) {
		super.prepareJFreeChart(jfchart, chart);
		final LineAndShapeRenderer renderer = (LineAndShapeRenderer) ((CategoryPlot) jfchart.getPlot()).getRenderer();
		final int count = ((CategoryModel)chart.getModel()).getSeries().size();
		for(int j = 0; j < count; ++j) {
			renderer.setSeriesStroke(j, STROKE);
			renderer.setSeriesShapesVisible(j, true);
		}
		return false;
	}
}