Math2mat

/home/ythoma/docs/math2mat/svn/wp1/framework/m2mGUI/src/m2m/frontend/dynamicview/figure/IfFigure.java

Go to the documentation of this file.
00001 
00015 package m2m.frontend.dynamicview.figure;
00016 
00017 import org.eclipse.draw2d.ChopboxAnchor;
00018 import org.eclipse.draw2d.ColorConstants;
00019 import org.eclipse.draw2d.Figure;
00020 import org.eclipse.draw2d.Label;
00021 import org.eclipse.draw2d.PolylineConnection;
00022 import org.eclipse.draw2d.RectangleFigure;
00023 import org.eclipse.draw2d.Shape;
00024 import org.eclipse.draw2d.ToolbarLayout;
00025 import org.eclipse.draw2d.XYLayout;
00026 import org.eclipse.draw2d.geometry.Point;
00027 import org.eclipse.draw2d.geometry.Rectangle;
00028 
00029 public class IfFigure extends Figure
00030 {
00034         public static final int TRUE_POINT_X_POSITION = 0;
00035         public static final int TRUE_POINT_Y_POSITION = 8;
00039         public static final int FALSE_POINT_X_POSITION = 0;
00040         public static final int FALSE_POINT_Y_POSITION = 27;
00044         public static final int OUT_POINT_X_POSITION = 35;
00045         public static final int OUT_POINT_Y_POSITION = 17;
00049         public static final int HEIGHT = 40;
00050         public static final int WIDTH  = 41;
00051         
00052         
00056     private XYLayout layout;
00060         private Label labelTrue = new Label();
00064         private Label labelFalse = new Label();
00065     
00066 
00067     
00071     public IfFigure() 
00072     {
00073         /* Set the type of layout */
00074         layout = new XYLayout();
00075         setLayoutManager(layout);   
00076          
00077         /* Initialisation of the labelTrue */
00078         labelTrue.setForegroundColor(ColorConstants.black);
00079         labelTrue.setText("0");
00080         add(labelTrue, ToolbarLayout.VERTICAL); 
00081         setConstraint(labelTrue, new Rectangle(8, TRUE_POINT_Y_POSITION-5, -1, -1)); 
00082     
00083         /* Initialisation of the labelFalse */
00084         labelFalse.setForegroundColor(ColorConstants.black);
00085         labelFalse.setText("1");
00086         add(labelFalse, ToolbarLayout.VERTICAL); 
00087         setConstraint(labelFalse, new Rectangle(8, FALSE_POINT_Y_POSITION-5, -1, -1)); 
00088         
00089         /* Create and locate the four corner of the multiplexer */
00090                 Shape rectangle1 = new RectangleFigure();
00091                 rectangle1.setSize(0, 0);
00092                 rectangle1.setLocation(new Point(0, 0));
00093                 
00094                 Shape rectangle2 = new RectangleFigure();
00095                 rectangle2.setSize(0, 0);
00096                 rectangle2.setLocation(new Point(0, 40));
00097                 
00098                 Shape rectangle3 = new RectangleFigure();
00099                 rectangle3.setSize(0, 0);
00100                 rectangle3.setLocation(new Point(40, 9));
00101                 
00102                 Shape rectangle4 = new RectangleFigure();
00103                 rectangle4.setSize(0, 0);
00104                 rectangle4.setLocation(new Point(40, 31));
00105                 
00106                 /* Create and draw lines between the four corner of the multiplexer */
00107         PolylineConnection c1 = new PolylineConnection();
00108         c1.setSourceAnchor(new ChopboxAnchor(rectangle1));
00109         c1.setTargetAnchor(new ChopboxAnchor(rectangle2));
00110         
00111         PolylineConnection c2 = new PolylineConnection();
00112         c2.setSourceAnchor(new ChopboxAnchor(rectangle1));
00113         c2.setTargetAnchor(new ChopboxAnchor(rectangle3));
00114         
00115         PolylineConnection c3 = new PolylineConnection();
00116         c3.setSourceAnchor(new ChopboxAnchor(rectangle3));
00117         c3.setTargetAnchor(new ChopboxAnchor(rectangle4));
00118         
00119         PolylineConnection c4 = new PolylineConnection();
00120         c4.setSourceAnchor(new ChopboxAnchor(rectangle2));
00121         c4.setTargetAnchor(new ChopboxAnchor(rectangle4));
00122          
00123         add(c1);
00124         add(c2);
00125         add(c3);
00126         add(c4);
00127         
00128         add(rectangle1);
00129         add(rectangle2);
00130         add(rectangle3);
00131         add(rectangle4);
00132     }
00133     
00134     
00139     public void setLayout(Rectangle rect) 
00140     {
00141         getParent().setConstraint(this, rect);
00142     }
00143 }
 All Classes Namespaces Files Functions Variables Enumerations