Math2mat
|
00001 00015 package m2m.frontend.dynamicview.figure; 00016 00017 import m2m.backend.buildingblocks.BuildingBlock.NumType; 00018 import m2m.frontend.dynamicview.model.*; 00019 00020 import org.eclipse.draw2d.ActionEvent; 00021 00022 import org.eclipse.draw2d.ActionListener; 00023 import org.eclipse.draw2d.CheckBox; 00024 import org.eclipse.draw2d.ColorConstants; 00025 import org.eclipse.draw2d.Figure; 00026 import org.eclipse.draw2d.Label; 00027 import org.eclipse.draw2d.ToolbarLayout; 00028 import org.eclipse.draw2d.XYLayout; 00029 import org.eclipse.draw2d.geometry.Rectangle; 00030 00031 00032 public class SchemaPropertyFigure extends Figure implements ActionListener 00033 { 00037 private Schema schema; 00041 private XYLayout layout; 00045 private Label labelName = new Label(); 00049 private CheckBox checkBox32Bits = new CheckBox("FLOAT32 architecture"); 00053 private CheckBox checkBox64Bits = new CheckBox("FLOAT64 architecture"); 00057 private CheckBox checkBoxFifoComp = new CheckBox("Add fifo compensation"); 00058 00062 public SchemaPropertyFigure(Schema schema) 00063 { 00064 this.schema = schema; 00065 00066 /* Set the type of layout */ 00067 layout = new XYLayout(); 00068 setLayoutManager(layout); 00069 00070 /* Initialisation of the labelName */ 00071 labelName.setForegroundColor(ColorConstants.black); 00072 add(labelName, ToolbarLayout.VERTICAL); 00073 setConstraint(labelName, new Rectangle(0, 0, -1, -1)); 00074 labelName.setText("Unknown"); 00075 00076 /* Initialisation of the checkBox32Bits */ 00077 add(checkBox32Bits); 00078 setConstraint(checkBox32Bits, new Rectangle(0, 30, -1, -1)); 00079 checkBox32Bits.addActionListener(this); 00080 00081 /* Initialisation of the checkBox64Bits */ 00082 add(checkBox64Bits); 00083 setConstraint(checkBox64Bits, new Rectangle(0, 45, -1, -1)); 00084 checkBox64Bits.addActionListener(this); 00085 00086 /* Initialisation of the checkBox64Bits */ 00087 add(checkBoxFifoComp); 00088 setConstraint(checkBoxFifoComp, new Rectangle(0, 75, -1, -1)); 00089 checkBoxFifoComp.addActionListener(this); 00090 00091 /* Initialisation of the figure */ 00092 setOpaque(true); 00093 setBackgroundColor(ColorConstants.menuBackground); 00094 setForegroundColor(ColorConstants.menuForeground); 00095 } 00096 00097 00101 public void setProperty() 00102 { 00103 // Get and show the name of the GraphicIf 00104 labelName.setText("Name : " + schema.getName()); 00105 00106 /* Initialize the state of checkBoxes */ 00107 checkBox32Bits.setSelected(schema.getDataType() == NumType.FLOAT32); 00108 checkBox64Bits.setSelected(schema.getDataType() == NumType.FLOAT64); 00109 checkBoxFifoComp.setSelected(schema.getFifoComp()); 00110 } 00111 00112 00117 @Override 00118 public void actionPerformed(ActionEvent arg) 00119 { 00120 /* Update architecture type */ 00121 if(arg.getSource() == checkBox32Bits) 00122 schema.setDataType(NumType.FLOAT32); 00123 else if (arg.getSource() == checkBox64Bits) 00124 schema.setDataType(NumType.FLOAT64); 00125 checkBox32Bits.setSelected(schema.getDataType() == NumType.FLOAT32); 00126 checkBox64Bits.setSelected(schema.getDataType() == NumType.FLOAT64); 00127 00128 /* Update compensation fifo */ 00129 if(arg.getSource() == checkBoxFifoComp) 00130 schema.setFifoComp(checkBoxFifoComp.isSelected()); 00131 00132 } 00133 } 00134