Package madkit.gui

Class ConsoleAgent

All Implemented Interfaces:
Comparable<AbstractAgent>

public class ConsoleAgent extends AbstractAgent
This agent displays standard out and err prints in its GUI. This agent is useful when the application is not launched from a command line or an IDE so that the console is not directly visible.
Since:
MaDKit 5.0.0.14
Version:
0.91
Author:
Fabien Michel
  • Constructor Details

    • ConsoleAgent

      public ConsoleAgent()
  • Method Details

    • setupFrame

      public void setupFrame(AgentFrame frame)
      Description copied from class: AbstractAgent
      Called when the default GUI mechanism is used upon agent creation. This provides an empty frame which will be used as GUI for the agent. The life cycle of the frame is automatically managed: The frame is disposed when the agent is terminated. Some menus are available by default. Default code is only one line: frame.setContentPane(new OutputPanel(this));. Default settings for the frame are:
      Overrides:
      setupFrame in class AbstractAgent
      Parameters:
      frame - the default frame which has been created by MaDKit for this agent.
      See Also:
    • end

      protected void end()
      Description copied from class: AbstractAgent
      This method corresponds to the last behavior which is called by the MaDKit kernel. This call occurs when a threaded agent normally exits its live method or when the agent is killed. Usually a good place to release taken resources or log what has to be logged. It has to be noted that the kernel automatically takes care of removing the agent from the organizations it is in. However, this cleaning is not logged by the agent. Therefore it could be of interest for the agent to do that itself.

      Here is a typical example:

       @Override
       protected void end()
       {
              AbstractAgent.ReturnCode returnCode = leaveRole("a community", "a group", "my role");
              if (returnCode == AbstractAgent.ReturnCode.SUCCESS){
                      if(logger != null)
                              logger.info("I am leaving the artificial society");
              }
              else{
                      if(logger != null)
                              logger.warning("something wrong when ending, return code is "+returnCode);
              }
              if(logger != null)
                      logger.info("I am done");
              }
       }
       
      Overrides:
      end in class AbstractAgent