Example #1
0
        public static UMLClass CreateNew(
			UMLDiagram ownerDiagram,
			UML.Class clsModel )
        {
            // creates the graphical representation of the new Class
            DI.GraphNode classifierGN = new DI.GraphNode ();
            //    model bridge to the UML model element (Class)
            Uml2SemanticModelBridge bridge = new Uml2SemanticModelBridge ();
            bridge.Element = clsModel;
            classifierGN.SemanticModel = bridge;
            // graphical representation of the property "Name"
            DI.GraphNode nameGN = new DI.GraphNode ();
            //    graphical properties
            nameGN.Position.X = 4D;
            nameGN.Position.Y = 6D;
            nameGN.Property[DI.StandardProperty.FontFamily] = "Verdana";
            nameGN.Property[DI.StandardProperty.FontSize] = "10";
            //    model bridge to the property
            DI.SimpleSemanticModelElement nameBridge = new DI.SimpleSemanticModelElement ();
            nameBridge.TypeInfo = "NameCompartment";
            nameGN.SemanticModel = nameBridge;
            // adds the name GN to the Use Case GN
            classifierGN.Contained.Add (nameGN);
            nameGN.Container = classifierGN;
            // adds the classifier to the diagram
            ownerDiagram.DIDiagram.Contained.Add (classifierGN);
            classifierGN.Container = ownerDiagram.DIDiagram;
            return new UMLClass (ownerDiagram, classifierGN);
        }
Example #2
0
        public static UMLAssociation CreateNew(
			UMLDiagram ownerDiagram,
			UMLElement fromElement,
			UMLElement toElement )
        {
            UMLAssociation association = null;
            DI.GraphElement fromGE = fromElement.GraphElement;
            DI.GraphElement toGE = toElement.GraphElement;
            UML.Classifier fromModelElement = MonoUML.Widgets.Helper.GetSemanticElement (fromGE) as UML.Classifier;
            UML.Classifier toModelElement = MonoUML.Widgets.Helper.GetSemanticElement (toGE) as UML.Classifier;
            if (fromModelElement != null && toModelElement != null)
            {
                // creates the new Association in the model
                UML.Association assocModel = UML.Create.Association ();
                UML.Property end0 = UML.Create.Property ();
                // the first end aims at the "TO" end
                end0.Type = toModelElement;
                assocModel.OwnedEnd.Add (end0);
                end0.OwningAssociation = assocModel;
                // the second (and last) end aims at the "FROM" end
                UML.Property end1 = UML.Create.Property ();
                end1.Type = fromModelElement;
                assocModel.OwnedEnd.Add (end1);
                end1.OwningAssociation = assocModel;
                // creates the graphical representation of the new Association
                DI.GraphEdge assocGE = new DI.GraphEdge ();
                //    graphical properties
                //    model bridge to the UML model element (Actor)
                Uml2SemanticModelBridge bridge = new Uml2SemanticModelBridge ();
                bridge.Element = assocModel;
                assocGE.SemanticModel = bridge;
                // adds anchors and anchorages
                DI.GraphConnector cnn;
                cnn = new DI.GraphConnector ();
                cnn.GraphElement = fromGE;
                fromGE.Anchorage.Add (cnn);
                fromGE.Position.CopyTo (cnn.Position);
                assocGE.Anchor.Add (cnn);
                cnn.GraphEdge.Add (assocGE);
                cnn = new DI.GraphConnector ();
                cnn.GraphElement = toGE;
                toGE.Anchorage.Add (cnn);
                toGE.Position.CopyTo (cnn.Position);
                assocGE.Anchor.Add (cnn);
                cnn.GraphEdge.Add (assocGE);
                // adds waypoints
                DI.GraphNode gn = fromGE as DI.GraphNode;
                DI.Point f = (gn != null ? gn.Center : toGE.Position.Clone ());
                gn = toGE as DI.GraphNode;
                DI.Point t = (gn != null ? gn.Center : toGE.Position.Clone ());
                assocGE.Waypoints.Add (f);
                assocGE.Waypoints.Add (t);
                // adds the name compartment
                DI.SimpleSemanticModelElement simpleBridge;
                DI.GraphNode nameCompartmentGN = new DI.GraphNode ();
                simpleBridge = new DI.SimpleSemanticModelElement ();
                simpleBridge.TypeInfo = "DirectedName";
                nameCompartmentGN.SemanticModel = simpleBridge;
                assocGE.Contained.Add (nameCompartmentGN);
                nameCompartmentGN.Container = assocGE;
                DI.Point.GetHalfWayPoint (fromGE.Position, toGE.Position).CopyTo (nameCompartmentGN.Position);
                DI.GraphNode keywordMetaclassGN = new DI.GraphNode ();
                simpleBridge = new DI.SimpleSemanticModelElement ();
                simpleBridge.TypeInfo = "Name";
                keywordMetaclassGN.SemanticModel = simpleBridge;
                nameCompartmentGN.Contained.Add (keywordMetaclassGN);
                keywordMetaclassGN.Container = nameCompartmentGN;
                // adds the association ends compartments
                DI.GraphNode endCompartment0 = UMLAssociationEnd.CreateNewGraphNode (end0);
                assocGE.Contained.Add (endCompartment0);
                endCompartment0.Container = assocGE;
                DI.GraphNode endCompartment1 = UMLAssociationEnd.CreateNewGraphNode (end1);
                assocGE.Contained.Add (endCompartment1);
                endCompartment1.Container = assocGE;
                // adds the association to the diagram
                ownerDiagram.DIDiagram.Contained.Add (assocGE);
                assocGE.Container = ownerDiagram.DIDiagram;
                association = new UMLAssociation (ownerDiagram, assocGE, assocModel);
                association._assocEnd0.SetPosition ((DI.Point) association._graphEdge.Waypoints [0]);
                association._assocEnd1.SetPosition ((DI.Point) association._graphEdge.Waypoints [1]);
                ownerDiagram.AddNewClassifier (association, assocModel);
            }
            return association;
        }
Example #3
0
 private static void AddNewCompartment(DI.GraphNode owner, string typeInfo)
 {
     DI.GraphNode compartment = new DI.GraphNode ();
     DI.SimpleSemanticModelElement bridge = new DI.SimpleSemanticModelElement ();
     bridge.TypeInfo = typeInfo;
     compartment.SemanticModel = bridge;
     owner.Contained.Add (compartment);
     compartment.Container = owner;
 }
Example #4
0
 public void NewUMLDiagram()
 {
     if(_elementsList == null || _elementsList.Count == 0)
     {
         Gtk.MessageDialog md = new Gtk.MessageDialog (
             null,
             Gtk.DialogFlags.DestroyWithParent,
             Gtk.MessageType.Info,
             Gtk.ButtonsType.Close,
             GettextCatalog.GetString ("There are no elements in the model; you should create some elements first."));
         md.Run ();
         md.Destroy();
         return;
     }
     // pick a diagram type
     DiagramTypeChooserDialog dialog = new DiagramTypeChooserDialog();
     int rtn = dialog.Run();
     if (rtn != Gtk.ResponseType.Accept.value__ && rtn != Gtk.ResponseType.Ok.value__)
     {
         return;
     }
     string diagramType = dialog.Selection;
     // pick a namespace
     ElementChooserDialog chooser = new ElementChooserDialog(
         typeof(UML.Namespace), GettextCatalog.GetString ("Choose a namespace"));
     if (_eventQueue.LastSelectedElement is UML.Namespace)
     {
         chooser.SelectedObject = _eventQueue.LastSelectedElement;
     }
     if(chooser.Run() != Gtk.ResponseType.Accept.value__) return;
     UML.Namespace ns = (UML.Namespace)chooser.SelectedObject;
     // create a new diagram
     DI.Diagram newDiagram = new DI.Diagram();
     DI.SimpleSemanticModelElement bridge = new DI.SimpleSemanticModelElement();
     bridge.TypeInfo = diagramType.Replace(" ", "") + "Diagram";
     newDiagram.SemanticModel = bridge;
     Uml2SemanticModelBridge nsbridge = new Uml2SemanticModelBridge();
     nsbridge.Element = ns;
     newDiagram.Namespace =  nsbridge;
     _elementsList.Add (newDiagram);
     // broadcast the change
     _broadcaster.BroadcastNewModel(_elementsList);
     ElementChooserDialog.SetProjectElements(_elementsList);
 }
Example #5
0
        protected static DI.GraphNode CreateNewGraphNode(
			UMLDiagram ownerDiagram,
			UML.Element modelElement)
        {
            // creates the graphical representation
            DI.GraphNode modelElementGN = new DI.GraphNode ();
            //    model bridge to the UML model element
            Uml2SemanticModelBridge bridge = new Uml2SemanticModelBridge ();
            bridge.Element = modelElement;
            modelElementGN.SemanticModel = bridge;
            // graphical representation of the property "Name"
            DI.GraphNode nameGN = new DI.GraphNode ();
            //    graphical properties
            nameGN.Position.X = 4D;
            nameGN.Position.Y = 6D;
            nameGN.Property[DI.StandardProperty.FontFamily] = "Verdana";
            nameGN.Property[DI.StandardProperty.FontSize] = "10";
            //    model bridge to the property
            DI.SimpleSemanticModelElement nameBridge = new DI.SimpleSemanticModelElement ();
            nameBridge.TypeInfo = "NameCompartment";
            nameGN.SemanticModel = nameBridge;
            // adds the name GN to the model element GN
            modelElementGN.Contained.Add (nameGN);
            nameGN.Container = modelElementGN;
            // adds the modelElement to the diagram
            ownerDiagram.DIDiagram.Contained.Add (modelElementGN);
            return modelElementGN;
        }
Example #6
0
 private object Deserialize_SimpleSemanticModelElement()
 {
     DI.SimpleSemanticModelElement deserialized = new DI.SimpleSemanticModelElement();
     SkipAllAndWornAsUnknown();
     return deserialized;
 }
        public static UMLStereotypedEdge CreateNewAndAdd(
			UMLDiagram owningDiagram,
			UML.Relationship stereotypedEdgeModel,
			DI.GraphElement fromGE,
			DI.GraphElement toGE
		)
        {
            // creates the graphical representation of the new Stereotyped Edge
            DI.GraphEdge stereotypedEdgeGE = new DI.GraphEdge ();
            // model semanticModelBridge to the UML model element
            Uml2SemanticModelBridge semanticModelBridge = new Uml2SemanticModelBridge ();
            semanticModelBridge.Element = stereotypedEdgeModel;
            stereotypedEdgeGE.SemanticModel = semanticModelBridge;
            // adds anchors and anchorages
            DI.GraphConnector cnn;

            cnn = new DI.GraphConnector ();
            cnn.GraphElement = fromGE;
            fromGE.Position.CopyTo (cnn.Position);
            fromGE.Anchorage.Add (cnn);
            stereotypedEdgeGE.Anchor.Add (cnn);
            cnn.GraphEdge.Add(stereotypedEdgeGE);

            cnn = new DI.GraphConnector ();
            cnn.GraphElement = toGE;
            toGE.Position.CopyTo (cnn.Position);
            toGE.Anchorage.Add (cnn);
            stereotypedEdgeGE.Anchor.Add (cnn);
            cnn.GraphEdge.Add(stereotypedEdgeGE);
            // adds waypoints
            DI.GraphNode gn = fromGE as DI.GraphNode;
            DI.Point f = (gn != null ? gn.Center : fromGE.Position.Clone ());
            gn = toGE as DI.GraphNode;
            DI.Point t = (gn != null ? gn.Center : toGE.Position.Clone ());
            stereotypedEdgeGE.Waypoints.Add (f);
            stereotypedEdgeGE.Waypoints.Add (t);
            // adds the stereotype compartment
            DI.SimpleSemanticModelElement bridge;
            DI.GraphNode stCompartmentGN = new DI.GraphNode ();
            bridge = new DI.SimpleSemanticModelElement ();
            bridge.TypeInfo = "StereotypeCompartment";
            stCompartmentGN.SemanticModel = bridge;
            stereotypedEdgeGE.Contained.Add (stCompartmentGN);
            stCompartmentGN.Container = stereotypedEdgeGE;
            DI.Point.GetHalfWayPoint (fromGE.Position, toGE.Position).CopyTo (stCompartmentGN.Position);
            DI.GraphNode keywordMetaclassGN = new DI.GraphNode ();
            bridge = new DI.SimpleSemanticModelElement ();
            bridge.TypeInfo = "KeywordMetaclass";
            keywordMetaclassGN.SemanticModel = bridge;
            stCompartmentGN.Contained.Add (keywordMetaclassGN);
            keywordMetaclassGN.Container = stCompartmentGN;
            // adds the stereotypedEdge to the diagram
            owningDiagram.DIDiagram.Contained.Add (stereotypedEdgeGE);
            stereotypedEdgeGE.Container = owningDiagram.DIDiagram;
            UMLStereotypedEdge stereotypedEdge = new UMLStereotypedEdge (owningDiagram, stereotypedEdgeGE, stereotypedEdgeModel);
            owningDiagram.UMLCanvas.AddElement (stereotypedEdge);
            return stereotypedEdge;
        }