Scenario Selector GUI

From SIMA wiki
Revision as of 16:16, 2 January 2013 by Schaat (talk | contribs) (Scenario Property File)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The class sim.ScenarioSelector provides a GUI that shows all available scenario configurations and starts the selected scenario.

ScenarioSelector.png

GUI Elements

The window contains the following elements:

  • Scenario menu - Each file that has the extension ”.properties” in the folder S:\ARSIN_V01\Sim\config is listed1).
  • Description group - The details of the select configuration are shown.
    • Title - The short title of the scenario (identical to the entry in the scenario menu above).
    • Icon - An icon that shows a typical scene of the scenario or what ever seemed to fit.
    • Short Description - A short description of the scenario. Something like an abstract.
    • Field Size - The world dimension.
    • Filename - The filename of the scenario property file.
    • Long Description - A lengthy description of the scenario.
  • autostart - If selected, the simulator loads all entities, objects, and agents and pauses at step 0. Otherwise, the whole loading process would have to be started explicitly at the next window. Only necessary if the loading process needs to be debugged.
  • adaptor - upon pressing “start scenario” an additional window is shown (if checkbox is activated) and the number of entities can be changed. But only for entity types that exist in this scenario.
  • “Start Scenario” - Submit the selected parameters to SimulatorMain and close the window.
  • “Exit” - Close the window.
  • "Edit" - Use the Scenario editor (see below)

Scenario Property File

This is an example for a typical scenario property file. Six different entitiy groups define what kind of objects and entities are placed in the world. Each group defines what kind if entity and, if applicable, which decision unti to be used. Further, the number of entities and how they are placed in the world has to be provided. Optionally, the default values for the entity and/or the decision unit can be overwritten (e.g. entitygroups.0.overwriteentitydefaults.immortal=TRUE). An indepth explanation of the properties is given at page Scenario file.

For details see the property-file "S:\ARSIN_V01\Sim\config\scenarios\tutorial.properties"

#
#Sun Jul 26 15:07:41 CEST 2009
entitygroups.0.groupentitytype=ARSIN
entitygroups.0.groupdecisionunittype=PA
entitygroups.0.numentities=1
entitygroups.0.positions.0.pos_angle=0
entitygroups.0.positions.0.pos_x=100
entitygroups.0.positions.0.pos_y=100
entitygroups.0.positions.positiontype=LIST
entitygroups.0.overwriteentitydefaults.immortal=TRUE
entitygroups.1.groupentitytype=REMOTEBOT
entitygroups.1.groupdecisionunittype=REMOTE
entitygroups.1.numentities=0
entitygroups.1.positions.0.pos_angle=0
entitygroups.1.positions.0.pos_x=80
entitygroups.1.positions.0.pos_y=80
entitygroups.1.positions.positiontype=LIST
entitygroups.2.groupentitytype=PLANT
entitygroups.2.numentities=0
entitygroups.2.positions.positiontype=RANDOM
entitygroups.3.groupentitytype=CAN 
entitygroups.3.numentities=0
entitygroups.3.positions.positiontype=RANDOM
entitygroups.4.groupentitytype=CAKE
entitygroups.4.numentities=1
entitygroups.4.positions.positiontype=RANDOM
entitygroups.5.groupentitytype=STONE
entitygroups.5.numentities=1
entitygroups.5.positions.positiontype=RANDOM
loader_type=SIMPLE_PROPERTY_LOADER
loader_version=3
short_description=Clemens' main test world setup for temp development purposes
description=Ich schreib hier rein was mir gefällt denn es ist ja meine eigene Welt! \n meine Welt: 1 ARSIN der hunger hat, eine Futterquelle
field_height=200.0
field_width=200.0
image=Clemens_01.png
entitygroups.numentitygroups=6
title=Clemens' testscenario
worldboundarywalls=true
usedefaults=true

Scenario editor

When using the scenario selector you are able to use an editor to change a scenario file. An alternative with more control over the file is the usage of a text editor to change a scenario file.

  • Click "Edit" in the scenario selector

The following three menus are available in the editor:

  • File
    • Open …: Performs the method showOpenDialog(…) defined in the Java swing platform package class JFileChooser to select a file and than displays the new file in the editor.
    • Save: Checks whether the specified file really should be overwritten if it already exists and if so performs the writeProperties(…) method from the class clsProperties to save the properties if the file name is known respectively calls the Save as … function if the file name is unknown.
    • Save as …: Uses the showSaveDialog(…) method from JFileChooser to select a file and stores the new file name in the clsPropertiesInspector object’s variable propertyFilename and as the root node of the tree.
  • View
    • Expand subtree: Recursively expands the sub tree below the selected node or if no node is selected the complete tree.

Remark: The function to collapse sub trees is not needed in the menu as it is a feature of JTree objects and can be activated by double click on the left mouse key if the sub tree is expanded. If the sub tree is not expanded double click on the left mouse key triggers expansion up to the latest expansion state but not fully recursive expansion as it is provided by the menu function.

  • Edit
    • Copy subtree: Writes the nodes of the sub tree of the selected node (this one inclusive) to the buffer variable bufferPropertylabels[…] and the values to bufferPropertyvalues[…].
    • Cut subtree: Writes the nodes of the sub tree of the selected node (this one inclusive) to the buffer variable bufferPropertylabels[…] and the values to bufferPropertyvalues[…] and then deletes the sub tree.
    • Delete subtree: Deletes the selected node and its sub tree.
    • New node …: Changes the editing area; offers two new input fields, one for the name of the new node, one for the value. The new node gets added as a new leaf below the selected node. The action gets executed if the button Add is pressed or can be withdrawn by using the button Cancel. If the selected node is a leaf with a value (not empty) the user is asked, whether this value should be deleted and get replaced by the new node.
    • Paste: The sub tree stored in the buffer by the recent execution of one of the functions Copy subtree or Cut subtree is added below the currently selected node (as a sibling of the selected node’s children). If the selected node is a leaf with a value (not empty) the user is asked, whether this value should be deleted and get replaced by the sub tree to be pasted.

Implementation

    • Paste renamed: As frequently a copied sub tree has to be added below its own parent under a “new name”, that means the root node of the sub tree will have a new label but the rest will be an exact copy of the buffer contents, this menu entry was added. It changes the editing area and offers an input field to specify the new label of the root of the sub tree to be inserted. With the button Proceed the function gets executed, to prevent execution you may use the button Cancel.

Remark: Edit menu together with View menu are available as popup menus also by clicking the right mouse button.