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

The Traffic 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 traffic simulation system. In this tutorial, we provide a detailed description of the steps necessary to customize the GUI module of the traffic simulation system.

    1. Tunning the “traffic-GUI” module configuration

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

    1. Double click on the file “pom.xml” that exists in the “traffic-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 traffic 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 traffic GUI module depends on the previously created traffic 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.traffic</groupId>
                            <artifactId>traffic</artifactId>
                            <version>1.0.0-SNAPSHOT</version>
                         </parent>
                         <groupId>traffic-gui</groupId>
                         <artifactId>traffic-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.traffic</groupId>
                               <artifactId>traffic-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.traffic.gui”. You can use your own rules to name the package.
    2. Inside the package “edu.utdallas.mavs.traffic.gui”, create a class named “TrafficGui” 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 traffic simulation GUI.
    3. The “TrafficGui” 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 traffic 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 “TrafficGui”:
                       
      package edu.utdallas.mavs.traffic.gui;
      
      
      import javafx.application.Application;
      import edu.utdallas.mavs.divas.gui.DivasGuiApplication;
      import edu.utdallas.mavs.traffic.visualization.vis2D.TrafficVisualizer2DMain;
      import edu.utdallas.mavs.traffic.visualization.vis3D.TrafficVisualizer3DMain;
      
      public class TrafficGui extends DivasGuiApplication
      {
          /**
           * @param args
           *        the command line arguments
           */
          public static void main(String[] args)
          {
              Application.launch(TrafficGui.class, args);
          }
      
          @Override
          public String getVis2DMainClass()
          {
              return TrafficVisualizer2DMain.class.getName();
          }
      
          @Override
          public String getVis3DMainClass()
          {
              return TrafficVisualizer3DMain.class.getName();
          }
      
      }
  2. Configuring the logging information
    1. Right click on the “traffic-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=WARN, A1, AdminFileAppender
                    #, CoalescingStatistics
                    
                    # 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 [%-26t] %-20c{1}: - %-30m%n
                    
                    # Set logger levels
                    log4j.logger.edu.utdallas.mavs.divas=INFO
                    log4j.logger.edu.utdallas.mavs.matisse=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