belka
Class BelkaManager

java.lang.Object
  extended by belka.BelkaManager
All Implemented Interfaces:
ActionListener, EventListener

public class BelkaManager
extends Object
implements ActionListener

The object of this class manages the life of Belka as a program or applet. It performes two main functions:

Author:
Alexej Abyzov

Constructor Summary
BelkaManager(Container drawContentPane, String[] args)
          Object constructor.
BelkaManager(Container drawContentPane, String[] args, URL codeBase)
          Object constructor meant to create object when Belka is used as an applet.
 
Method Summary
 void actionPerformed(ActionEvent evt)
           
 boolean addMolecule(Molecule molecule)
           
 int countMolecules()
           
 void destroy()
          The method nulls internal pointers and disassembles molecules to help garbage collector to clear memory.
 int getLargestGroup()
          The function returns the largest group id assigned to any assembly.
 Component getMainComponent()
          Returns the main component to draw on
 Molecule moleculeList()
           
 boolean removeMolecule(Molecule molecule)
           
 void run()
          The function waits for user input and processes command.
 String runCommand(String command)
          Runs the given command and updates screen view if necesary.
 String runCommand(String command, boolean update)
          Runs the given command and updates screen view depending on value of update.
 String runScript(String script)
          Runs the script of command and updates screen view if necesary.
 void setUserInput(String input)
          To set user input to the manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BelkaManager

public BelkaManager(Container drawContentPane,
                    String[] args,
                    URL codeBase)
Object constructor meant to create object when Belka is used as an applet.

Parameters:
drawContentPane - main content pane for drawing. If it's null, no graphical display is created.
args - input files to load upon start up.
codeBase - url where the input files are located. If null, files are searched in current directory.

BelkaManager

public BelkaManager(Container drawContentPane,
                    String[] args)
Object constructor.

Parameters:
drawContentPane - main content pane for drawing. If it's null, no graphical display is created. This allows to use Belka in batch mode.
args - input files to load upon start up. Files are searched in current directory.
Method Detail

destroy

public void destroy()
The method nulls internal pointers and disassembles molecules to help garbage collector to clear memory.


setUserInput

public void setUserInput(String input)
To set user input to the manager.

Parameters:
input - user input.

moleculeList

public Molecule moleculeList()

addMolecule

public boolean addMolecule(Molecule molecule)

removeMolecule

public boolean removeMolecule(Molecule molecule)

countMolecules

public int countMolecules()

getMainComponent

public Component getMainComponent()
Returns the main component to draw on

Returns:
the main component to draw on

run

public void run()
The function waits for user input and processes command. Function exits only if the input command equals to 'end' or java exits.


runScript

public String runScript(String script)
Runs the script of command and updates screen view if necesary. Commands are assumed to be put in square brackets []. For example [backbone off][spacefill on].

Parameters:
script - string with script.

runCommand

public String runCommand(String command)
                  throws Exception
Runs the given command and updates screen view if necesary.

Parameters:
command - command to execute.
Returns:
message to be printed.
Throws:
Exception

runCommand

public String runCommand(String command,
                         boolean update)
                  throws Exception
Runs the given command and updates screen view depending on value of update.

Parameters:
command - command to execute.
update - flag specifying whether screen must be updated.
Returns:
message to be printed.
Throws:
Exception

getLargestGroup

public int getLargestGroup()
The function returns the largest group id assigned to any assembly.

Returns:
the largest group id assigned to any assembly.

actionPerformed

public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener