public void PostStep(Agent agent, Model model) { Agent.AgentID id = model.getSimulation().getViewableAgent(); /* only update the selected agent or all agents if selected */ Node currentNode = model.getMap().getNodeAtLocation(agent.getNode(Agent.NodeType.Current).getPosition()); Color backColor = agent.getColor(Agent.ColorType.BackColor); Color foreColor = agent.getColor(Agent.ColorType.ForeColor); if (currentNode.isEqual(agent.getNode(Agent.NodeType.Finish))) currentNode.repaintNode(backColor, foreColor, "F"); else { if (model.getSimulation().getVisualizations() == View.Visualizations.Enabled) currentNode.repaintNode(backColor, foreColor, currentNode.Text); else currentNode.repaintNode(backColor, foreColor, ""); } if (agent.getNode(Agent.NodeType.Current).getParent() != null) { Node parentNode = model.getMap().getNodeAtLocation(agent.getNode(Agent.NodeType.Current).getParent().getPosition()); if (model.getSimulation().getPersistenceEnabled() == View.PathPersistence.Disabled | !agent.isActive()) { if (model.isSpecialNode(parentNode)) { Agent specialAgent = model.getSpecialNodeAgent(parentNode); backColor = specialAgent.getColor(Agent.ColorType.BackColor); foreColor = specialAgent.getColor(Agent.ColorType.ForeColor); parentNode.repaintNode(backColor, foreColor, ""); } else { if (agent.isActive()) if (parentNode.getFlag(Node.Flag.IsWalkable)) parentNode.repaintNode(Color.White, Color.White, ""); else parentNode.repaintNode(Color.Gray, Color.Gray, ""); else { /* is node visible on active agent's map */ Agent viewAgent = model.getAgent(model.getSimulation().getViewableAgent()); bool isVisibleOnActiveAgentsMap = viewAgent.getMap().isNodeFlag(parentNode, Node.Flag.IsVisible); if (isVisibleOnActiveAgentsMap) { /* is node special */ bool isSpecial = viewAgent.getMap().isNodeFlag(parentNode, Node.Flag.IsSpecial); if (isSpecial) { if (parentNode.isEqual(viewAgent.getNode(Agent.NodeType.Start))) parentNode.repaintNode(viewAgent.getColor(Agent.ColorType.BackColor), viewAgent.getColor(Agent.ColorType.ForeColor), "S"); else parentNode.repaintNode(viewAgent.getColor(Agent.ColorType.BackColor), viewAgent.getColor(Agent.ColorType.ForeColor), "F"); } else { /* is node walkable on active agent's map */ bool isWalkable = viewAgent.getMap().isNodeFlag(parentNode, Node.Flag.IsWalkable); if (isWalkable) { bool isPathNode = viewAgent.getMap().isNodeFlag(parentNode,Node.Flag.IsPath); if (isPathNode) { if (model.getSimulation().getPersistenceEnabled() == View.PathPersistence.Enabled) { /* non active agent's parent node is also the active agent's path node */ Color b = viewAgent.getColor(Agent.ColorType.BackColor); Color f = viewAgent.getColor(Agent.ColorType.ForeColor); parentNode.repaintNode(b, f, ""); } else { /* non active agent's walkable path node with persistence disabled */ parentNode.repaintNode(Color.White, Color.White, ""); } } else { /* non active agent's parent node is just a visible walkable node */ parentNode.repaintNode(Color.White, Color.White, ""); } } else { /* non active agent's parent node is just a visible non-walkable node */ parentNode.repaintNode(Color.Gray, Color.Gray, ""); } } } else { /* node is not visible on active agent's map therefore we can just paint it black */ parentNode.repaintNode(Color.Black, Color.Black, ""); } } } } } }
protected bool visualizationPaintOK(Node node, Agent agent, Model model) { bool isActive = agent.isActive(); View.Visualizations visualizations = model.getSimulation().getVisualizations(); bool notSpecial = !model.isSpecialNode(node); bool notPath = !model.isPathNode(node); if (isActive && visualizations == View.Visualizations.Enabled && notSpecial && notPath) return true; else return false; }