Math2mat
|
00001 00015 package m2m.frontend.dynamicview.model; 00016 00017 import java.util.Vector; 00018 00019 import m2m.backend.structure.Operation; 00020 import m2m.backend.structure.StructTreatment; 00021 import m2m.frontend.dynamicview.figure.InternPointConnectionFigure; 00022 import m2m.frontend.dynamicview.figure.LoopIteratorFigure; 00023 import m2m.frontend.view.Editor; 00024 00025 import org.eclipse.draw2d.geometry.Rectangle; 00026 import org.eclipse.ui.PlatformUI; 00027 00028 public class GraphicLoopIterator extends Node 00029 { 00033 private boolean selectAll; 00037 private String startInitialisation; 00041 private String incrementation; 00045 private String endCondition; 00049 private InternPointConnection outPoint = new InternPointConnection(); 00053 private PointConnection outputPointConnection = null; 00057 private Vector<Node> conditionNodes = new Vector<Node>(); 00058 private Operation iterOperation; 00059 00063 public GraphicLoopIterator () 00064 { 00065 super(); 00066 00067 startInitialisation = "Unknown"; 00068 incrementation = "Unknown"; 00069 endCondition = "Unknown"; 00070 00071 /* Initialisation of the out intern connection point */ 00072 outPoint.setName("out"); 00073 outPoint.setParent(this); 00074 outPoint.setLayout(new Rectangle (LoopIteratorFigure.OUT_POINT_X_POSITION, LoopIteratorFigure.OUT_POINT_Y_POSITION, 00075 InternPointConnectionFigure.WIDTH, InternPointConnectionFigure.HEIGHT)); 00076 00077 iterOperation = null; 00078 } 00079 00080 00087 public GraphicLoopIterator (String startInit, String inc, String endCond, Operation op) 00088 { 00089 super(); 00090 00091 startInitialisation = startInit; 00092 incrementation = inc; 00093 endCondition = endCond; 00094 00095 /* Initialisation of the out intern connection point */ 00096 outPoint.setName("out"); 00097 outPoint.setParent(this); 00098 outPoint.setLayout(new Rectangle (LoopIteratorFigure.OUT_POINT_X_POSITION, LoopIteratorFigure.OUT_POINT_Y_POSITION, 00099 InternPointConnectionFigure.WIDTH, InternPointConnectionFigure.HEIGHT)); 00100 00101 iterOperation = op; 00102 } 00103 00104 00109 public boolean getMonitor() 00110 { 00111 return getElement().getMonitor(); 00112 } 00113 00114 00119 public void setMonitor(boolean monitor) 00120 { 00121 Editor editor = (Editor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); 00122 StructTreatment treatment = editor.getM2MProject().getStructTreatment(); 00123 00124 getElement().setMonitor(monitor,treatment); 00125 } 00126 00127 00132 public String getStartInitialisation() 00133 { 00134 return startInitialisation; 00135 } 00136 00137 00142 public void setStartInitialisation(String startInit) 00143 { 00144 startInitialisation = startInit; 00145 } 00146 00147 00152 public String getIncrementation() 00153 { 00154 return incrementation; 00155 } 00156 00157 00162 public void setIncrementation(String inc) 00163 { 00164 incrementation = inc; 00165 } 00166 00167 00172 public String getEndCondition() 00173 { 00174 return endCondition; 00175 } 00176 00177 00182 public void setEndCondition(String endCond) 00183 { 00184 endCondition = endCond; 00185 } 00186 00187 00192 public InternPointConnection getOutPoint() 00193 { 00194 return outPoint; 00195 } 00196 00197 00202 public Vector<Node> getChildrenArray() 00203 { 00204 Vector<Node> children = new Vector<Node>(); 00205 children.add(outPoint); 00206 return children; 00207 } 00208 00209 00214 public void addConditionNodes(Node node) 00215 { 00216 if (node == null) 00217 throw new IllegalArgumentException(); 00218 else 00219 conditionNodes.add(node); 00220 } 00221 00222 00227 public void removeConditionNodes(Node node) 00228 { 00229 if (node == null) 00230 throw new IllegalArgumentException(); 00231 else 00232 conditionNodes.remove(node); 00233 } 00234 00235 00240 public Vector<Node> getConditionNodes() 00241 { 00242 return conditionNodes; 00243 } 00244 00245 00250 public void setVisible(boolean visible) 00251 { 00252 super.setVisible(visible); 00253 outPoint.setVisible(visible); 00254 } 00255 00256 00261 public PointConnection getOutputPointConnection() 00262 { 00263 return outputPointConnection; 00264 } 00265 00266 00271 public void setOutputPointConnexion(PointConnection pc) 00272 { 00273 outputPointConnection = pc; 00274 pc.setOutputResult(this); 00275 } 00276 00277 00282 public Operation getIterOperation() { 00283 return iterOperation; 00284 } 00285 00286 00291 public void setIterOperation(Operation op) { 00292 iterOperation = op; 00293 } 00294 00299 public void setSelectAll(boolean val) 00300 { 00301 this.selectAll = val; 00302 } 00303 00304 00309 public boolean getSelectAll() 00310 { 00311 return selectAll; 00312 } 00313 00318 public boolean CanSetLayout(Rectangle layoutTest) 00319 { 00320 /* Check if the new layout is inside its parent */ 00321 if(!isInParent(layoutTest)) 00322 return false; 00323 00324 /* Check if the new layout is under connection points */ 00325 for(Node node : getParent().getChildrenArray()) 00326 { 00327 if(node != this && node != outputPointConnection) 00328 if(nodeUnderNode(layoutTest, node.getLayout())) 00329 return false; 00330 } 00331 return true; 00332 } 00333 }