private Connection newConnection() {
   Connection c = checkConnectionDuplicity();
   if (c == null) {
     c = new Connection(currentWorld.getWorld(), address, port, netCode);
     connections.add(c);
     c.addConnectionListener(this);
   } else return null;
   return c;
 }
 public Connection newConnection(InetAddress remoteAddress, int remotePort) {
   address = remoteAddress;
   port = remotePort;
   Connection c = checkConnectionDuplicity();
   if (c == null) {
     c = new Connection(currentWorld.getWorld(), remoteAddress, remotePort);
     connections.add(c);
     c.addConnectionListener(this);
   } else return null;
   return c;
 }
  /**
   * Starts the program, creating the main objects.
   *
   * @return A reference to the application's MainWindow.
   */
  public MainWindow start() {
    ActionFactory actionFactory;

    // create the main objects and link them together
    process = new biogenesis.Process();
    currentWorld = new CurrentWorld(new World(new STOrganismFactory()));
    mainWindow = new MainWindow(currentWorld, process);
    visibleWorld = new VisibleWorld(mainWindow, currentWorld);
    mainWindow.setIconImage(imageIcon.getImage());
    currentWorld.getWorld().genesis();
    netServer = new NetServerThread(currentWorld);
    currentWorld.addListener(netServer);
    // sets net server
    if (Utils.ACCEPT_CONNECTIONS) {
      netServer.setAcceptConnections(true);
      netServer.startServer();
    }
    // sets listeners
    netServer.addStatusListener(mainWindow.getStatusBar());
    process.addTimeListener(mainWindow);
    process.addTimeListener(currentWorld);
    // starts timer
    process.startLifeProcess(Utils.DELAY);
    // initialize actions
    ActionFactory.init(mainWindow, process, currentWorld, visibleWorld, netServer);
    actionFactory = ActionFactory.getInstance();
    // set specific actions as listeners
    mainWindow.addWindowListener(actionFactory.getQuitAction());
    mainWindow.getOrganismTracker().addObserver(actionFactory.getAbortTrackingAction());
    process.addPauseListener(actionFactory.getStartStopAction());
    // create menu bars
    initToolBar();
    mainWindow.setJMenuBar(new MainMenu());

    return mainWindow;
  }
  @Override
  public void update(Connection c) {
    int state = c.getState();
    World w = currentWorld.getWorld();

    if (state == Connection.STATE_DISCONNECTED) {
      notifyStatusListeners(
          Messages.getInstance()
              .getString("T_CONNECTION_LOST", c.getRemoteAddress().toString())); // $NON-NLS-1$
      w.removeAgent(c.getInCorridor());
      w.removeAgent(c.getOutCorridor());
      removeConnection(c);
    } else if (state == Connection.STATE_CONNECTED) {
      w.addAgent(c.getInCorridor(), null);
      w.addAgent(c.getOutCorridor(), null);
      notifyStatusListeners(
          Messages.getInstance()
              .getString(
                  "T_CONNECTION_STABLISHED", c.getRemoteAddress().toString())); // $NON-NLS-1$
    }
  }
 @Override
 public void actionPerformed(ActionEvent e) {
   currentWorld.getWorld().getAtmosphere().addCO2(500);
 }