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.FlowLayout;
009 import java.awt.Graphics;
010
011 import simuLCS.Classifier;
012 import simuLCS.ClassifierComponent;
013 import simuLCS.Template;
014
015
016 /**
017 * The Panel gathering all the GUI components to change the Condition part
018 * of the selected Classifier (in the tab "behaviour")
019 * @author Benoit
020 *
021 */
022 public class G_TemplatePanConditions extends G_Panel {
023
024 private static G_TemplatePanConditions instance = null;
025 protected ClassifierComponent[] conditions ;
026 protected Template associatedTemplate ;
027
028 protected G_TemplatePanConditions(Template t, ClassifierComponent[] conds)
029 {
030 super();
031 conditions = conds;
032 associatedTemplate = t;
033 // setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
034
035 setLayout(new FlowLayout());
036
037 int currentPos = 0;
038 for(int i=0;i<conditions.length;i++)
039 {
040 G_Panel g = t.getCondition(i).getUIWithListener(currentPos,
041 Classifier.PART_CONDITION,false);
042 currentPos = currentPos + t.getCondition(i).getNbBits();
043 add(g);
044 }
045
046 this.validate();
047 }
048
049 public static G_TemplatePanConditions getInstance(Template t)
050 {
051 if(instance == null)
052 {
053 instance = new G_TemplatePanConditions(t,t.getConditions());
054 }
055 return instance ;
056 }
057
058 public void updateValues()
059 {
060 for(int i=0;i<conditions.length;i++)
061 {
062 associatedTemplate.getCondition(i).getPointerUI().updateValues();
063 }
064 }
065
066 public void paintComponents(Graphics g)
067 {
068 updateValues();
069 this.validate();
070 }
071 }