package com.imsl.demo.jsp;
import com.imsl.chart.*;
import java.awt.Color;

public class ImagemapBean extends JspBean {
    private JspBean bean;
    private int     explode;
    
    public ImagemapBean() {
        bean = new JspBean();
        bean.setSize(300,300);
        bean.setCreateImageMap(true);
    }
        
    public void createChart(javax.servlet.http.HttpServletRequest request) {
        Chart chart = new Chart();
        
        double y[] = {35., 20., 30., 40.};
        Pie pie = new Pie(chart, y);
        pie.setLabelType(Pie.LABEL_TYPE_TITLE);
        pie.setFillOutlineColor(Color.blue);

        PieSlice slice[] = pie.getPieSlice();

        slice[0].setFillColor(Color.red);
        slice[0].setTitle("Red");
        
        slice[1].setFillColor(Color.blue);
        slice[1].setTitle("Blue");
        slice[1].setFillOutlineColor(Color.yellow);
        
        slice[2].setFillColor(Color.black);
        slice[2].setTitle("Black");
        
        slice[3].setFillColor(Color.yellow);
        slice[3].setTitle("Yellow");
        
        for (int k = 0;  k < slice.length;  k++) {
            slice[k].setHREF("imagemap.jsp?explode="+k);
        }
        
        try {
            slice[explode].setExplode(0.3);
        } catch (Exception e) {
            // ignore out of range values for explode
        }
        
        bean.registerChart(chart, request);
    }
    
    
    
    public void setExplode(int explode) {
        this.explode = explode;
    }
    
    public String getImageTag() {
        return bean.getImageTag();
    }
    
    public String getImageMap() {
        return bean.getImageMap();
    }
}