protected void Render(GoalAgentAssignment assignment, bool createAgentShapes = false) { var circle = GetCircle(); Add(assignment.Identifier, circle); if (shapes.ContainsKey(assignment.GoalIdentifier)) { var parentGraphic = shapes[assignment.GoalIdentifier].First(); var topArrow = GetFilledArrow(circle, parentGraphic); sheet.GraphicsList.Add(topArrow); } foreach (var child in assignment.AgentIdentifiers) { Graphic childGraphic; if (!createAgentShapes) { if (!shapes.ContainsKey(child)) { continue; } childGraphic = shapes [child].First(); } else { childGraphic = Render(assignment.model.Agents().Single(x => x.Identifier == child)); } var line = GetLine(childGraphic, circle); sheet.GraphicsList.Add(line); } }
public void Add(GoalAgentAssignment assignment) { if (Agents.ContainsKey(assignment.Identifier)) { throw new ArgumentException(string.Format("Agent assignment identifier already exist: {0}", assignment.Identifier)); } GoalAgentAssignments.Add(assignment.Identifier, assignment); }
public override void Handle(Goal element, ParsedAssignedToAttribute attribute, KAOSModel model) { var assignment = new GoalAgentAssignment(model); assignment.GoalIdentifier = element.Identifier; foreach (var child in attribute.Values) { if (child is IdentifierExpression) { var identifier = ((IdentifierExpression)child).Value; Agent agent; if ((agent = model.agentRepository.GetAgent(identifier)) == null) { agent = new Agent(model, identifier) { Implicit = true }; model.agentRepository.Add(agent); } assignment.Add(agent); } else { throw new NotImplementedException(string.Format("'{0}' is not supported in '{1}' on '{2}'. ({3},{4})", child.GetType().Name, attribute.GetType().Name, element.GetType().Name, attribute.Line, attribute.Col)); } } if (!assignment.IsEmpty) { model.Add(assignment); } }