⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tutorial2.java

📁 MASON代表多主体邻里或网络仿真(Multi-Agent Simulator of Neighborhoods or Networks)。它是乔治梅森大学用Java开发的离散事件多主体仿真核心库
💻 JAVA
字号:
package sim.app.tutorial1and2;import sim.engine.*;import sim.display.*;import sim.portrayal.grid.*;import java.awt.*;import javax.swing.*;public class Tutorial2 extends GUIState    {    public Display2D display;    public JFrame displayFrame;    public Tutorial2() { super(new Tutorial1(System.currentTimeMillis())); }        public Tutorial2(SimState state) { super(state); }        public String getName() { return "Conway's Game of Life"; }        public String getInfo()        {        return             "<H2>Conway's Game of Life</H2>" +            "<p>... with a B-Heptomino";         }        FastValueGridPortrayal2D gridPortrayal = new FastValueGridPortrayal2D();    public void setupPortrayals()        {        // tell the portrayals what to portray and how to portray them        gridPortrayal.setField(((Tutorial1)state).grid);        gridPortrayal.setMap(            new sim.util.gui.SimpleColorMap(                new Color[] {new Color(0,0,0,0), Color.blue}));        }        public void start()        {        super.start();              setupPortrayals();  // set up our portrayals        display.reset();    // reschedule the displayer        display.repaint();  // redraw the display        }        public void init(Controller c)        {        super.init(c);                // Make the Display2D.  We'll have it display stuff later.        Tutorial1 tut = (Tutorial1)state;        display = new Display2D(tut.gridWidth * 4, tut.gridHeight * 4,this,1);        displayFrame = display.createFrame();        c.registerFrame(displayFrame);   // register the frame so it appears in the "Display" list        displayFrame.setVisible(true);        // attach the portrayals        display.attach(gridPortrayal,"Life");        // specify the backdrop color  -- what gets painted behind the displays        display.setBackdrop(Color.black);        }    public static void main(String[] args)        {        Tutorial2 tutorial2 = new Tutorial2();        Console c = new Console(tutorial2);        c.setVisible(true);        }        public void load(SimState state)        {        super.load(state);        setupPortrayals();  // we now have new grids.  Set up the portrayals to reflect this        display.reset();    // reschedule the displayer        display.repaint();  // redraw the display        }            }                    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -