JSci.awt.PieChart Maven / Gradle / Ivy
package JSci.awt;
import java.awt.*;
/**
* A pie chart AWT component.
* @version 1.2
* @author Mark Hale
*/
public class PieChart extends CategoryGraph2D {
/**
* Total value of pie.
*/
private float pieTotal;
/**
* Slice colors.
*/
protected Color sliceColor[]={Color.blue,Color.green,Color.red,Color.yellow,Color.cyan,Color.lightGray,Color.magenta,Color.orange,Color.pink};
/**
* Constructs a pie chart.
*/
public PieChart(CategoryGraph2DModel cgm) {
super(cgm);
dataChanged(new GraphDataEvent(model));
}
/**
* Implementation of GraphDataListener.
* Application code will not use this method explicitly, it is used internally.
*/
public void dataChanged(GraphDataEvent e) {
model.firstSeries();
final int len=model.seriesLength();
pieTotal=0.0f;
for(int i=0;isliceColor.length) {
Color tmp[]=sliceColor;
sliceColor=new Color[len];
System.arraycopy(tmp,0,sliceColor,0,tmp.length);
for(int i=tmp.length;i 0) {
for(int i=0; i