// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   ConnectedSeries.java

package lt.monarch.chart.chart2D;

import java.awt.*;
import lt.monarch.chart.*;

// Referenced classes of package lt.monarch.chart.chart2D:
//			DotSeries, ChartPoint, ChartPointProvider, ChartPointSeries, 
//			NormalizedPoint2D, Axis2D

public class ConnectedSeries extends DotSeries
{

	protected Color lineColor;
	protected Color fillColor;
	protected Stroke lineStroke;

	public ConnectedSeries(ChartPointProvider chartpointprovider, PlainMapper plainmapper, AxisMapper axismapper, AxisMapper axismapper1)
	{
		super(chartpointprovider, plainmapper, axismapper, axismapper1);
		lineColor = Color.red;
		fillColor = null;
	}

	public ConnectedSeries(ChartPointProvider chartpointprovider, Axis2D axis2d, Axis2D axis2d1)
	{
		super(chartpointprovider, axis2d, axis2d1);
		lineColor = Color.red;
		fillColor = null;
	}

	public void draw(Graphics g)
	{
		Polygon polygon = new Polygon();
		double d = 0.0D;
		double d1 = 0.0D;
		int i = super.provider.pointCount();
		for(int j = 0; j < i; j++)
		{
			NormalizedPoint2D normalizedpoint2d = super.provider.point(j).getCenter(g, this);
			Point point = chart().projector().project(normalizedpoint2d);
			polygon.addPoint(point.x, point.y);
			d1 = normalizedpoint2d.x;
			if(j == 0)
				d = d1;
		}

		if(i != 0 && fillColor != null)
		{
			Polygon polygon1 = new Polygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
			Point point1 = chart().projector().project(super.mapper.map(d1, 0.0D));
			polygon1.addPoint(point1.x, point1.y);
			Point point2 = chart().projector().project(super.mapper.map(d, 0.0D));
			polygon1.addPoint(point2.x, point2.y);
			g.setColor(fillColor);
			g.fillPolygon(polygon1);
		}
		Stroke stroke = null;
		if(lineStroke != null)
		{
			stroke = ((Graphics2D)g).getStroke();
			((Graphics2D)g).setStroke(lineStroke);
		}
		g.setColor(lineColor);
		g.drawPolyline(polygon.xpoints, polygon.ypoints, polygon.npoints);
		if(stroke != null)
			((Graphics2D)g).setStroke(stroke);
		drawPoints(g);
	}

	public void pointAdded(ChartPointProvider chartpointprovider, ChartPoint chartpoint)
	{
		chart().invalidate();
	}

	public void setColor(Color color)
	{
		lineColor = color;
	}

	public void setFillColor(Color color)
	{
		fillColor = color;
	}

	public void setStroke(Stroke stroke)
	{
		lineStroke = stroke;
	}
}
