Exemple #1
0
 public UMLBox(UMLDiagram ownerDiagram, DI.GraphNode graphNode)
     : base(ownerDiagram, graphNode)
 {
     _outerBox = new CanvasRect (ChildrensRoot);
     _outerBox.X1 = _outerBox.Y1 = 0;
     _outerBox.X2 = Width;
     _outerBox.Y2 = Height;
     _outerBox.FillColor = DEFAULT_FILL_COLOR;
     _outerBox.OutlineColor = DEFAULT_OUTLINE_COLOR;
     Width = graphNode.Size.Width;
     Height = graphNode.Size.Height;
     // gets the corresponding model element
     Uml2SemanticModelBridge bridge = (Uml2SemanticModelBridge) graphNode.SemanticModel;
     _modelElement = (UML.NamedElement) bridge.Element;
     DI.GraphElement nestedDiagElem;
     DI.SimpleSemanticModelElement nestedBridge;
     // looks for the Name compartment
     foreach (DI.DiagramElement elem in GraphNode.Contained)
     {
         nestedDiagElem = elem as DI.GraphElement;
         if (nestedDiagElem != null)
         {
             nestedBridge = nestedDiagElem.SemanticModel as DI.SimpleSemanticModelElement;
             if (nestedBridge.TypeInfo == "NameCompartment")
             {
                 // widget for the property Name
                 _name = new UMLEntry (this, (DI.GraphNode)nestedDiagElem, ChildrensRoot, false, _modelElement.Name);
                 _name.Show();
                 break;
             }
         }
     }
     Redraw ();
 }
 // Constructor
 private NoteBookLabel(DI.Diagram diagram)
     : base(1, 3, false)
 {
     _parent = null;
     _diagram = diagram;
     //this must change depending of the diagram's type
     string diagramType = ((DI.SimpleSemanticModelElement)diagram.SemanticModel).TypeInfo;
     _icon = GetIcon(diagramType);
     //_icon = new Gdk.Pixbuf (new Gdk.Colorspace(), false, 8, 15, 15);
     //_icon.Fill (0xffff0000);
     //
     Attach(new Gtk.Image(_icon), 0, 1, 0, 1);
     //
     _label = new Label(_diagram.Name);
     Attach(_label, 1, 2, 0, 1);
     //
     Image image = new Image();
     image.Stock = Gtk.Stock.Close;
     _close_button = new Button();
     _close_button.Add(image);
     _close_button.HeightRequest = 20;
     _close_button.WidthRequest = 20;
     _close_button.Relief = Gtk.ReliefStyle.None;
     _close_button.Clicked += OnCloseButtonClicked;
     Tooltips ttips = new Tooltips ();
     ttips.SetTip (_close_button, GettextCatalog.GetString ("Close diagram"), GettextCatalog.GetString ("Close diagram"));
     //_close_button.
     Attach(_close_button, 2, 3, 0, 1);
     ShowAll();
 }
Exemple #3
0
 // Constructor
 private UMLDiagram(DI.Diagram diagram)
 {
     _diagram = diagram;
     _canvas = new UMLCanvas (this);
     _canvas.ElementNameChanged += ChangeElementNameHub;
     Refresh ();
 }
        public static UMLAssociation CreateNew(
			CanvasGroup group,
			DI.Diagram ownerDiagram,
			UML.Association associationModel )
        {
            return null;
        }
 public UMLInterfaceRealization(UMLDiagram ownerDiagram, DI.GraphEdge interfaceRealizationGraphEdge)
     : this(ownerDiagram, interfaceRealizationGraphEdge, (UML.InterfaceRealization) MonoUML.Widgets.Helper.GetSemanticElement (interfaceRealizationGraphEdge))
 {
     // create the graphic elements that compose this element
     // create the UML canvas elements that compose this UML Element
     Redraw ();
     // create nested stuff
 }
Exemple #6
0
 public UMLElement(UMLDiagram ownerDiagram, DI.GraphElement graphElement)
     : base(ownerDiagram.CanvasRoot)
 {
     _ownerDiagram = ownerDiagram;
     _graphElement = graphElement;
     ownerDiagram.AddMapping (graphElement, this);
     _freeEntries = new ArrayList ();
 }
 public UMLAssociation(UMLDiagram ownerDiagram, DI.GraphEdge associationGraphEdge)
     : this(ownerDiagram, associationGraphEdge, (UML.Association) MonoUML.Widgets.Helper.GetSemanticElement (associationGraphEdge))
 {
     // create the graphic elements that compose this element
     // create the UML canvas elements that compose this UML Element
     Redraw ();
     // create nested stuff
 }
        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;
        }
        private UMLInterfaceRealization(
			UMLDiagram ownerDiagram,
			DI.GraphEdge interfaceRealizationGraphEdge,
			UML.InterfaceRealization interfaceRealizationModel
		)
            : base(ownerDiagram, interfaceRealizationGraphEdge, false)
        {
            _modelElement = interfaceRealizationModel;
            SetEdgeEnds ();
        }
        private UMLGeneralization(
			UMLDiagram ownerDiagram,
			DI.GraphEdge generalizationGraphEdge,
			UML.Generalization generalizationModel
		)
            : base(ownerDiagram, generalizationGraphEdge, false)
        {
            _modelElement = generalizationModel;
            SetEdgeEnds ();
        }
Exemple #11
0
        public UMLNamedEdge(
			UMLDiagram ownerDiagram,
			DI.GraphEdge graphEdge,
			UML.NamedElement namedElementModel,
			bool forceRedraw)
            : base(ownerDiagram, graphEdge, forceRedraw)
        {
            _namedElementModel = namedElementModel;
            SearchAndDrawName (graphEdge, ownerDiagram);
        }
        private UMLAssociation(
			UMLDiagram ownerDiagram,
			DI.GraphEdge associationGraphEdge,
			UML.Association associationModel
		)
            : base(ownerDiagram, associationGraphEdge, associationModel, false)
        {
            _modelElement = associationModel;
            SetEdgeEnds ();
            SearchAndDrawEndTexts ();
        }
        public UMLStereotypedEdge(
			UMLDiagram ownerDiagram,
			DI.GraphEdge graphEdge,
			UML.Relationship edgeModel
		)
            : base(ownerDiagram, graphEdge, false)
        {
            _modelElement = edgeModel;
            base.AddToEnd (new UMLOpenArrow (ChildrensRoot));
            SearchAndDrawStereotype (graphEdge, ownerDiagram);
            base.ForceRedraw ();
        }
Exemple #14
0
 public UMLActor(UMLDiagram ownerDiagram, DI.GraphNode actorGraphNode)
     : base(ownerDiagram, actorGraphNode)
 {
     // old ctor
     _head = new CanvasEllipse (ChildrensRoot);
     _head.OutlineColor = DEFAULT_OUTLINE_COLOR;
     _head.FillColor = DEFAULT_FILL_COLOR;
     //
     _arms = new CanvasLine (ChildrensRoot);
     _arms.WidthUnits = 1.0;
     _arms.FillColor = DEFAULT_OUTLINE_COLOR;
     //
     _body = new CanvasLine (ChildrensRoot);
     _body.WidthUnits = 1.0;
     _body.FillColor = DEFAULT_OUTLINE_COLOR;
     //
     _legs = new CanvasLine (ChildrensRoot);
     _legs.WidthUnits= 1.0;
     _legs.FillColor = DEFAULT_OUTLINE_COLOR;
     // /old ctor
     _modelElement = (UML.Actor) MonoUML.Widgets.Helper.GetSemanticElement (actorGraphNode);
     DI.GraphElement nestedDiagElem;
     DI.SimpleSemanticModelElement nestedBridge;
     //
     DI.DiagramElement elem = (DI.DiagramElement) actorGraphNode.Contained[0];
     nestedDiagElem = elem as DI.GraphElement;
     if (nestedDiagElem != null)
     {
         nestedBridge = nestedDiagElem.SemanticModel as DI.SimpleSemanticModelElement;
         if (nestedBridge.TypeInfo == "Name")
         {
             string fontModifier = (_modelElement.IsAbstract ? "italic" : "");
             _nameUMLEntry = new UMLEntry (this, (DI.GraphNode)nestedDiagElem, ownerDiagram.CanvasRoot, true, _modelElement.Name, fontModifier);
             base.AddFreeEntry (_nameUMLEntry);
             _nameUMLEntry.Show ();
             _nameDIGraphNode = nestedDiagElem;
         }
     }
     else
     {
         //TODO: Create both, entry and DI nested element
     }
     _nameUMLEntry.TextChanged += CallHub;
     Redraw ();
 }
 protected override void DrawElement(DI.GraphNode node)
 {
     Uml2SemanticModelBridge bridge = node.SemanticModel as Uml2SemanticModelBridge;
     UML.Element element = bridge.Element;
     if (element is UML.Actor)
     {
         UMLActor actor = new UMLActor (this, node);
         _canvas.AddElement (actor);
     }
     else if (element is UML.UseCase)
     {
         UMLUseCase ucase = new UMLUseCase (this, node);
         _canvas.AddElement (ucase);
     }
     else
     {
         base.DrawElement (node);
     }
 }
 protected override void DrawElement(DI.GraphEdge edge)
 {
     Uml2SemanticModelBridge bridge = edge.SemanticModel as Uml2SemanticModelBridge;
     UML.Element umlElement = bridge.Element;
     if (umlElement is UML.Association)
     {
         UMLAssociation association = new UMLAssociation (this, edge);
         _canvas.AddElement (association);
     }
     else if (umlElement is UML.Generalization)
     {
         UMLGeneralization generalization = new UMLGeneralization (this, edge);
         _canvas.AddElement (generalization);
     }
     else
     {
         base.DrawElement(edge);
     }
 }
Exemple #17
0
 public UMLUseCase(UMLDiagram ownerDiagram, DI.GraphNode graphNode)
     : base(ownerDiagram, graphNode)
 {
     _circle = new CanvasEllipse (ChildrensRoot);
     _circle.X1 = _circle.Y1 = 0;
     _circle.X2 = Width;
     _circle.Y2 = Height;
     _circle.FillColor = DEFAULT_FILL_COLOR;
     _circle.OutlineColor = DEFAULT_OUTLINE_COLOR;
     //
     Width = GraphNode.Size.Width;
     Height = GraphNode.Size.Height;
     //
     Uml2SemanticModelBridge bridge = (Uml2SemanticModelBridge) GraphNode.SemanticModel;
     _modelElement = (UML.UseCase) bridge.Element;
     DI.GraphElement nestedDiagElem;
     DI.SimpleSemanticModelElement nestedBridge;
     //
     foreach (DI.DiagramElement elem in GraphNode.Contained)
     {
         nestedDiagElem = elem as DI.GraphElement;
         if (nestedDiagElem != null)
         {
             nestedBridge = nestedDiagElem.SemanticModel as DI.SimpleSemanticModelElement;
             System.Console.WriteLine ("UMLUseCase nestedBridge.TypeInfo "+nestedBridge.TypeInfo);
             if (nestedBridge.TypeInfo == "NameCompartment")
             {
                 // widget for the property Name
                 string fontModifier = (_modelElement.IsAbstract ? "italic" : "");
                 _name = new UMLEntry (this, (DI.GraphNode)nestedDiagElem, ChildrensRoot, false, _modelElement.Name, fontModifier);
                 _name.Show();
                 break;
             }
         }
     }
     _circle.X1 = _circle.Y1 = 0;
     _circle.X2 = Width;
     _circle.Y2 = Height;
     Redraw ();
 }
Exemple #18
0
 internal UMLElement GetUmlcanvasElement(DI.GraphElement diElement)
 {
     return (UMLElement)_di2umlcanvas [diElement];
 }
 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;
 }
 // sets its position to the point passed as argument,
 // and the position of all the nested elements to (0,0)
 public void SetPosition(DI.Point pos)
 {
     pos.CopyTo (_graphNode.Position);
     _multiplicity.X = pos.X;
     _multiplicity.Y = pos.Y + 10;
     _name.X = pos.X;
     _name.Y = pos.Y - 20;
 }
 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 #22
0
 // Constructor with default font
 private UMLDiagram(DI.Diagram diagram, string font, string size)
     : this(diagram)
 {
     DefaultFontName = font;
     DefaultFontSize = size;
 }
Exemple #23
0
 private void CreateToolbar(DI.Diagram diagram, Uml2.UMLDiagram uDiagram)
 {
     TBar.ToolbarBase tbar = null;
     string diagramType = ((DI.SimpleSemanticModelElement) diagram.SemanticModel).TypeInfo.ToLower ();
     switch (diagramType)
     {
         case "classdiagram":
             tbar = new TBar.ToolbarClass (uDiagram);
             break;
         case "usecasediagram":
             tbar = new TBar.ToolbarUseCase (uDiagram);
             break;
         default:
             System.Console.WriteLine ("Unexpected diagram type.");
             break;
     }
     tbar.ButtonGrid.Toggled += OnGridToggled;
     _toolbarsKey.Add (diagram, tbar);
     _canvasArea.PackStart (tbar, false, false, 0);
 }
Exemple #24
0
 // Shows a diagram at the NoteBook
 public void ShowDiagram(DI.Diagram diagram)
 {
     bool created = false;
     if (!_diagramsKey.Contains (diagram))
     {
         _diagramsKey.Add (diagram);
         Uml2.UMLDiagram uDiagram = Uml2.UMLDiagram.CreateFor (diagram, this);
         AppendPage (uDiagram.UMLCanvas, new NoteBookLabel (this, diagram));
         CreateToolbar (diagram, uDiagram);
         created = true;
     }
     for (int nbpages = 0; nbpages < NPages; nbpages++)
     {
         Uml2.UMLCanvas canvas = (Uml2.UMLCanvas) GetNthPage (nbpages);
         if (canvas.Diagram.DIDiagram == diagram)
         {
             Page = nbpages;
             if (created == false)
             {
                 SetCurrentCanvas (canvas.Diagram.DIDiagram, canvas);
             }
             break;
         }
     }
 }
Exemple #25
0
 public void RemoveDiagram(DI.Diagram diagram)
 {
     if (_diagramsKey.Contains(diagram))
     {
         for (int nbpages = 0; nbpages < NPages; nbpages++)
         {
             Uml2.UMLCanvas canvas = (Uml2.UMLCanvas) GetNthPage (nbpages);
             if (canvas.Diagram.DIDiagram == diagram)
             {
                 RemovePage(nbpages);
                 canvas.Destroy ();
                 break;
             }
         }
         if (NPages == 0)
         {
             _canvasArea.Remove ((TBar.ToolbarBase) _toolbarsKey [diagram]);
         }
         _diagramsKey.Remove (diagram);
         _toolbarsKey.Remove (diagram);
     }
 }
Exemple #26
0
 // Draws the given node.
 // Derived classes are supposed to try to draw the given node,
 // and if they fail, call this default implementation.
 protected virtual void DrawElement(DI.GraphNode node)
 {
     Uml2SemanticModelBridge bridge = node.SemanticModel as Uml2SemanticModelBridge;
     UML.Element element = bridge.Element;
     // if the element is any kind of classifier, represent it as an UMLClassifier.
     UML.Classifier classifier = element as UML.Classifier;
     if (classifier != null)
     {
         System.Console.WriteLine ("UMLDiagram.DrawElement> Adding a generic UMLClassifier to the canvas for element: " + element.ToString());
         UMLClassifier umlClassifier = new UMLClassifier (this, node);
         _canvas.AddElement (umlClassifier);
     }
 }
Exemple #27
0
 public void UpdateDiagramName(DI.Diagram diagram)
 {
     System.Console.WriteLine ("New name: "+diagram.Name);
     if (_diagramsKey.Contains (diagram))
     {
         for (int nbpages = 0; nbpages < NPages; nbpages++)
         {
             Uml2.UMLCanvas canvas = (Uml2.UMLCanvas) GetNthPage (nbpages);
             if (canvas.Diagram.DIDiagram == diagram)
             {
                 NoteBookLabel label = (NoteBookLabel) GetTabLabel (canvas);
                 if (label != null)
                 {
                     label.Label = diagram.Name;
                 }
                 else
                 {
                     System.Console.WriteLine ("NoteBookLabel: Not found!!");
                 }
                 break;
             }
         }
     }
     else
     {
         System.Console.WriteLine ("UpdateDiagramName ERROR: diagram not found");
     }
     //_diagramsKey.Add (diagram);
 }
Exemple #28
0
 // Draws the given edge.
 // Derived classes are supposed to try to draw the given edge,
 // and if they fail, call this default implementation.
 protected virtual void DrawElement(DI.GraphEdge edge)
 {
     Uml2SemanticModelBridge bridge = edge.SemanticModel as Uml2SemanticModelBridge;
     UML.Element umlElement = bridge.Element;
     // if the element is any kind of binary relationship, represent
     // it as an edge.
     UML.Relationship umlRelation = umlElement as UML.Relationship;
     if (umlRelation != null && umlRelation.RelatedElement.Count == 2)
     {
         System.Console.WriteLine ("UMLDiagram.DrawElement> Adding a generic UMLEdge to the canvas for element: " + umlElement.ToString());
         UMLStereotypedEdge umlEdge = new UMLStereotypedEdge (this, edge);
         _canvas.AddElement (umlEdge);
     }
 }
Exemple #29
0
 private void SetCurrentCanvas(DI.Diagram diagram, Uml2.UMLCanvas canvas)
 {
     TBar.ToolbarBase tbar = (TBar.ToolbarBase) _toolbarsKey [diagram];
     if (tbar != null)
     {
         _canvasArea.PackStart (tbar, false, false, 0);
         ((TBar.ToolbarBase)tbar).Grid = canvas.Grid;
     }
 }
Exemple #30
0
 protected UMLDiagram(DI.Diagram diagram, Widgets.NoteBook notebook)
     : this(diagram)
 {
     _canvas.NoteBook = notebook;
 }