Math2mat

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

Go to the documentation of this file.
00001 
00015 package m2m.frontend.dynamicview.figure;
00016 
00017 import m2m.frontend.dynamicview.model.Connection;
00018 import m2m.frontend.dynamicview.model.GraphicFunction;
00019 import m2m.frontend.dynamicview.model.GraphicIf;
00020 import m2m.frontend.dynamicview.model.GraphicLoop;
00021 import m2m.frontend.dynamicview.model.GraphicLoopIterator;
00022 import m2m.frontend.dynamicview.model.GraphicOperation;
00023 import m2m.frontend.dynamicview.model.Node;
00024 import m2m.frontend.dynamicview.model.PointConnection;
00025 import m2m.frontend.dynamicview.model.Schema;
00026 
00027 import org.eclipse.draw2d.ColorConstants;
00028 import org.eclipse.draw2d.Figure;
00029 import org.eclipse.draw2d.LineBorder;
00030 import org.eclipse.draw2d.XYLayout;
00031 import org.eclipse.draw2d.geometry.Rectangle;
00032 
00033 
00034 public class PropertyFigure extends Figure
00035 {
00039     private XYLayout layout;
00043     private PointConnectionPropertyFigure pcPropertyFigure;
00047     private SchemaPropertyFigure schemaPropertyFigure;
00051     private FunctionPropertyFigure functionPropertyFigure;
00055     private IfPropertyFigure ifPropertyFigure;  
00059     private OperationPropertyFigure operationPropertyFigure;
00063     private LoopPropertyFigure forPropertyFigure;
00067     private LoopIteratorPropertyFigure loopIteratorPropertyFigure;
00071     private ConnectionPropertyFigure connectionPropertyFigure;
00072     
00073     
00077     public PropertyFigure(Schema schema) 
00078     {
00079         /* Set the type of layout */
00080         layout = new XYLayout();
00081         setLayoutManager(layout);
00082         
00083         /* Initialisation of the PointConnectionPropertyFigure */
00084         pcPropertyFigure = new PointConnectionPropertyFigure();
00085         add(pcPropertyFigure);
00086         setConstraint(pcPropertyFigure, new Rectangle(0, 0, -1, -1));
00087         pcPropertyFigure.setVisible(false);
00088         
00089         /* Initialisation of the SchemaPropertyFigure */
00090         schemaPropertyFigure = new SchemaPropertyFigure(schema);
00091         add(schemaPropertyFigure);
00092         setConstraint(schemaPropertyFigure, new Rectangle(0, 0, -1, -1));
00093         schemaPropertyFigure.setVisible(false);
00094         
00095         /* Initialisation of the FunctionPropertyFigure */
00096         functionPropertyFigure = new FunctionPropertyFigure();
00097         add(functionPropertyFigure);
00098         setConstraint(functionPropertyFigure, new Rectangle(0, 0, -1, -1));
00099         functionPropertyFigure.setVisible(false);
00100 
00101         /* Initialisation of the IfPropertyFigure */
00102         ifPropertyFigure = new IfPropertyFigure();
00103         add(ifPropertyFigure);
00104         setConstraint(ifPropertyFigure, new Rectangle(0, 0, -1, -1));
00105         ifPropertyFigure.setVisible(false);       
00106         
00107         /* Initialisation of the OperationPropertyFigure */
00108         operationPropertyFigure = new OperationPropertyFigure(schema);
00109         add(operationPropertyFigure);
00110         setConstraint(operationPropertyFigure, new Rectangle(0, 0, -1, -1));
00111         operationPropertyFigure.setVisible(false);
00112         
00113         /* Initialisation of the ForPropertyFigure */
00114         forPropertyFigure = new LoopPropertyFigure();
00115         add(forPropertyFigure);
00116         setConstraint(forPropertyFigure, new Rectangle(0, 0, -1, -1));
00117         forPropertyFigure.setVisible(false);
00118         
00119         /* Initialisation of the LoopIteratorPropertyFigure */
00120         loopIteratorPropertyFigure = new LoopIteratorPropertyFigure(schema);
00121         add(loopIteratorPropertyFigure);
00122         setConstraint(loopIteratorPropertyFigure, new Rectangle(0, 0, -1, -1));
00123         loopIteratorPropertyFigure.setVisible(false);
00124         
00125         /* Initialisation of the ConnectionPropertyFigure */
00126         connectionPropertyFigure = new ConnectionPropertyFigure();
00127         add(connectionPropertyFigure);
00128         setConstraint(connectionPropertyFigure, new Rectangle(0, 0, -1, -1));
00129         connectionPropertyFigure.setVisible(false);
00130         
00131         /* Initialisation of the figure */
00132         setOpaque(true);     
00133         setBackgroundColor(ColorConstants.menuBackground);
00134         setForegroundColor(ColorConstants.menuForeground);
00135         setBorder(new LineBorder(3));   
00136     }
00137     
00138     
00143     public void setProperty(Node node) 
00144     {
00145         /* Mask all property figure */
00146         pcPropertyFigure.setVisible(false);
00147         schemaPropertyFigure.setVisible(false);
00148         functionPropertyFigure.setVisible(false);
00149         ifPropertyFigure.setVisible(false);     
00150         operationPropertyFigure.setVisible(false);
00151         forPropertyFigure.setVisible(false);
00152         loopIteratorPropertyFigure.setVisible(false);
00153         connectionPropertyFigure.setVisible(false);
00154         
00155         /* Draw the correct property figure corresponding to the selected node */
00156         if(node instanceof Schema)
00157         {
00158                 schemaPropertyFigure.setVisible(true);          
00159                 schemaPropertyFigure.setProperty();
00160         }
00161         else if(node instanceof GraphicFunction)
00162         {
00163                 functionPropertyFigure.setVisible(true);                
00164                 functionPropertyFigure.setProperty((GraphicFunction) node);
00165         }
00166         else if(node instanceof PointConnection)
00167         {
00168                 pcPropertyFigure.setVisible(true);              
00169                 pcPropertyFigure.setProperty((PointConnection) node);
00170         }
00171         else if(node instanceof GraphicIf)
00172         {
00173                 ifPropertyFigure.setVisible(true);              
00174                 ifPropertyFigure.setProperty((GraphicIf) node);
00175         }
00176         else if(node instanceof GraphicOperation)
00177         {
00178                 operationPropertyFigure.setVisible(true);               
00179                 operationPropertyFigure.setProperty((GraphicOperation) node);
00180         }
00181         else if(node instanceof GraphicLoop)
00182         {
00183                 forPropertyFigure.setVisible(true);             
00184                 forPropertyFigure.setProperty((GraphicLoop) node);
00185         }
00186         else if(node instanceof GraphicLoopIterator)
00187         {
00188                 loopIteratorPropertyFigure.setVisible(true);            
00189                 loopIteratorPropertyFigure.setProperty((GraphicLoopIterator) node);
00190         }
00191     }
00192     
00197     public void setProperty(Connection conn) 
00198     {
00199         /* Mask all property figures */
00200         pcPropertyFigure.setVisible(false);
00201         schemaPropertyFigure.setVisible(false);
00202         functionPropertyFigure.setVisible(false);
00203         ifPropertyFigure.setVisible(false);     
00204         operationPropertyFigure.setVisible(false);
00205         forPropertyFigure.setVisible(false);
00206         loopIteratorPropertyFigure.setVisible(false);
00207         
00208         /*  Set the properties the connection */
00209                 connectionPropertyFigure.setVisible(true);              
00210                 connectionPropertyFigure.setProperty((Connection) conn);
00211     }
00212     
00213 }
 All Classes Namespaces Files Functions Variables Enumerations