public UmlDiagramDependenceRelation( UmlRelation umlRelation, UmlDiagramClass startUmlDiagramClass, UmlDiagramClass endUmlDiagramClass ) : base(umlRelation, startUmlDiagramClass, endUmlDiagramClass) { }
public UmlDiagramRelation(UmlRelation umlRelation, UmlDiagramClass startUmlDiagramClass, UmlDiagramClass endUmlDiagramClass) : base(startUmlDiagramClass, endUmlDiagramClass) { Relation = umlRelation; IsVisible = true; }
private UmlRelation Aggregation(Type owner, Type component, UmlArrowDirections?direction = null, string label = null, string ownerLabel = null, string componentLabel = null) { var isManyComponent = componentLabel == "0..n"; if (isManyComponent) { componentLabel = null; } var rel = new UmlRelation { Left = new UmlRelationEnd(GetTypeName(owner), ownerLabel), Right = new UmlRelationEnd(GetTypeName(component), componentLabel), Arrow = isManyComponent ? UmlRelationArrow.AggregationLeftMany : UmlRelationArrow.AggregationLeft, Label = label }; if (direction != null) { rel.Arrow = rel.Arrow.With(direction.Value); } return(rel); }
public UmlDiagramImplementsInterfaceRelation( UmlRelation umlRelation, UmlDiagramClass startUmlDiagramClass, UmlDiagramClass endUmlDiagramClass ) : base(umlRelation, startUmlDiagramClass, endUmlDiagramClass) { }
public void NewRelation(UmlRelation rel) { GuiClass c1 = FindClass(rel.src), c2 = FindClass(rel.dest); if (c1 != null && c2 != null) { int ux1 = 1, ux2 = 3; float uy1 = .5f, uy2 = .5f; if (rel.type == UmlRelationType.Association) { ux1 = 0; uy1 = c1.get_empty_point_on_edge(ux1); ux2 = 2; uy2 = c2.get_empty_point_on_edge(ux2); } else if (rel.type == UmlRelationType.Realization || rel.type == UmlRelationType.Inheritance) { uy2 = c2.get_empty_point_on_edge(ux2); } GuiConnection c = new GuiConnection(new GuiConnectionPoint(c1, ux1, uy1, 0), new GuiConnectionPoint(c2, ux2, uy2, 1), rel.type, this, rel.type == UmlRelationType.Attachment ? GuiConnectionStyle.Line : MouseAgent.conn_style); if (rel.type == UmlRelationType.Association) { c.nav = GuiConnectionNavigation.Left; } c.relation_id = rel.ID; c.first.UpdatePosition(true); c.second.UpdatePosition(true); c.DoCreationFixup(); c.ConnectionCreated(this, rel.src_role, rel.dest_role, rel.name, rel.stereo); Undo.Push(new CreateOperation(c), false); } }
public UmlDiagramAssociationRelation( UmlRelation umlRelation, UmlDiagramClass startUmlDiagramClass, UmlDiagramClass endUmlDiagramClass ) : base(umlRelation, startUmlDiagramClass, endUmlDiagramClass) { PreferredAngles = new double[] { }; }
public UmlDiagramInheritanceRelation( UmlRelation umlRelation, UmlDiagramClass startUmlDiagramClass, UmlDiagramClass endUmlDiagramClass ) : base(umlRelation, startUmlDiagramClass, endUmlDiagramClass) { PreferredAngles = new double[] { 90 }; }
private Shape GetUmlAssociation(DiagramRelationElement associationElement) { var association = new UmlRelation(); var data = new UmlAssociationData(); data.Owner = associationElement; data.DiagramData = this; association.DataSource = data; return(association); }
private UmlRelation Inherits(Type baseClass, Type subClass) { var rel = new UmlRelation { Left = new UmlRelationEnd(GetTypeName(subClass)), Right = new UmlRelationEnd(GetTypeName(baseClass)), Arrow = UmlRelationArrow.InheritRight }; return(rel); }
public UmlRelation CreateModelRelation( RelationType relationType, UmlClass startClass, UmlClass endClass, bool oneToN, string name = null ) { UmlRelation umlRelation = null; switch (relationType) { case RelationType.Inheritance: umlRelation = Model.GetOrCreateInheritanceRelation(true, startClass, endClass); break; case RelationType.ImplementsInterface: umlRelation = Model.GetOrCreateImplementsInterfaceRelation(true, startClass, endClass); break; case RelationType.Aggregation: umlRelation = Model.GetOrCreateAggregationRelation(true, startClass, endClass, name); umlRelation.StartMultiplicity = oneToN ? "N" : "1"; break; case RelationType.Composition: umlRelation = Model.GetOrCreateCompositionRelation(true, startClass, endClass, name); umlRelation.StartMultiplicity = oneToN ? "N" : "1"; break; case RelationType.Association: umlRelation = Model.GetOrCreateAssociationRelation(true, startClass, endClass, name); umlRelation.EndMultiplicity = oneToN ? "N" : "1"; break; case RelationType.Dependence: umlRelation = Model.GetOrCreateDependenceRelation(true, startClass, endClass, name); umlRelation.EndMultiplicity = oneToN ? "N" : "1"; break; } if (umlRelation != null) { // // Exception for now: immediately create the relation in the diagram too. This should happen via an event from the model, // but for now, we do it directly. // //AddRelationFromModel(umlRelation); } return(umlRelation); }
protected override void VisitInternal(UmlDiagram diagram, UmlEntity info, UmlAddRelationAttribute att) { var rel = new UmlRelation { Left = new UmlRelationEnd(diagram.GetTypeName(info.Type)), Right = new UmlRelationEnd(diagram.GetTypeName(att.RelatedType)), Arrow = UmlRelationArrow.MkArrow(att, att.Multiple), Label = att.Name } .WitCreatorMeta <UmlAddRelationAttributeVisitor>(info.Type, att.RelatedType) .WithNote(att); rel.Tag = att.Tag; diagram.Relations.Add(rel); if (att.ForceAddToDiagram) { diagram.UpdateTypeInfo(att.RelatedType, null); } }
public UmlDiagramRelation AddRelationFromModel(UmlRelation umlRelation) { var startUmlDiagramClass = Classes.FirstOrDefault(c => c.Class == umlRelation.StartClass); var endUmlDiagramClass = Classes.FirstOrDefault(c => c.Class == umlRelation.EndClass); UmlDiagramRelation umlDiagramRelation = null; if (umlRelation is UmlDependenceRelation) { umlDiagramRelation = new UmlDiagramDependenceRelation(umlRelation, startUmlDiagramClass, endUmlDiagramClass); } else if (umlRelation is UmlAssociationRelation) { umlDiagramRelation = new UmlDiagramAssociationRelation(umlRelation, startUmlDiagramClass, endUmlDiagramClass); } else if (umlRelation is UmlImplementsInterfaceRelation) { umlDiagramRelation = new UmlDiagramImplementsInterfaceRelation(umlRelation, startUmlDiagramClass, endUmlDiagramClass); } else if (umlRelation is UmlInheritanceRelation) { umlDiagramRelation = new UmlDiagramInheritanceRelation(umlRelation, startUmlDiagramClass, endUmlDiagramClass); } else if (umlRelation is UmlCompositionRelation) { umlDiagramRelation = new UmlDiagramCompositionRelation(umlRelation, startUmlDiagramClass, endUmlDiagramClass); } else if (umlRelation is UmlAggregationRelation) { umlDiagramRelation = new UmlDiagramAggregationRelation(umlRelation, startUmlDiagramClass, endUmlDiagramClass); } if (umlDiagramRelation != null && startUmlDiagramClass != null && endUmlDiagramClass != null) { modelToDiagramRelations[umlRelation] = umlDiagramRelation; AddRelation(umlDiagramRelation); startUmlDiagramClass.AddRelation(umlDiagramRelation); endUmlDiagramClass.AddRelation(umlDiagramRelation); } UpdateBendingOffsets(endUmlDiagramClass, startUmlDiagramClass); return(umlDiagramRelation); }
public void AdjustRelation(UmlRelation rel) { Invalidate(); invalidate_children(); if (rel.src_role != null) { first.role.Text = rel.src_role; } if (rel.dest_role != null) { second.role.Text = rel.dest_role; } if (rel.name != null) { conn_name.Text = rel.name; } if (rel.stereo != null) { conn_stereo.Text = rel.stereo; } type = rel.type; invalidate_children(); Invalidate(); }
private IEnumerable <Type> AddTypeToGraph(PlantUmlResult rr, Type t, List <UmlRelation> relations, HashSet <Type> processed) { var result = new List <Type>(); if (!_types.TryGetValue(t, out var info)) { return(result); } if (!processed.Add(t)) { return(result); } var cf = rr.Classes; cf.Open(GetClassOpen(t)); foreach (var pi in t.GetProperties(BindingFlags.Instance | BindingFlags.Public)) { if (SkipDrawing(t, pi.DeclaringType)) { continue; } var att = pi.GetCustomAttribute <UmlRelationAttribute>(); var kind = att?.Kind ?? UmlRelationKind.AggregationWithArrow; var rel = FindRelation(pi.PropertyType, kind, att, pi.Name, t); if (rel != null) { relations.Add(rel); result.Add(pi.PropertyType); continue; } cf.Writeln(GetTypeName(pi.PropertyType) + " " + pi.Name); } foreach (var mi in t.GetMethods(BindingFlags.Instance | BindingFlags.Public)) { if (mi.IsSpecialName) { continue; } if (mi.DeclaringType == typeof(object)) { continue; } if (SkipDrawing(t, mi.DeclaringType)) { continue; } cf.Writeln(MethodToUml(mi)); var att = mi.GetCustomAttribute <UmlRelationAttribute>(); if (att != null) { var kind = att.Kind; var rel = FindRelation(mi.ReturnType, kind, att, mi.Name + "() >", t); if (rel != null) { var a = rel.Arrow; a.Dotted = true; rel.Arrow = a; relations.Add(rel); result.Add(mi.ReturnType); } } } foreach (var i in t.GetCustomAttributes <UmlAddRelationAttribute>()) { var rel = new UmlRelation { Left = new UmlRelationEnd(GetTypeName(t)), Right = new UmlRelationEnd(GetTypeName(i.RelatedType)), Arrow = UmlRelationArrow.GetRelationByKind(i.Kind), Label = i.Name, Note = i.Note, NoteColor = i.NoteColor }; relations.Add(rel); } cf.Close(); foreach (var i in t.GetCustomAttributes <UmlNoteAttribute>()) { // cf.Writeln("-- note --"); cf.Writeln("note bottom of " + GetTypeName(t)); foreach (var line in i.Text.Split('\n', '\r')) { if (!string.IsNullOrEmpty(line)) { cf.Writeln(line); } } cf.Writeln("end note"); } if (t.BaseType != null && _types.ContainsKey(t.BaseType)) { relations.Add(Inherits(t.BaseType, t).With(UmlArrowDirections.Up)); } foreach (var i in t.GetInterfaces()) { if (_types.ContainsKey(i)) { relations.Add(Inherits(i, t).With(UmlArrowDirections.Up)); } } return(result); }
private UmlDiagramRelation GetDiagramRelation(UmlRelation umlRelation) { return(modelToDiagramRelations.ContainsKey(umlRelation) ? modelToDiagramRelations[umlRelation] : null); }