// created: 3.1.01
// modified:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class CountChoiceFunctionChanger extends FunctionChanger
 {

 CountFunctionChanger funcChanger;
 JRadioButton anyButton;
 JRadioButton otherButton; 
 JRadioButton imageButton;
 JRadioButton soundButton;
 JRadioButton videoButton;

 CountChoiceFunctionChanger()
  {  
  super();
  setPreferredSize(new Dimension(310,40));
  funcChanger = new CountFunctionChanger();
  // set up the components
  anyButton = new JRadioButton("any");
  anyButton.setSelected(true);
  otherButton = new JRadioButton("other");
  imageButton = new JRadioButton("image");
  soundButton = new JRadioButton("sound");
  videoButton = new JRadioButton("video");

  ButtonGroup group = new ButtonGroup();
  group.add(anyButton);
  group.add(otherButton);
  group.add(imageButton);
  group.add(soundButton);
  group.add(videoButton);

  JPanel panel = new JPanel();
  panel.add(anyButton);
  panel.add(imageButton);
  panel.add(soundButton);
  panel.add(videoButton);
  panel.add(otherButton);

  //setLayout(new GridLayout(2,1));
  setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
  add(funcChanger);
  add(panel);

  } 
 
 public void setEnabled(boolean bool)
  {
  super.setEnabled(bool);
  funcChanger.setEnabled(bool);
  anyButton.setEnabled(bool);
  otherButton.setEnabled(bool);
  imageButton.setEnabled(bool);
  soundButton.setEnabled(bool);
  videoButton.setEnabled(bool);
  }

 /**********************/
 /* method getFunction */
 /**********************/

 ValueFunction getFunction()
  { 
  if (otherButton.isSelected())
    return new CountChoiceValueFunction("other",(CountValueFunction) funcChanger.getFunction());
  else if (imageButton.isSelected())
    return new CountChoiceValueFunction("image",(CountValueFunction) funcChanger.getFunction());
  else if (soundButton.isSelected())
    return new CountChoiceValueFunction("sound",(CountValueFunction) funcChanger.getFunction());
  else if (videoButton.isSelected())
    return new CountChoiceValueFunction("video",(CountValueFunction) funcChanger.getFunction());
  else // if (anyButton.isSelected())
    return new CountChoiceValueFunction((CountValueFunction) funcChanger.getFunction());
  }

 }