+1 (972) 883-2091
ECSS 4.220, 800 W Campbell Rd, Richardson, TX 75083–0688, US

Tuning Evacuation GUI module configuration and creating its inner packages

The Evacuation GUI Module exists as an individual component that allows the users to control a running simulation and to query the detailed properties of any simulated entity. Most of the GUI module components are reusable components and are reused “as-is” when developing the evacuation simulation system. In this tutorial, we provide a detailed description of the steps necessary to customize the GUI module of the evacuation simulation system.

    1. Tunning the “evacuation-GUI” module configuration

We start by updating the POM configuration of the “evacuation-gui” module to manage its dependencies.

    1. Double click on the file “pom.xml” that exists in the “evacuation-gui” module. The Maven POM Editor should appear.
    2. In the opened window, click on the tab “pom.xml”.
    3. Add the following dependencies’ configuration to include the dependencies used by the evacuation GUI module. You should be careful here, the group infomration should match to the information you used in Tutorial 1. In the illustrated example, the evacuation GUI module depends on the previously created evacuation simulation and visualization modules. The content of the project object model (POM) should be as follows:
                      <?xml version="1.0" encoding="UTF-8"?>
                      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
                         <modelVersion>4.0.0</modelVersion>
                         <parent>
                            <groupId>edu.utdallas.mavs.evacuation</groupId>
                            <artifactId>evacuation</artifactId>
                            <version>1.0.0-SNAPSHOT</version>
                         </parent>
                         <groupId>evacuation-gui</groupId>
                         <artifactId>evacuation-gui</artifactId>
                         <!-- ======================================= -->
                         <!-- ==== Properties === -->
                         <!-- ======================================= -->
                         <properties>
                            <fx.home>C:Program FilesJavajdk1.8.0_60</fx.home>
                            <fx.rt>${fx.home}/jre/lib/jfxrt.jar</fx.rt>
                         </properties>
                         <!-- ======================================= -->
                         <!-- ==== Dependencies === -->
                         <!-- ======================================= -->
                         <dependencies>
                            <!-- Project Dependencies -->
                            <dependency>
                               <groupId>edu.utdallas.mavs.divas</groupId>
                               <artifactId>divas-gui</artifactId>
                               <version>${divas.version}</version>
                            </dependency>
                            <dependency>
                               <groupId>edu.utdallas.mavs.evacuation</groupId>
                               <artifactId>evacuation-visualization</artifactId>
                               <version>1.0.0-SNAPSHOT</version>
                            </dependency>
                            <!-- General Dependencies -->
                         </dependencies>
                         <!-- ======================================= -->
                         <!-- ==== Plugins === -->
                         <!-- ======================================= -->
                         <build>
                            <plugins>
                               <plugin>
                                  <groupId>com.zenjava</groupId>
                                  <artifactId>javafx-maven-plugin</artifactId>
                                  <version>1.5</version>
                                  <configuration>
                                     <mainClass>edu.utdallas.mavs.matisse.gui.MatisseGui</mainClass>
                                  </configuration>
                                  <executions>
                                     <execution>
                                        <id>make-assembly</id>
                                        <!-- this is used for inheritance merges -->
                                        <phase>install</phase>
                                        <!-- bind to the packaging phase -->
                                        <goals>
                                           <goal>build-jar</goal>
                                        </goals>
                                     </execution>
                                  </executions>
                               </plugin>
                               <plugin>
                                  <artifactId>maven-antrun-plugin</artifactId>
                                  <executions>
                                     <execution>
                                        <id>copy_resources</id>
                                        <phase>install</phase>
                                        <configuration>
                                           <tasks>
                                              <copy todir="${project.build.directory}">
                                                 <fileset dir="${basedir}" includes="*.properties" />
                                              </copy>
                                           </tasks>
                                        </configuration>
                                        <goals>
                                           <goal>run</goal>
                                        </goals>
                                     </execution>
                                  </executions>
                               </plugin>
                            </plugins>
                         </build>
                      </project>
      
      
  1. Creating and implementing the inner packages
    1. Right click on the folder “src/main/java” > New > Package and create a package named “edu.utdallas.mavs.evacuation.gui”. You can use your own rules to name the package.
    2. Inside the package “edu.utdallas.mavs.evacuation.gui”, create a class named “evacuationGui” that extends the class “DivasGuiApplication” defined in the package “edu.utdallas.mavs.divas.gui”. This is the main class that starts the execution of the evacuation simulation GUI.
    3. The “EvacuationGui” class provides an implementation of the “main” method that represents the GUI entry point. The only action required to customize the simulation GUI is to include a reference to the evacuation 2D/3D visualizers built in previous tutorials. This is necessary to be able to invoke the execution of these visualizers from the GUI menu. The following code provides a full implementation of the class “EvacuationGui”:
      package edu.utdallas.mavs.evacuation.gui;
      
      import javafx.application.Application;
      import edu.utdallas.mavs.divas.gui.DivasGuiApplication;
      import edu.utdallas.mavs.evacuation.visualization.vis2D.EvacuationVisualizer2DMain;
      import edu.utdallas.mavs.evacuation.visualization.vis3D.EvacuationVisualizer3DMain;
      
      public class EvacuationGui extends DivasGuiApplication
      {
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args)
          {
              Application.launch(EvacuationGui.class, args);
          }
      
          @Override
          public String getVis2DMainClass()
          {
              return EvacuationVisualizer2DMain.class.getName();
          }
      
          @Override
          public String getVis3DMainClass()
          {
              return EvacuationVisualizer3DMain.class.getName();
          }
      
      }
      

  2. Configuring the logging information
    1. Right click on the “evacuation-gui” module and create a new file named “log4j.properties”.
    2. Write the following code that indicates that the logging information will be appended to the file “admin.log”.
    # Set root logger level 
    log4j.rootLogger=INFO, A1, AdminFileAppender 
    
    # A1 is set to be a ConsoleAppender.
    log4j.appender.A1=org.apache.log4j.ConsoleAppender
    
    # A1 uses PatternLayout.
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss.SSS} %-5p [%-21t] %-20c{1}: - %-30m%n
    
    # Set logger levels
    log4j.logger.edu.utdallas.mavs.divas=INFO
    log4j.logger.org.perf4j.TimingLogger=WARN
    log4j.logger.org.apache.activemq=ERROR
    log4j.logger.org.apache.activemq.spring=ERROR
    
    # AdminFileAppender - used to log messages in the admin.log file.
    log4j.appender.AdminFileAppender=org.apache.log4j.FileAppender
    log4j.appender.AdminFileAppender.File=admin.log
    log4j.appender.AdminFileAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.AdminFileAppender.layout.ConversionPattern=%d{HH:mm:ss.SSS} %-5p [%-21t] %-20c{1}: - %-30m%n