001 /*
002 * SimuCS - Simulator to use with Classifier Systems
003 * MSc project - Oxford University
004 * by Benoit Isaac - Summer 2005
005 */
006
007 package simuLCS.graphics;
008 import java.awt.Graphics;
009
010 import javax.swing.BoxLayout;
011
012 import simuLCS.Classifier;
013 import simuLCS.ClassifierComponent;
014 import simuLCS.Template;
015
016
017 /**
018 * The Panel gathering all the GUI components to change the Action part
019 * of the selected Classifier (in the tab "behaviour")
020 * @author Benoit
021 *
022 */
023 public class G_TemplatePanActions extends G_Panel {
024
025 private static G_TemplatePanActions instance = null;
026 protected ClassifierComponent[] actions ;
027 protected Template associatedTemplate ;
028
029 protected G_TemplatePanActions(Template t, ClassifierComponent[] acts)
030 {
031 super();
032 actions = acts;
033 associatedTemplate = t;
034 setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
035
036 // setLayout(new FlowLayout());
037
038 int currentPos = 0;
039 for(int i=0;i<actions.length;i++)
040 {
041 G_Panel g = t.getAction(i).getUIWithListener(currentPos,
042 Classifier.PART_ACTION,false);
043 currentPos = currentPos + t.getAction(i).getNbBits();
044 add(g);
045 }
046
047 this.validate();
048 }
049
050 public static G_TemplatePanActions getInstance(Template t)
051 {
052 if(instance == null)
053 {
054 instance = new G_TemplatePanActions(t,t.getActions());
055 }
056 return instance ;
057 }
058
059 public void updateValues()
060 {
061 for(int i=0;i<actions.length;i++)
062 {
063 associatedTemplate.getAction(i).getPointerUI().updateValues();
064 }
065 }
066
067 public void paintComponents(Graphics g)
068 {
069 updateValues();
070 this.validate();
071 }
072 }