Exemple #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);
        }
        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;
        }
 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;
 }
 public static DI.GraphNode CreateNewGraphNode(UML.Property end)
 {
     DI.GraphNode endCompartment = new DI.GraphNode ();
     Uml2SemanticModelBridge modelBridge = new Uml2SemanticModelBridge ();
     modelBridge.Element = end;
     endCompartment.SemanticModel = modelBridge;
     // compartments
     AddNewCompartment (endCompartment, "Multiplicity");
     AddNewCompartment (endCompartment, "Name");
     AddNewCompartment (endCompartment, "Visibility");
     return endCompartment;
 }
 public UMLAssociationEnd(UMLDiagram ownerDiagram, DI.GraphNode graphNode)
     : base(ownerDiagram, graphNode)
 {
     _circle = new CanvasEllipse (ownerDiagram.CanvasRoot);
     _circle.OutlineColorGdk = UMLEdge.HIGHLIGHTED_OUTLINE_COLOR;
     _graphNode = graphNode;
     _modelElement = (UML.Property) MonoUML.Widgets.Helper.GetSemanticElement (graphNode);
     DI.SimpleSemanticModelElement bridge;
     foreach (DI.GraphNode gn in graphNode.Contained)
     {
         bridge = gn.SemanticModel as DI.SimpleSemanticModelElement;
         switch (bridge.TypeInfo)
         {
             case "Name":
                 _name = new UMLEntry (this, gn, ownerDiagram.CanvasRoot, true, _modelElement.Name);
                 _name.TextChanged += new UMLElementNameChangedHandler (BroadcastNameChange);
                 base.AddFreeEntry (_name);
                 _name.Show ();
                 break;
             case "Visibility":
                 break;
             case "Multiplicity":
                 _multiplicity = new UMLEntry (this, gn, ownerDiagram.CanvasRoot, true, GetMultiplicity ());
                 _multiplicity.TextChanged += new UMLElementNameChangedHandler (ApplyMultiplicityChange);
                 base.AddFreeEntry (_multiplicity);
                 _multiplicity.Show ();
                 break;
         }
     }
 }
Exemple #6
0
        public UMLEntry(
			UMLElement owner,
			DI.GraphNode graphNode,
			CanvasGroup group,
			bool isMovable,
			string text,
			string fontModifier
		)
            : base(group)
        {
            _graphNode = graphNode;
            Movable = isMovable;
            _owner = owner;
            _text = new CanvasText (this);
            _text.Text = (text == null ? System.String.Empty : text);
            _text.FillColor = "black";
            _text.CanvasEvent += EntryEvents;
            _text.Justification = Gtk.Justification.Left;
            _text.Anchor = Gtk.AnchorType.NorthWest;
            this.FontModifier = fontModifier;
            _root = group;
            X = _movable ? _graphNode.GlobalPosition.X : _graphNode.Position.X;
            Y = _movable ? _graphNode.GlobalPosition.Y : _graphNode.Position.Y;
            Show ();
        }
Exemple #7
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;
        }
Exemple #8
0
 private object Deserialize_GraphNode()
 {
     string attrNs, prop;
     DI.GraphNode deserialized = new DI.GraphNode();
     if(base.MoveToFirstChild())
     {
         do
         {
             attrNs = base.XmlReader.NamespaceURI;
             prop = base.XmlReader.NameTable.Get(base.XmlReader.LocalName);
             if(object.ReferenceEquals(attrNs, String.Empty)
                 || object.ReferenceEquals(attrNs, _diNs))
             {
                 if(!DeserCompElemsIn_GraphNode(deserialized, prop))
                 if(!DeserCompElemsIn_GraphElement(deserialized, prop))
                 if(!DeserCompElemsIn_DiagramElement(deserialized, prop))
                 base.WarnUnknownElement(prop);
             }
         } while(base.MoveToNextSibling());
     }
     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;
        }
 // Looks for the contained graph node that represents the stereotype,
 // then creates a UMLEntry and shows it.
 // The name of the edge is represented as two graph nodes: one for the
 // point where the name is located (typeInfo DirectedName) and another one
 // (contained within the former) which represents the label itself.
 // As always, every position is relative to its owner's position.
 // Note that edges are always placed at (0, 0).
 private void SearchAndDrawStereotype(DI.GraphEdge graphEdge, UMLDiagram ownerDiagram)
 {
     // looks for the contained graph node that represents the edge name
     DI.GraphNode stereotypeCompartmentGN = null;
     int i = 0;
     DI.SimpleSemanticModelElement bridge;
     while (_stereotypeCompartmentGN == null && i < graphEdge.Contained.Count)
     {
         stereotypeCompartmentGN = graphEdge.Contained [i++] as DI.GraphNode;
         if (stereotypeCompartmentGN != null)
         {
             bridge = stereotypeCompartmentGN.SemanticModel as DI.SimpleSemanticModelElement;
             if (bridge != null && bridge.TypeInfo == "StereotypeCompartment")
             {
                 _stereotypeCompartmentGN = stereotypeCompartmentGN;
             }
         }
     }
     // if the corresponding graph node was found, draw it
     if (_stereotypeCompartmentGN != null)
     {
         // first, find the corresponding Graph Node
         i = 0;
         DI.GraphNode keywordMetaclassGN = null;
         bridge = null;
         do
         {
             keywordMetaclassGN = _stereotypeCompartmentGN.Contained [i++] as DI.GraphNode;
             if (keywordMetaclassGN != null)
             {
                 bridge = keywordMetaclassGN.SemanticModel as DI.SimpleSemanticModelElement;
             }
         } while (bridge==null || bridge.TypeInfo != "KeywordMetaclass");
         // now we're able to draw it
         string text = "<<" + _modelElement.GetType().Name.Substring(6).ToLower() + ">>";
         _keywordMetaclassUMLEntry = new UMLEntry (this, keywordMetaclassGN, ownerDiagram.CanvasRoot, true, text);
         _keywordMetaclassUMLEntry.Editable = false;
         base.AddFreeEntry (_keywordMetaclassUMLEntry);
         _keywordMetaclassUMLEntry.Show ();
     }
 }