//***************************************************************************** // ColorRadioButtonPanel.java // // 15/3/00 // Geetika Tewari, Christie Rice & Victoria Manfredi // // //***************************************************************************** import java.awt.*; import java.awt.event.*; import java.lang.*; import java.io.*; import java.applet.*; import java.util.*; public class ColorRadioButtonPanel extends Panel implements ItemListener { ColorFrame cf; // Parent int width, height; // dimensions of panel CheckboxGroup colortype; // the radio buttons Checkbox rcb[]; ColorRadioCanvasPanel rcp[]; ColorRadioCanvas rcc[]; int i; //******************************** // // constructor // //******************************** public ColorRadioButtonPanel(ColorFrame cff) { super(); cf = cff; i = 0; colortype = new CheckboxGroup(); rcb = new Checkbox[Constants.NUM_RADIO_BUT]; rcb[0] = new Checkbox(" POINT FILL ", colortype, true); rcb[1] = new Checkbox(" POINT CONTOUR ", colortype, false); rcb[2] = new Checkbox(" BACKGROUND ", colortype, false); rcb[3] = new Checkbox(" GRID COLOR ", colortype, false); rcb[4] = new Checkbox(" AXIS ", colortype, false); rcb[5] = new Checkbox(" PARABOLA ", colortype, false); rcp = new ColorRadioCanvasPanel[Constants.NUM_RADIO_BUT]; rcc = new ColorRadioCanvas[Constants.NUM_RADIO_BUT]; // Initializing and constructing... for (i = 0; i < Constants.NUM_RADIO_BUT; i++) { rcb[i].addItemListener(this); rcc[i] = new ColorRadioCanvas(cf, cf.RBColor[i], i); rcp[i] = new ColorRadioCanvasPanel(cf, rcb[i], rcc[i]); } height = cf.getSize().height; width = cf.getSize().width/2; setSize(width,height); setBackground(Color.white); setLayout(new GridLayout (6,1,5,5)); // rows, columns, horizontal // spacing, vertical spacing // Add RadioCanvasPanel panels to RadioButtonPanel panels // on ColorFrame frame for (i = 0; i < Constants.NUM_RADIO_BUT; i++) { add(rcp[i]); }// end for }// end constructor //***************************** // // itemStateChanged // //***************************** public void itemStateChanged(ItemEvent e) { int i = 0; for (i = 0; i < Constants.NUM_RADIO_BUT; i++) { if (e.getSource() == rcb[i]) { // get the rgb values cf.r = cf.RBColor[i].getRed(); cf.g = cf.RBColor[i].getGreen(); cf.b = cf.RBColor[i].getBlue(); // make current color the same color as the radio button's color cf.curc = new Color(cf.r, cf.g, cf.b); cf.CurRButton = i; cf.cp.cbp.cc.repaint(); // making sure that ColorCanvas is // changed so that those classes // observing ColorCanvas are notified break; }// end if }// end for }// end itemStateChanged }//end class ColorRadioButtonPanel