📄 mbshelp.html
字号:
<h4>Adding fish to, and removing them from, an environment:</h4><p>When you are creating or editing an environment, a new panel appears with two pull-down menus. The first allows you to choose the type of the next fish to add to the environment. The second allows you to choose the next fish's color.<UL> <LI>Choose the desired fish type. (This is only necessary once you introduce additional fish types in Chapter 4 — see "<a href="#Advanced">Customizing the graphical user interface</a>" below.) <LI>Choose the desired fish color. There are a number of colors available, or you can choose "Other ..." to specify your own colors. Every fish you add to the environment will be of that color until you choose a different color from the pull-down menu. If you choose "Random," then every fish you add will be a different, randomly-chosen color. <LI>Click in an empty cell in the grid to add a fish to that location.<LI>Click on a fish to rotate it to a new direction. <LI>Rotating a fish all the way around will remove it from the environment. </UL><p> After you create or edit an environment, you may wish to <a href="#Save">Save</a> it to a configuration file. You can <a href="#Step">run the simulation</a> on the new or modified environment by clicking on the Step or Run buttons, at which time the extra panel for creating new fish will disappear.</p><p><a href="#Top">(Go to top of help file.)</a></p><h3><a name="Seed"></a>Seeding the random number generator</h3> <p>You can set a seed for the random number generator when opening or creating new environments. If you use the same seed for several simulation runs, starting with the same initial configuration, the fish in the simulation will exhibit the same behavior each time.</p><UL> <LI><b>To run the simulation without seeding the random number generator,</b> select "Don't reset seed" from the Seed menu. This is the default behavior when the program starts. <LI><b>To run the simulation with a specific seed,</b> select "Use fixed seed..." from the Seed menu, and then enter the seed value in the dialog box that comes up. Once you have chosen a seed, it will be used to seed the random number generator every time you open an initial configuration file or create a new environment (until you choose another alternative from the Seed menu). If you open or create the same environment several times using the same seed, the fish behavior will be the same each time. <LI><b>To run the simulation with different seed values for each run,</b> select "Prompt for seed" from the Seed menu. When this alternative is selected, you will be prompted for a seed value every time you open a configuration file or create a new environment.</UL><p><a href="#Top">(Go to top of help file.)</a></p><h3><a name="View"></a>Viewing large environments</h3><p>The environment display adjusts the size of the grid cells depending on the number of cells in the grid. The cells in a grid with very few cells will be quite large, whereas the cells in a grid with many cells will be much smaller. If, however, the cells would be too small to show fish clearly, then the graphical user interface displays only part of the environment and provides scroll bars for viewing other parts of the environment. There are also several options in the View menu for viewing large environments.</p><UL> <LI>Choose "Zoom in" from the View menu to view a smaller section of the environment in greater detail. Since the smaller section has fewer cells, each cell will be drawn larger. <LI>Choose "Zoom out" from the View menu to view a larger section of the environment. Since the larger section has more cells, the cells will be smaller. <LI>Choose "Bring (0, 0) to upper left" from the View menu if you have scrolled around the environment and want to pan quickly back to location (0, 0). This option will shift the display back to its original orientation, with location (0, 0) in the upper-left corner of the display. If the environment is bounded, this action is the same as scrolling all the way up and all the way to the left. If the environment is unbounded, this action will bring the scroll bars to the center.</UL><p><a href="#Top">(Go to top of help file.</a>)</p><h3><a name="Advanced"></a>Customizing the graphical user interface</h3> <p>You can customize the MBS graphical user interface in several ways. (These are advanced features of the graphical user interface.)</p><UL> <LI><b>Changing the way fish are displayed:</b> Edit the <code>main</code> method in the <code>MBSGUI</code> class and look for the statement that associates a <code>FishDisplay</code> object with the <code>Fish</code> class in the display map. There are several other commented-out statements that illustrate how to associate a different display object (such as a <code>RoundFishDisplay</code> or a <code>FishImageDisplay</code> object) with a particular class, such as <code>Fish</code> or <code>DarterFish</code>. To use an image to display fish, you will need to pass the image filename and the direction the fish in the image is facing to the <code>FishImageDisplay</code> constructor. You will also need to put the image file in the folder where the simulation program is executed. This is probably the <code>Code</code> or <code>ExecutionInformation</code> folder, or a sub-folder under one of those folders. One image file, <code>smallfish.gif</code>, is provided in the <code>mbsgui.jar</code> file; you do not need to put that image file in the program's execution folder in order to use it. <LI><b>Changing the types of fish you can add when you create or edit an environment:</b> Edit the <code>main</code> method in the <code>MBSGUI</code> class and look for the statement that sets the <code>fishClassNames</code> variable. To add darter fish and slow fish to the list (see Chapter 4 of the MBS case study), comment out the existing statement and uncomment the later one that lists <code>Fish</code>, <code>DarterFish</code>, and <code>SlowFish</code>. If you create new <code>Fish</code> subclasses of your own, you will need to add them to this list if you want to be able to add objects of your new subclasses to environments using the graphical user interface. (You do not need to change the <code>fishClassNames</code> variable in order to open files or run simulations with <code>Fish</code> subclasses, just to add them to environments using the graphical user interface.) <LI><b>Changing the list of environment implementation classes available when you open or create an environment:</b> Edit the <code>main</code> method in the <code>MBSGUI</code> class and look for the statements that set the <code>boundedClassNames</code> and <code>unboundedClassNames</code> variables. There are several commented-out statements that illustrate how to specify additional implementation classes for either bounded or unbounded environments. (See the exercises at the end of Chapter 5 of the MBS case study for why this might be useful.) <p>Once you have added alternative environment implementation classes to the lists in the <code>MBSGUI</code> class, you will need to choose the bounded or unbounded implementation class you wish to use whenever you open an initial configuration file. An additional pull-down menu of class choices will appear in the dialog box. The new classes will also appear in the environment type pull-down menu in the dialog box for creating a new environment. <LI><b>Adding a menu to the GUI that allows you to turn breeding and dying on and off:</b> Edit your <code>Fish</code> class that has the modifications from Chapter 3 (either the file in the <code>DynamicPopulation</code> folder, or the original file in the <code>Code</code> folder to which you have added the code from <code>FishModsForChap3.txt</code>). Add a new class variable to the <code>Fish</code> class that specifies whether breeding and dying should be turned on or off. (Example: <code>private static boolean allowBreedingAndDying = true;</code>) Add the following method to the <code>Fish</code> class. Note that the signature and return type for the method must be exactly as shown below. <pre> /** Enables or disables fish breeding and dying. If this method * is present, MBSGUI will provide a way for users to specify * whether they want to run the program with breeding and dying * turned on or off. * @param flag <code>true</code> if the simulation should allow * breeding and dying; <code>false</code> otherwise. **/ public static void enableBreedDie(boolean flag) { // Set class variable from flag parameter. // Example: allowBreedingAndDying = flag; }</pre> <p>Finally, edit either the <code>act</code> method or the <code>breed</code> and <code>die</code> methods so that fish only breed and die when the class variable is set to <code>true</code>. <p>The graphical user interface looks to see if the Fish class has a <code>public static void enableBreedDie</code> method that takes a <code>boolean</code> value as a parameter. If it does, the graphical user interface adds a new menu, called Special, with two choices, "Enable breed and die" and "Disable breed and die." When you enable or disable breeding and dying by choosing the appropriate menu item, the graphical user interface calls the <code>enableBreedDie</code> method in the <code>Fish</code> class, passing it <code>true</code> if breeding and dying should be enabled, or <code>false</code> if they should not be enabled. This advanced feature allows you to turn breeding and dying on and off from the graphical user interface as the program is running, rather than turning it on and off by changing the code or compiling with different implementations of the <code>Fish</code> class. For example, in Chapter 4 the MBS case study suggests running the simulation without breeding and dying to see the difference between darter and normal fish movement more clearly, without the added complexity of fish breeding and dying.</UL><p><a href="#Top">(Go to top of help file.)</a></p><p><font size="-1">This document describes the 1 August 2002 release ofthe Marine Biology Simulation Graphical User Interface (MBSGUI).</font></p><p><font size="-1">Copyright© 2002 College Entrance Examination Board (www.collegeboard.com).</font></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -