/*
 * @(#) PieChartCustomizer.java 1.0 97/7/18 
 * Copyright (c) 1997 Lawrence Rodrigues
 */
package vis.beans.plotter;
import java.io.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
//import vis.util.*;
import vis.beans.customizers.*;
import java.lang.reflect.*;
import javax.swing.*;
import javax.swing.border.*;
 /** PieChartCustomizer Class
   * @version 1.0  18 July 1997
   * @author Lawrence Rodrigues
   **/
  public class PieChartCustomizer extends CustomizerImpl{
     public PieChart target;
     public PieChartCustomizer(){
        setTitle("Pie Chart Customizer");
     }

     protected void createGUI(){
        if(bean == null) return;
        target = (PieChart)bean;
        JPanel pan = new JPanel();
        JPanel colorspan = createColorsPanel();
        JPanel JLabelspan = createLabelsPanel();
        JPanel incrpan = new JPanel();
        JPanel diapan = CustomizerUtil.createIncrPanel(target,pcs, "PieDiaIncr", "Diameter");
        JPanel centpan = CustomizerUtil.createXYIncrPanel(target,pcs,"PieCenterXIncr", "PieCenterYIncr","Center");
        incrpan.add(diapan);
        incrpan.add(centpan);
        incrpan.setBorder(BorderFactory.createTitledBorder("Pie"));

        JPanel legpan = new JPanel();
        JPanel legpospan = CustomizerUtil.createXYIncrPanel(target,pcs, "LegendPosXIncr","LegendPosYIncr","Position");
        JPanel leggappan = CustomizerUtil.createIncrPanel(target, pcs, "LegendGapIncr", "Gap");
        legpan.add(leggappan);
        legpan.add(legpospan);
     
        legpan.setBorder(BorderFactory.createTitledBorder("Legend"));

        GridBagLayout   gb = new GridBagLayout() ;
        GridBagConstraints c = new GridBagConstraints();
        pan.setLayout(gb);
        setBackground(Color.lightGray);
        setForeground(Color.black);
        c.insets = new Insets(10,10,0,0);
        c.weighty = 0.0; c.weightx = 1.0;
        c.gridwidth = 1;
        c.gridheight =1;
        c.fill = GridBagConstraints.BOTH;

        gb.setConstraints(colorspan,c);
        pan.add(colorspan,c);
        c.gridheight =1;
        c.gridwidth = GridBagConstraints.REMAINDER;
        gb.setConstraints(JLabelspan,c);
        pan.add(JLabelspan);
        gb.setConstraints(incrpan,c);
        pan.add(incrpan);
        c.gridwidth = GridBagConstraints.REMAINDER;
        gb.setConstraints(legpan,c);
        pan.add(legpan);
        pan.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),"Pie Chart Customizer"));
        add(pan);
        setSize(400,300);
     }

     /**
       *  Creates a JPanel for the colors.
       */
     public JPanel createColorsPanel(){
        JLabel bklab = new JLabel("Background");
        JComboBox bk = CustomizerUtil.createColorComboBox(target, pcs,"Background");
        JLabel fglab = new JLabel("Foreground");
        JComboBox fg = CustomizerUtil.createColorComboBox(target,pcs,"Foreground");
        Component comp[] = {bklab,bk,fglab,fg};
        JPanel pan = CustomizerUtil.doGridbagLayout(comp, 2);
        pan.setBorder(BorderFactory.createTitledBorder("Colors"));
        return pan;
     }

     /**
       * Creates a JPanel for the lables. 
       */
     public JPanel createLabelsPanel(){
        JLabel tlab = new JLabel("Title");
        JTextField tl = CustomizerUtil.createJTextField(target,pcs,"TitleString", String.class);
        Component comp[] = {tlab,tl};
        JPanel pan = CustomizerUtil.doGridbagLayout(comp,2);
        pan.setBorder(BorderFactory.createTitledBorder("Labels"));
        return pan;
     }
  }
