import org.eclipse.swt.widgets.Display; // AP(r) Computer Science Marine Biology Simulation: // The MBSGUI2 class is copyright(c) 2004-5 David Walser // // This class is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation. // // This class is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. /** * AP® Computer Science Marine Biology Simulation:
* The MBSGUI2 class provides a main method for a version * of the AP Computer Science Marine Biology Simulation with a graphical * user interface. * *

* This class will NOT be tested on the Advanced Placement exam. * * @author David Walser * @version 20 April 2004 **/ public class MBSGUI2 { /** Start the Marine Biology Simulation program. * @param args The String arguments are not used in this application. **/ public static void main(String[] args) { // Specify which fish classes are available. This array is used // to provide a choice of fish classes in the pull-down menu when // manually placing objects into the environment. String[] fishClassNames = {"Fish","DarterFish","SlowFish"}; // FOR CHAPTER 4, use the following instead: // String[] fishClassNames = {"Fish", "DarterFish", "SlowFish"}; // As you create new subclasses of the Fish class, add the class // names to the list. // Create the window containing the graphical user interface MBSGUIWindow aw = new MBSGUIWindow(fishClassNames); // Specify classes that know how to draw various environment objects; // in other words, map environment object classes (like Fish) to // display objects (like the DrawnFishDisplay object). aw.associate("Fish", new DrawnFishDisplay(5,4)); // normal fish // Use lines like the following to give different fish // different shapes. The two arguments to the DrawnFishDisplay // constructor are the length and width of a fish on a scale of // 1 to 5. You can also use images for any of the fish // classes, as in the second SlowFish example below. // aw.associate("Fish", new DrawnFishDisplay(2,1)); // little fish aw.associate("DarterFish", new DrawnFishDisplay(4,2)); // narrow fish // aw.associate("SlowFish", new DrawnFishDisplay(4,5)); // round fish aw.associate("SlowFish", new ImageFishDisplay("smallfish.gif", Direction.EAST)); // FishDisplay classes available in mbsgui2.jar are DrawnFishDisplay // and ImageFishDisplay. One gif file is provided: smallfish.gif. // The constructor for ImageFishDisplay takes two parameters: the // name of the image file and the direction the fish in the image // is facing. // Determine what classes are available for representing bounded // and unbounded environments. String[] boundedClassNames = {"BoundedEnv"}; String[] unboundedClassNames = {"UnboundedEnv"}; // FOR CHAPTER 5, use something like the following instead: // String[] boundedClassNames = {"BoundedEnv", "VLBoundedEnv"}; // String[] unboundedClassNames = {"UnboundedEnv", "SLUnboundedEnv"}; // Inform the window object of the classes being used in this program // so it can construct instances of those classes when environments // are read or created. aw.addBoundedEnvClassNames(boundedClassNames); aw.addUnboundedEnvClassNames(unboundedClassNames); // Show the window containing the graphical user interface aw.setBlockOnOpen(true); aw.open(); Display.getCurrent().dispose(); System.exit(0); } }