Swarm程序分析StartHeatbugs程序

来源:互联网 发布:手游服务端源码 编辑:程序博客网 时间:2024/05/01 13:28

// Java Heatbugs application. Copyright � 1999-2000 Swarm Development Group.
// This library is distributed without any warranty; without even the
// implied warranty of merchantability or fitness for a particular
// purpose.  See file COPYING for details and terms of copying.

import swarm.Globals;

public class StartHeatbugs {
    /** The main() function is the top-level place where everything
        starts.  For a typical Swarm simulation, in main() you create
        a toplevel Swarm, let it build and activate, and set it to
        running. 
        main()是顶级函数,必须由此进入,开始程序的运行。对于一个典型的Swarm仿真,在main()函数里你创建
        一个toplevel Swarm对象,让他构建并激活,并且设置他运行。
    */
    public static void main (String[] args) {
        /* Swarm initialization: all Swarm apps must call this first.
     Swarm全局环境变量初始化,所有的Swarm应用程序必须在进入main方法里第一调用的。
     在这个过程中声明了SimpleBug 用到的随机生成函数*/
        Globals.env.initSwarm ("JHeatbugs", "2.1", "bug-swarm@swarm.org", args);
       
        /* swarmGUIMode is set in initSwarm(). It's set to be `false'
        swarmGUIMode(swarm图形用户接口模型) 是设置在initSwarm()中初始化的。它默认设置成‘false’
         if you typed `heatbugs --batchmode' or `heatbugs -b'. Otherwise, it's set to `true'.
         如果你的类型是'heatbugs --batchmode' or `heatbugs -b'.除此之外,它设置成‘true’*/

        if (Globals.env.guiFlag) {
            /* We've got graphics, so make a full ObserverSwarm to get GUI objects
         我们已经获得图像,同样生成所有的ObserverSwarm到获得的GUI 对象中。*/
         
            HeatbugObserverSwarm topLevelSwarm =  new HeatbugObserverSwarm (Globals.env.globalZone);
            Globals.env.setWindowGeometryRecordName (topLevelSwarm, "topLevelSwarm");
           
            topLevelSwarm.buildObjects ();
            topLevelSwarm.buildActions ();
            topLevelSwarm.activateIn (null);
            topLevelSwarm.go ();
            topLevelSwarm.drop ();
        }
        else {
        HeatbugBatchSwarm topLevelSwarm =
            (HeatbugBatchSwarm) Globals.env.lispAppArchiver.getWithZone$key(Globals.env.globalZone, "batchSwarm");
            topLevelSwarm.buildObjects ();
            topLevelSwarm.buildActions ();
            topLevelSwarm.activateIn (null);
            topLevelSwarm.go ();
            topLevelSwarm.drop ();
        }
    }
}

在官网上的API,没有参数注释。希望网友们可以一起找到,并完善一下。