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

The “dialog” package

1. The “voModification” package

In the “dialog” package, we create package “voModification”.

1.1 The “agentModification” package

Inside the package “voModification”, we create package “agentModification”.

To implement the “AgentPropertyDialog” class:

    • Create a new class inside the “edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentModification” package and name it “AgentPropertyDialog”.
  • Copy the code given below that describes the full implementation of a “AgentPropertyDialog” class.
package edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentModification;

import java.util.HashMap;
import java.util.Map;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.elements.Element;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.customControls.voModification.AbstractPropertyDialog;
import edu.utdallas.mavs.evacuation.visualization.vis3D.vo.EvacuationHumanAgentVO;

/**
 * This class describes a property dialog for an agent.
 */
public class AgentPropertyDialog extends AbstractPropertyDialog<EvacuationHumanAgentVO, AgentPropertyDialogController>
{
    /**
     * The {@link AgentPropertyDialog} constructor.
     * 
     * @param parentElement
     *        The parent element for the dialog.
     */
    public AgentPropertyDialog(Element parentElement)
    {
        super(parentElement);
    }

    @Override
    public boolean isContextSelected(Object object)
    {
        if(object instanceof EvacuationHumanAgentVO)
        {
            return ((EvacuationHumanAgentVO) object).isContextSelected();
        }
        else
        {
            return false;
        }
    }

    @Override
    public String getWidth()
    {
        return "275px";
    }

    @Override
    public String getHeight()
    {
        return "610px";
    }

    @Override
    public String getAlignment()
    {
        return "center";
    }

    @Override
    public Map<String, String> getParameters()
    {
        return new HashMap<String, String>();
    }

    @Override
    public Class<AgentPropertyDialogDefinition> getDefinitionClass()
    {
        return AgentPropertyDialogDefinition.class;
    }

    @Override
    public Class<AgentPropertyDialogController> getControllerClass()
    {
        return AgentPropertyDialogController.class;
    }

    @Override
    public void registerNiftyDefinition(Nifty nifty)
    {
        AgentPropertyDialogDefinition.register(nifty);
    }

    @Override
    public void updateDialog()
    {
        if(content != null)
        {
            try
            {
                content.getControl(getControllerClass()).updatePanel();
            }
            catch(Exception e)
            {
                entity.setContextSelected(false);
                super.removeDialog();
            }
        }
    }

    @Override
    public String getControllerName()
    {
        return (new AgentPropertyDialogController()).getClass().getName();
    }

    @Override
    public String getPositionX()
    {
        return "40";
    }

    @Override
    public String getPositionY()
    {
        return "40";
    }

    @Override
    public String getContentHeight()
    {
        return "590px";
    }

    @Override
    public String getContentWidth()
    {
        return "100%";
    }

    @Override
    public String createDialogId(String id)
    {
        return String.format("#AgentPropertyWindow%s", id);
    }

    @Override
    public String createDialogTitle(String id)
    {
        return String.format("%s %s", "Agent", id);
    }

    @Override
    public String getEntityId(Object entity)
    {
        return String.valueOf(((EvacuationHumanAgentVO) entity).getState().getID());
    }
}

To implement the “AgentPropertyDialogController” class:

    • Create a new class inside the “edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentModification” package and name it “AgentPropertyDialogController”.
  • Copy the code given below that describes the full implementation of a “AgentPropertyDialogController” class.
package edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentModification;

import org.bushe.swing.event.EventTopicSubscriber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.lessvoid.nifty.controls.CheckBox;
import de.lessvoid.nifty.controls.CheckBoxStateChangedEvent;
import de.lessvoid.nifty.controls.DropDown;
import de.lessvoid.nifty.controls.DropDownSelectionChangedEvent;
import de.lessvoid.nifty.controls.TextFieldChangedEvent;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.elements.render.TextRenderer;
import edu.utdallas.mavs.divas.core.msg.RuntimeAgentCommandMsg.RuntimeAgentCommand;
import edu.utdallas.mavs.divas.core.sim.agent.interaction.perception.sensors.vision.VisionAlgorithm;
import edu.utdallas.mavs.divas.core.sim.common.state.AgentControlType;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.controls.spinner.SpinnerController;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.controls.spinner.SpinnerDefinition;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.customControls.voModification.AbstractPropertyDialogController;
import edu.utdallas.mavs.evacuation.simulation.sim.common.state.EHumanAgentState;
import edu.utdallas.mavs.evacuation.simulation.sim.common.state.Posture;
import edu.utdallas.mavs.evacuation.visualization.vis3D.vo.EvacuationHumanAgentVO;

/**
 * The AgentOptionsDialogController contains all the events that the AgentOptionsDialog element generates.
 */
public class AgentPropertyDialogController extends AbstractPropertyDialogController<EvacuationHumanAgentVO>
{
    private final static Logger        logger = LoggerFactory.getLogger(AgentPropertyDialogController.class);

    private EHumanAgentState  agent;

    // Agent Properties
    private Element                    position;
    private Element                    velocity;
    private Element                    acceleration;
    private Element                    heading;

    private Element                    desiredSpeed;
    private Element                    maxSpeed;
    private Element                    visibleDistance;
    private Element                    fov;
    private Element                    minAudibleThreshold;
    private Element                    smellSensitivity;

    private CheckBox                   auditoryEnabled;
    private CheckBox                   olfactoryEnabled;
    private CheckBox                   cameraEnabled;
    private CheckBox                   coneEnabled;

    private DropDown<Posture>          posture;
    private DropDown<AgentControlType> agentControlType;
    private DropDown<VisionAlgorithm>  visionAlgorithm;

    /**
     * Constructs a new agent properties dialog controller
     */
    public AgentPropertyDialogController()
    {}

    @Override
    public void init()
    {
        if(entityVO != null)
        {
            agent = (EHumanAgentState) entityVO.getState();
            super.init();
        }
    }

    @Override
    public void bindNiftyElements()
    {
        // Agent Properties
        setupLabels();
        setupCheckBoxes();
        setupDropDowns();
        setupSpinners();
    }

    private void setupLabels()
    {
        position = getElement(AgentPropertyDialogDefinition.POSITION_LABEL);
        velocity = getElement(AgentPropertyDialogDefinition.VELOCITY_LABEL);
        acceleration = getElement(AgentPropertyDialogDefinition.ACCELERATION_LABEL);
        heading = getElement(AgentPropertyDialogDefinition.HEADING_LABEL);
    }

    private void setupCheckBoxes()
    {
        auditoryEnabled = getNiftyControl(AgentPropertyDialogDefinition.AUDITORY_ENABLED_CHECKBOX, CheckBox.class);
        olfactoryEnabled = getNiftyControl(AgentPropertyDialogDefinition.OLFACTORY_ENABLED_CHECKBOX, CheckBox.class);
        cameraEnabled = getNiftyControl(AgentPropertyDialogDefinition.AGENT_CAM_CHECKBOX, CheckBox.class);
        coneEnabled = getNiftyControl(AgentPropertyDialogDefinition.CONE_CHECKBOX, CheckBox.class);
    }

    @SuppressWarnings("unchecked")
    private void setupDropDowns()
    {
        posture = (DropDown<Posture>) createDropDownControl("posture", AgentPropertyDialogDefinition.POSTURE_PANEL);
        agentControlType = (DropDown<AgentControlType>) createDropDownControl("agentControlType", AgentPropertyDialogDefinition.AGENT_CONTROL_PANEL);
        visionAlgorithm = (DropDown<VisionAlgorithm>) createDropDownControl("visionAlgorithm", AgentPropertyDialogDefinition.VISION_ALGORITHM_PANEL);
    }

    private void setupSpinners()
    {
        SpinnerDefinition.labelSize = "127px";
        //SpinnerDefinition.register(nifty);

        desiredSpeed = createSpinnerControl("#desiredSpeed", "Desired Speed:", 1f, 10f, 0f, agent.getDesiredSpeed(), "m/s", AgentPropertyDialogDefinition.DESIRED_SPEED_PANEL, false);
        maxSpeed = createSpinnerControl("#maxSpeed", "Speed:", 1f, 10f, 0f, agent.getMaxSpeed(), "m/s", AgentPropertyDialogDefinition.MAX_SPEED_PANEL, true);
        visibleDistance = createSpinnerControl("#visibleDistance", "Visible Distance:", 10f, 1000f, 0f, agent.getVisibleDistance(), "m", AgentPropertyDialogDefinition.VISIBLE_DISTANCE_PANEL, true);
        fov = createSpinnerControl("#fov", "Field of View:", 10f, 360f, 0f, agent.getFOV(), "degrees", AgentPropertyDialogDefinition.FOV_PANEL, true);
        minAudibleThreshold = createSpinnerControl("#minAudibleThreshold", "Audible Threshold: ", 10f, 100f, 0f, agent.getMinAudibleThreshold(), "dB",
                AgentPropertyDialogDefinition.MIN_AUDIBLE_THRESHOLD_PANEL, true);
        smellSensitivity = createSpinnerControl("#smellSensitivity", "Smell Sensitivity: ", 1f, 10f, 0f, agent.getSmellSensitivity(), "", AgentPropertyDialogDefinition.SMELL_SENSITIVITY_PANEL, true);
    }

    @Override
    public void populatePanel()
    {
        // Populate dropdowns
        populateDropDown(posture, Posture.class);
        populateDropDown(agentControlType, AgentControlType.class);
        populateDropDown(visionAlgorithm, VisionAlgorithm.class);

        // Update agent properties
        updatePanel();

        // Select dropdown item
        posture.selectItem(agent.getPosture());
        agentControlType.selectItem(agent.getControlType());
        visionAlgorithm.selectItem(agent.getVisionAlgorithm());

        // Set checkbox controls
        auditoryEnabled.setChecked(agent.isAuditoryEnabled());
        olfactoryEnabled.setChecked(agent.isOlfactoryEnabled());
        cameraEnabled.setChecked(entityVO.isCamModeOn());
        coneEnabled.setChecked(entityVO.isVisionConeEnabled());
    }

    @Override
    public void subscriptions()
    {
        /*
         * Subscriptions for DropDown Controls
         */
        nifty.subscribe(screen, getPosture().getId(), DropDownSelectionChangedEvent.class, new EventTopicSubscriber<DropDownSelectionChangedEvent<Posture>>()
        {
            @Override
            public void onEvent(final String id, DropDownSelectionChangedEvent<Posture> event)
            {
                simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.SET_POSTURE, event.getSelection().toString());
            }
        });

        nifty.subscribe(screen, getAgentControlType().getId(), DropDownSelectionChangedEvent.class, new EventTopicSubscriber<DropDownSelectionChangedEvent<AgentControlType>>()
        {

            @Override
            public void onEvent(final String id, DropDownSelectionChangedEvent<AgentControlType> event)
            {
                simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.SET_CONTROL_TYPE, event.getSelection().toString());
            }
        });

        nifty.subscribe(screen, getVisionAlgorithm().getId(), DropDownSelectionChangedEvent.class, new EventTopicSubscriber<DropDownSelectionChangedEvent<VisionAlgorithm>>()
        {
            @Override
            public void onEvent(final String id, DropDownSelectionChangedEvent<VisionAlgorithm> event)
            {
                VisionAlgorithm vision = event.getSelection();                
                
                simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.SET_VISION_ALG, vision.toString());

                if(vision.equals(VisionAlgorithm.DivasVision) || vision.equals(VisionAlgorithm.NDDivasVision))
                {
                    setPartialProperties(true);
                }
                else
                {
                    setPartialProperties(false);
                }
            }
        });

        /*
         * Subscriptions for CheckBox Controls
         */
        nifty.subscribe(screen, getAuditoryEnabled().getId(), CheckBoxStateChangedEvent.class, new EventTopicSubscriber<CheckBoxStateChangedEvent>()
        {
            @Override
            public void onEvent(final String id, final CheckBoxStateChangedEvent event)
            {
                if(auditoryEnabled.isChecked())
                {
                    simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.ENABLE_AUDITORY_SENSOR, null);
                }
                else
                {
                    simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.DISABLE_AUDITORY_SENSOR, null);
                }
            }
        });

        nifty.subscribe(screen, getOlfactoryEnabled().getId(), CheckBoxStateChangedEvent.class, new EventTopicSubscriber<CheckBoxStateChangedEvent>()
        {

            @Override
            public void onEvent(final String id, final CheckBoxStateChangedEvent event)
            {
                if(olfactoryEnabled.isChecked())
                {
                    simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.ENABLE_OLFACTORY_SENSOR, null);
                }
                else
                {
                    simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.DISABLE_OLFACTORY_SENSOR, null);
                }
            }
        });

        nifty.subscribe(screen, getConeEnabled().getId(), CheckBoxStateChangedEvent.class, new EventTopicSubscriber<CheckBoxStateChangedEvent>()
        {

            @Override
            public void onEvent(final String id, final CheckBoxStateChangedEvent event)
            {
                if(coneEnabled.isChecked())
                {
                    entityVO.setVisionCone(true);
                }
                else
                {
                    entityVO.setVisionCone(false);
                }
            }
        });

        nifty.subscribe(screen, getCameraEnabled().getId(), CheckBoxStateChangedEvent.class, new EventTopicSubscriber<CheckBoxStateChangedEvent>()
        {
            @Override
            public void onEvent(final String id, final CheckBoxStateChangedEvent event)
            {
                if(event.getCheckBox().isChecked())
                {
                    // Dettach free camera
                    entityVO.setCamMode(true);
                    app.dettachFreeCamera();
                }

                else if(!event.getCheckBox().isChecked())
                {
                    entityVO.setCamMode(false);
                    app.attachFreeCamera();
                }
            }
        });

        /*
         * Subscriptions for Spinner Controls
         */
        nifty.subscribe(screen, getElementId(maxSpeed), TextFieldChangedEvent.class, new EventTopicSubscriber<TextFieldChangedEvent>()
        {
            @Override
            public void onEvent(final String id, final TextFieldChangedEvent event)
            {
                try
                {
                    simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.SET_MAX_VELOCITY, event.getText());

                }
                catch(NumberFormatException e)
                {
                    e.printStackTrace();
                }
            }
        });

        nifty.subscribe(screen, getElementId(visibleDistance), TextFieldChangedEvent.class, new EventTopicSubscriber<TextFieldChangedEvent>()
        {

            @Override
            public void onEvent(final String id, final TextFieldChangedEvent event)
            {
                try
                {
                    simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.SET_VISIBLE_DISTANCE, event.getText());
                }
                catch(NumberFormatException e)
                {
                    e.printStackTrace();
                }
            }
        });

        nifty.subscribe(screen, getElementId(fov), TextFieldChangedEvent.class, new EventTopicSubscriber<TextFieldChangedEvent>()
        {
            @Override
            public void onEvent(final String id, final TextFieldChangedEvent event)
            {
                try
                {
                    simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.SET_FOV, event.getText());
                }
                catch(NumberFormatException e)
                {
                    e.printStackTrace();
                }
            }
        });

        nifty.subscribe(screen, getElementId(minAudibleThreshold), TextFieldChangedEvent.class, new EventTopicSubscriber<TextFieldChangedEvent>()
        {

            @Override
            public void onEvent(final String id, final TextFieldChangedEvent event)
            {
                try
                {
                    simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.SET_MIN_AUDIBLE_THRESHOLD, event.getText());
                }
                catch(NumberFormatException e)
                {
                    e.printStackTrace();
                }
            }
        });

        nifty.subscribe(screen, getElementId(smellSensitivity), TextFieldChangedEvent.class, new EventTopicSubscriber<TextFieldChangedEvent>()
        {

            @Override
            public void onEvent(final String id, final TextFieldChangedEvent event)
            {
                try
                {
                    simCommander.sendRuntimeAgentCommand(agent.getID(), RuntimeAgentCommand.SET_SMELL_SENSITIVITY, event.getText());
                }
                catch(NumberFormatException e)
                {
                    e.printStackTrace();
                }
            }
        });
    }

    @Override
    public void updatePanel()
    {
        agent = (EHumanAgentState) entityVO.getState();
        updatePosition();
        updateVelocity();
        updateAcceleration();
        updateHeading();
    }

    private void updateHeading()
    {
        heading.getRenderer(TextRenderer.class).setText(String.format("(%.2f, %.2f, %.2f)", agent.getHeading().x, agent.getHeading().y, agent.getHeading().z));
    }

    private void updateAcceleration()
    {
        acceleration.getRenderer(TextRenderer.class).setText(String.format("(%.2f, %.2f, %.2f) m/s^2", agent.getAcceleration().x, agent.getAcceleration().y, agent.getAcceleration().z));
    }

    private void updateVelocity()
    {
        velocity.getRenderer(TextRenderer.class).setText(String.format("(%.2f, %.2f, %.2f) m/s", agent.getVelocity().x, agent.getVelocity().y, agent.getVelocity().z));
    }

    private void updatePosition()
    {
        position.getRenderer(TextRenderer.class).setText(String.format("(%.2f, %.2f, %.2f)", agent.getPosition().x, agent.getPosition().y, agent.getPosition().z));
    }

    /**
     * Gets the camera check box control of the nifty gui window.
     * 
     * @return the camera check box control.
     */
    public CheckBox getCameraEnabled()
    {
        return cameraEnabled;
    }

    private CheckBox getAuditoryEnabled()
    {
        return auditoryEnabled;
    }

    private CheckBox getOlfactoryEnabled()
    {
        return olfactoryEnabled;
    }

    private CheckBox getConeEnabled()
    {
        return coneEnabled;
    }

    private DropDown<Posture> getPosture()
    {
        return posture;
    }

    private DropDown<AgentControlType> getAgentControlType()
    {
        return agentControlType;
    }

    private DropDown<VisionAlgorithm> getVisionAlgorithm()
    {
        return visionAlgorithm;
    }

    @SuppressWarnings("unused")
    private String getDesiredSpeedTextFieldId()
    {
        return desiredSpeed.getControl(SpinnerController.class).getTextFieldId();
    }

    private void setPartialProperties(boolean enabled)
    {
        logger.info("Partial properties is enabled? {}", enabled);

        if(enabled)
        {
            fov.enable();
            visibleDistance.enable();
            coneEnabled.enable();
        }
        else
        {
            fov.disable();
            visibleDistance.disable();
            coneEnabled.disable();
        }
    }

    @Override
    public void setEntity(EvacuationHumanAgentVO entity)
    {
        super.entityVO = entity;
    }
}

To implement the “AgentPropertyDialogDefinition” class:

    • Create a new class inside the “edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentModification” package and name it “AgentPropertyDialogDefinition”.
  • Copy the code given below that describes the full implementation of a “AgentPropertyDialogDefinition” class.
package edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentModification;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.builder.ControlDefinitionBuilder;
import de.lessvoid.nifty.builder.PanelBuilder;
import de.lessvoid.nifty.controls.DefaultController;
import de.lessvoid.nifty.controls.checkbox.builder.CheckboxBuilder;
import de.lessvoid.nifty.controls.label.builder.LabelBuilder;
import de.lessvoid.nifty.tools.Color;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.utils.CommonBuilders;

/**
 * The {@link AgentPropertyDialogDefinition} registers a new control with Nifty that
 * represents the whole {@link AgentPropertyDialogDefinition}. This gives us later an
 * appropriate ControlBuilder to actual construct the Dialog (as a control) with
 * the given NAME.
 */
public class AgentPropertyDialogDefinition
{
    /**
     * The name of the control {@link AgentPropertyDialogDefinition}.
     */
    public static final String    NAME                            = AgentPropertyDialogDefinition.class.getName();

    /**
     * The id for the label containing the heading of the agent.
     */
    public static final String    HEADING_LABEL                   = "#heading";

    /**
     * The id for the label containing the acceleration of the agent.
     */
    public static final String    ACCELERATION_LABEL              = "#acceleration";

    /**
     * The id for the label containing the velocity of the agent.
     */
    public static final String    VELOCITY_LABEL                  = "#velocity";

    /**
     * The id for the label containing the position of the agent.
     */
    public static final String    POSITION_LABEL                  = "#position";

    /**
     * The id of the panel for the posture of the agent.
     */
    public static final String    POSTURE_PANEL                   = "#posturePanel";

    /**
     * The id of the panel for the agent control (i.e. autonomous, keyboard) of the agent.
     */
    public static final String    AGENT_CONTROL_PANEL             = "#agentControlPanel";

    /**
     * The id of the panel for the vision algorithm of the agent.
     */
    public static final String    VISION_ALGORITHM_PANEL          = "#visionAlgorithmPanel";

    /**
     * The id for the checkbox containing whether the agent auditory sense is enabled or not.
     */
    public static final String    AUDITORY_ENABLED_CHECKBOX       = "#auditoryEnabled";

    /**
     * The id for the checkbox containing whether the agent olfactory sense is enabled or not.
     */
    public static final String    OLFACTORY_ENABLED_CHECKBOX      = "#olfactoryEnabled";

    /**
     * The id for the checkbox containing whether the agent camera is enabled or not.
     */
    public static final String    AGENT_CAM_CHECKBOX              = "#agentCamEnabled";

    /**
     * The id for the checkbox containing whether the agent cone is on or off.
     */
    public static final String    CONE_CHECKBOX                   = "#coneEnabled";

    /**
     * The id for the textfield containing the agent degree of smell sensitivity.
     */
    public static final String    SMELL_SENSITIVITY_TEXTFIELD     = "#smellSensitivity";

    /**
     * The id for the panel containing the agent degree of smell sensitivity.
     */
    public static final String    SMELL_SENSITIVITY_PANEL         = "#smellSensitivityPanel";

    /**
     * The id for the textfield containing the minimum audible threshold of the agent.
     */
    public static final String    MIN_AUDIBLE_THRESHOLD_TEXTFIELD = "#minAudibleThreshold";

    /**
     * The id for the panel containing the minimum audible threshold of the agent.
     */
    public static final String    MIN_AUDIBLE_THRESHOLD_PANEL     = "#minAudibleThresholdPanel";

    /**
     * The id for the textfield containing the agent field of vision degree.
     */
    public static final String    FOV_TEXTFIELD                   = "#FOV";

    /**
     * The id for the panel containing the agent field of vision degree.
     */
    public static final String    FOV_PANEL                       = "#FOVPanel";

    /**
     * The id for the textfield containing the visible distance the agent can perceive.
     */
    public static final String    VISIBLE_DISTANCE_TEXTFIELD      = "#visibleDistance";

    /**
     * The id for the panel containing the visible distance the agent can perceive.
     */
    public static final String    VISIBLE_DISTANCE_PANEL          = "#visibleDistancePanel";

    /**
     * The id for the textfield containing the maximum speed of the agent.
     */
    public static final String    MAX_SPEED_TEXTFIELD             = "#maxSpeed";

    /**
     * The id for the panel containing the maximum speed of the agent.
     */
    public static final String    MAX_SPEED_PANEL                 = "#maxSpeedPanel";

    /**
     * The id for the textfield containing the desired speed of the agent.
     */
    public static final String    DESIRED_SPEED_TEXTFIELD         = "#desiredSpeed";

    /**
     * The id for the panel containing the desired speed of the agent.
     */
    public static final String    DESIRED_SPEED_PANEL             = "#desiredSpeedPanel";

    private static CommonBuilders builders                        = new CommonBuilders();

    /**
     * This registers the dialog as a new ControlDefintion with Nifty so that we can
     * later create the dialog dynamically.
     * 
     * @param nifty
     *        The Nifty instance
     */
    public static void register(final Nifty nifty)
    {
        new ControlDefinitionBuilder(NAME)
        {
            {
                controller(new DefaultController()); // AgentOptionsDialogController());
                panel(new PanelBuilder()
                {
                    {
                        // style("nifty-panel");
                        padding("5px,20px,0px,19px"); // top, right, bottom, left
                        backgroundColor(new Color(0.0f, 0.0f, 0.0f, 0.4f));
                        // height("590px");
                        width("100%");
                        childLayoutVertical();

                        panel(new PanelBuilder()
                        {
                            {
                                childLayoutVertical();

                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutHorizontal();
                                        control(builders.createLabel("Position: ", "80px"));
                                        panel(builders.hspacer("0px"));
                                        control(new LabelBuilder(POSITION_LABEL)
                                        {
                                            {
                                                width("*");
                                                alignLeft();
                                                textVAlignCenter();
                                                textHAlignLeft();
                                            }
                                        });
                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutHorizontal();
                                        control(builders.createLabel("Velocity: ", "80px"));
                                        panel(builders.hspacer("0px"));
                                        control(new LabelBuilder(VELOCITY_LABEL)
                                        {
                                            {
                                                width("*");
                                                alignLeft();
                                                textVAlignCenter();
                                                textHAlignLeft();
                                            }
                                        });
                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutHorizontal();
                                        control(builders.createLabel("Acceleration: ", "80px"));
                                        panel(builders.hspacer("0px"));
                                        control(new LabelBuilder(ACCELERATION_LABEL)
                                        {
                                            {
                                                width("*");
                                                alignLeft();
                                                textVAlignCenter();
                                                textHAlignLeft();
                                            }
                                        });
                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutHorizontal();
                                        control(builders.createLabel("Heading: ", "80px"));
                                        panel(builders.hspacer("0px"));
                                        control(new LabelBuilder(HEADING_LABEL)
                                        {
                                            {
                                                width("*");
                                                alignLeft();
                                                textVAlignCenter();
                                                textHAlignLeft();
                                            }
                                        });
                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder(POSTURE_PANEL)
                                {
                                    {
                                        childLayoutHorizontal();
                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder(DESIRED_SPEED_PANEL)
                                {
                                    {
                                        childLayoutHorizontal();

                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder(MAX_SPEED_PANEL)
                                {
                                    {
                                        childLayoutHorizontal();
                                    }
                                });
                            }
                        });

                        panel(builders.vspacer("5px"));

                        panel(new PanelBuilder()
                        {
                            {
                                childLayoutVertical();
                                panel(builders.vspacer());
                                panel(new PanelBuilder(AGENT_CONTROL_PANEL)
                                {
                                    {
                                        childLayoutHorizontal();
                                    }
                                });
                            }
                        });

                        panel(builders.vspacer("5px"));

                        panel(new PanelBuilder()
                        {
                            {
                                childLayoutVertical();
                                panel(builders.vspacer());
                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutHorizontal();
                                        control(builders.createLabel("Agent Camera"));
                                        panel(builders.hspacer("10px"));
                                        control(new CheckboxBuilder(AGENT_CAM_CHECKBOX)
                                        {
                                            {
                                                // checked(false);
                                            }
                                        });
                                    }
                                });
                                panel(builders.vspacer());

                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutVertical();
                                        panel(builders.vspacer());
                                        panel(new PanelBuilder()
                                        {
                                            {
                                                childLayoutHorizontal();
                                                control(builders.createLabel("Vision"));
                                                panel(builders.hspacer("10px"));
                                                panel(new PanelBuilder(VISION_ALGORITHM_PANEL)
                                                {
                                                    {
                                                        childLayoutHorizontal();
                                                    }
                                                });
                                            }
                                        });
                                        panel(builders.vspacer());
                                        panel(new PanelBuilder(VISIBLE_DISTANCE_PANEL)
                                        {
                                            {
                                                childLayoutHorizontal();
                                                panel(builders.hspacer("10px"));
                                            }
                                        });
                                        panel(builders.vspacer());
                                        panel(new PanelBuilder(FOV_PANEL)
                                        {
                                            {
                                                childLayoutHorizontal();
                                                panel(builders.hspacer("10px"));
                                            }
                                        });
                                        panel(builders.vspacer());
                                        panel(new PanelBuilder()
                                        {
                                            {
                                                childLayoutHorizontal();
                                                panel(builders.hspacer("10px"));
                                                control(builders.createLabel("Vision Cone"));
                                                panel(builders.hspacer("30px"));
                                                control(new CheckboxBuilder(CONE_CHECKBOX));
                                            }
                                        });
                                    }
                                });
                                panel(builders.vspacer("5px"));

                            }
                        });

                        panel(builders.vspacer("5px"));

                        panel(new PanelBuilder()
                        {
                            {
                                childLayoutVertical();
                                panel(builders.vspacer());
                                panel(new PanelBuilder()
                                {
                                    {

                                        childLayoutHorizontal();
                                        control(builders.createLabel("Hearing Enabled"));
                                        panel(builders.hspacer("40px"));
                                        control(new CheckboxBuilder(AUDITORY_ENABLED_CHECKBOX)
                                        {
                                            {
                                                // checked(true);
                                            }
                                        });
                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder(MIN_AUDIBLE_THRESHOLD_PANEL)
                                {
                                    {
                                        childLayoutHorizontal();
                                    }
                                });

                            }
                        });

                        panel(builders.vspacer("5px"));

                        panel(new PanelBuilder()
                        {
                            {
                                childLayoutVertical();
                                panel(builders.vspacer());
                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutHorizontal();
                                        control(builders.createLabel("Smell Enabled"));
                                        panel(builders.hspacer("40px"));
                                        control(new CheckboxBuilder(OLFACTORY_ENABLED_CHECKBOX)
                                        {
                                            {
                                                // checked(true);
                                            }
                                        });
                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder(SMELL_SENSITIVITY_PANEL)
                                {
                                    {
                                        childLayoutHorizontal();
                                        // control(builders.createLabel("Smell Sensitivity: "));
                                        // panel(builders.hspacer("10px"));
                                        // control(new TextFieldBuilder(SMELL_SENSITIVITY_TEXTFIELD)
                                        // {
                                        // {
                                        // width("60px");
                                        // alignLeft();
                                        // textVAlignCenter();
                                        // textHAlignLeft();
                                        // }
                                        // });
                                        // panel(new PanelBuilder()
                                        // {
                                        // {
                                        // childLayoutVertical();
                                        // valignCenter();
                                        // }
                                        // });
                                    }
                                });
                            }
                        });
                    }
                });
            }
        }.registerControlDefintion(nifty);
    }
}

1.2 The “agentsPropertyModification” package

Inside the package “voModification”, we create package “agentsPropertyModification”.

To implement the “AgentsPropertyModificationDialog” class:

    • Create a new class inside the “edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentsPropertyModification” package and name it “AgentsPropertyModificationDialog”.
  • Copy the code given below that describes the full implementation of a “AgentsPropertyModificationDialog” class.
package edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentsPropertyModification;

import java.util.HashMap;
import java.util.Map;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.elements.Element;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.customControls.AbstractDialog;

/**
 * This class represents the dialog for modification of general properties for agents.
 */
public class AgentsPropertyModificationDialog extends AbstractDialog<AgentsPropertyModificationDialogController>
{
    /**
     * Constructs a dialog for general properties modification for agents.
     * 
     * @param parentElement
     *        The parent element of this dialog
     */
    public AgentsPropertyModificationDialog(final Element parentElement)
    {
        super(parentElement);
    }

    @Override
    public String getWidth()
    {
        return "100%";
    }

    @Override
    public String getHeight()
    {
        return "280px";
    }

    @Override
    public String getAlignment()
    {
        return "center";
    }

    @Override
    public Map<String, String> getParameters()
    {
        Map<String, String> parameters = new HashMap<String, String>();
        
        parameters.put("title_label", "Agent General Properties");
       
        return parameters;
    }

    @Override
    public String getDialogId()
    {
        return "agentsPropertyModificationDialog";
    }
   
    @Override
    public Class<AgentsPropertyModificationDialogDefinition> getDefinitionClass()
    {
        return AgentsPropertyModificationDialogDefinition.class;
    }

    @Override
    public Class<AgentsPropertyModificationDialogController> getControllerClass()
    {
        return AgentsPropertyModificationDialogController.class;
    }

    @Override
    public String getDefinitionName()
    {
        return AgentsPropertyModificationDialogDefinition.NAME;
    }

    @Override
    public void registerNiftyDefinition(Nifty nifty)
    {
        AgentsPropertyModificationDialogDefinition.register(nifty);
    }

    @Override
    public String getControllerName()
    {
        return (new AgentsPropertyModificationDialogController()).getClass().getName();
    }
}

To implement the “AgentsPropertyModificationDialogController” class:

    • Create a new class inside the “edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentsPropertyModification” package and name it “AgentsPropertyModificationDialogController”.
  • Copy the code given below that describes the full implementation of a “AgentsPropertyModificationDialogController” class.
package edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentsPropertyModification;

import org.bushe.swing.event.EventTopicSubscriber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.lessvoid.nifty.controls.CheckBox;
import de.lessvoid.nifty.controls.CheckBoxStateChangedEvent;
import de.lessvoid.nifty.controls.DropDown;
import de.lessvoid.nifty.controls.DropDownSelectionChangedEvent;
import de.lessvoid.nifty.controls.TextField;
import de.lessvoid.nifty.controls.TextFieldChangedEvent;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.elements.events.NiftyMouseEvent;
import edu.utdallas.mavs.divas.core.client.dto.GeneralAgentProperties;
import edu.utdallas.mavs.divas.core.config.SimConfig;
import edu.utdallas.mavs.divas.core.sim.agent.interaction.perception.sensors.vision.VisionAlgorithm;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.controls.spinner.SpinnerDefinition;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.customControls.AbstractDialogController;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.utils.NiftyAttributes;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.utils.RegExpressionHelper;

/**
 * This class represents the controller for the AgentsPropertyModificationDialog Nifty control.
 */
public class AgentsPropertyModificationDialogController extends AbstractDialogController
{
    private static Logger             logger = LoggerFactory.getLogger(AgentsPropertyModificationDialogController.class);

    // Agent Properties
    private DropDown<VisionAlgorithm> visionAlgorithmDropDown;
    private Element                   visibleDistanceElement;
    private Element                   fovElement;
    private CheckBox                  coneEnabled;
    private CheckBox                  auditoryEnabled;
    private CheckBox                  olfactoryEnabled;
    private Element                   applyButtonElement;
    private TextField                 agentRangeTextField;
    private CheckBox                  applyAllEnabled;

    private String                    currentTextField;

    @Override
    public void bindNiftyElements()
    {
        setupButtons();
        setupCheckBoxes();
        setupDropDowns();
        setupSpinners();
        setupTextField();
    }

    private void setupTextField()
    {
        agentRangeTextField = getNiftyControl(AgentsPropertyModificationDialogDefinition.AGENT_RANGE_TEXTFIELD, TextField.class);
        currentTextField = agentRangeTextField.getText();
    }

    private void setupButtons()
    {
        applyButtonElement = getElement(AgentsPropertyModificationDialogDefinition.AGENT_PROPERTY_BUTTON);
    }

    private void setupCheckBoxes()
    {
        coneEnabled = getNiftyControl(AgentsPropertyModificationDialogDefinition.CONE_CHECKBOX, CheckBox.class);
        auditoryEnabled = getNiftyControl(AgentsPropertyModificationDialogDefinition.AUDITORY_ENABLED_CHECKBOX, CheckBox.class);
        olfactoryEnabled = getNiftyControl(AgentsPropertyModificationDialogDefinition.OLFACTORY_ENABLED_CHECKBOX, CheckBox.class);
        applyAllEnabled = getNiftyControl(AgentsPropertyModificationDialogDefinition.APPLY_ALL_CHECKBOX, CheckBox.class);
    }

    @SuppressWarnings("unchecked")
    private void setupDropDowns()
    {
        visionAlgorithmDropDown = (DropDown<VisionAlgorithm>) createDropDownControl("#visionAlgorithm", AgentsPropertyModificationDialogDefinition.VISION_ALGORITHM_PANEL);
    }

    private void setupSpinners()
    {
        SpinnerDefinition.labelSize = "110px";
        // SpinnerDefinition.register(nifty);

        visibleDistanceElement = createSpinnerControl("#visibleDistance", "Visible Distance:", 10f, 1000f, 0f, SimConfig.getInstance().default_visible_Distance, "m",
                AgentsPropertyModificationDialogDefinition.VISIBLE_DISTANCE_PANEL, true);
        fovElement = createSpinnerControl("#fov", "Field of View:", 10f, 360f, 0f, SimConfig.getInstance().default_fov, "degrees", AgentsPropertyModificationDialogDefinition.FOV_PANEL, true);
    }

    @Override
    public void populatePanel()
    {
        populateDropDown(visionAlgorithmDropDown, VisionAlgorithm.class);

        // Set checkbox controls
        auditoryEnabled.setChecked(true);
        olfactoryEnabled.setChecked(true);
        coneEnabled.setChecked(false);

        // Set the drop down
        visionAlgorithmDropDown.selectItem(SimConfig.getInstance().default_Vision_Algorithm);
    }

    @Override
    public void subscriptions()
    {
        /*
         * Subscriptions for button control
         */
        nifty.subscribe(screen, getApplyButton().getId(), NiftyMouseEvent.class, new EventTopicSubscriber<NiftyMouseEvent>()
        {
            @Override
            public void onEvent(final String id, final NiftyMouseEvent event)
            {
                if(event.isButton0Down())
                {
                    if(!getAgentRange().isEnabled())
                    {
                        applyPropertyAll();
                    }
                    else
                    {
                        applyProperty(getAgentRange().getText());
                    }
                }
            }
        });

        /*
         * Subscriptions for textfield
         */
        nifty.subscribe(screen, getAgentRange().getId(), TextFieldChangedEvent.class, new EventTopicSubscriber<TextFieldChangedEvent>()
        {
            @Override
            public void onEvent(final String id, final TextFieldChangedEvent event)
            {
                logger.info("text field event");

                if(!event.getText().equals(NiftyAttributes.AGENT_RANGE_EXAMPLE) && getCurrentTextField().equals(NiftyAttributes.AGENT_RANGE_EXAMPLE))
                {
                    setAgentRangeTextField("");
                }
            }
        });

        /*
         * Subscriptions for DropDown Controls
         */
        nifty.subscribe(screen, getVisionAlgorithm().getId(), DropDownSelectionChangedEvent.class, new EventTopicSubscriber<DropDownSelectionChangedEvent<VisionAlgorithm>>()
        {
            @Override
            public void onEvent(final String id, DropDownSelectionChangedEvent<VisionAlgorithm> event)
            {
                VisionAlgorithm vision = event.getSelection();

                if(vision.equals(VisionAlgorithm.DivasVision) || vision.equals(VisionAlgorithm.NDDivasVision))
                {
                    setPartialProperties(true);
                }
                else
                {
                    setPartialProperties(false);
                }
            }
        });

        /*
         * Subscriptions for CheckBox Controls
         */
        nifty.subscribe(screen, getApplyAllEnabled().getId(), CheckBoxStateChangedEvent.class, new EventTopicSubscriber<CheckBoxStateChangedEvent>()
        {
            @Override
            public void onEvent(final String id, final CheckBoxStateChangedEvent event)
            {
                if(getApplyAllEnabled().isChecked())
                {
                    getAgentRange().disable();
                }
                else
                {
                    getAgentRange().enable();
                }
            }
        });

    }

    @Override
    public void updatePanel()
    {}

    /**
     * Gets the apply property button for applying the properties to the selected agents in the simulation.
     * 
     * @return the apply property button
     */
    public Element getApplyButton()
    {
        return applyButtonElement;
    }

    private void applyPropertyAll()
    {
        app.getSimulatingAppState().applyAgentPropertiesForAll(getGeneralAgentProperties());
    }

    private void applyProperty(String text)
    {
        if(RegExpressionHelper.isNumberPattern(text))
        {
            app.getSimulatingAppState().applyAgentPropertiesForAgent(Integer.valueOf(text), getGeneralAgentProperties());
        }

        else if(RegExpressionHelper.isNumberRangePattern(text))
        {
            String[] range = text.split("-");
            app.getSimulatingAppState().applyAgentPropertiesForRange(Integer.valueOf(range[0]), Integer.valueOf(range[1]), getGeneralAgentProperties());
        }
    }

    private GeneralAgentProperties getGeneralAgentProperties()
    {
        VisionAlgorithm visionAlgorithm = visionAlgorithmDropDown.getSelection(); 
        float visDist = Float.valueOf(getSpinnerText(visibleDistanceElement));
        float fov = Float.valueOf(getSpinnerText(fovElement));
        boolean cone = coneEnabled.isChecked();
        boolean auditory = auditoryEnabled.isChecked();
        boolean olfactory = olfactoryEnabled.isChecked();

        return new GeneralAgentProperties(visionAlgorithm, visDist, fov, cone, auditory, olfactory);
    }

    private void setPartialProperties(boolean enabled)
    {
        logger.info("Partial properties is enabled? {}", enabled);

        if(enabled)
        {
            fovElement.enable();
            visibleDistanceElement.enable();
            coneEnabled.enable();
        }
        else
        {
            fovElement.disable();
            visibleDistanceElement.disable();
            coneEnabled.disable();
        }
    }

    private DropDown<VisionAlgorithm> getVisionAlgorithm()
    {
        return visionAlgorithmDropDown;
    }

    private Element getVisibleDistance()
    {
        return visibleDistanceElement;
    }

    private Element getFov()
    {
        return fovElement;
    }

    private CheckBox getConeEnabled()
    {
        return coneEnabled;
    }

    private CheckBox getAuditoryEnabled()
    {
        return auditoryEnabled;
    }

    private CheckBox getOlfactoryEnabled()
    {
        return olfactoryEnabled;
    }

    private TextField getAgentRange()
    {
        return agentRangeTextField;
    }

    private CheckBox getApplyAllEnabled()
    {
        return applyAllEnabled;
    }

    private String getCurrentTextField()
    {
        return currentTextField;
    }

    private void setAgentRangeTextField(String string)
    {
        getAgentRange().setText(string);
        currentTextField = string;
    }
}

To implement the “AgentsPropertyModificationDialogDefinition” class:

    • Create a new class inside the “edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentsPropertyModification” package and name it “AgentsPropertyModificationDialogDefinition”.
  • Copy the code given below that describes the full implementation of a “AgentsPropertyModificationDialogDefinition” class.
package edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentsPropertyModification;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.builder.ControlDefinitionBuilder;
import de.lessvoid.nifty.builder.PanelBuilder;
import de.lessvoid.nifty.controls.DefaultController;
import de.lessvoid.nifty.controls.button.builder.ButtonBuilder;
import de.lessvoid.nifty.controls.checkbox.builder.CheckboxBuilder;
import de.lessvoid.nifty.controls.textfield.builder.TextFieldBuilder;
import de.lessvoid.nifty.tools.Color;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.utils.CommonBuilders;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.utils.NiftyAttributes;

/**
 * The {@link AgentsPropertyModificationDialogDefinition} registers a new control with Nifty that
 * represents the whole {@link AgentsPropertyModificationDialogDefinition}. This gives us later an
 * appropriate ControlBuilder to actual construct the Dialog (as a control) with
 * the given NAME.
 */
@SuppressWarnings("javadoc")
public class AgentsPropertyModificationDialogDefinition
{
    /**
     * The name of the control {@link AgentsPropertyModificationDialogDefinition}.
     */
    public static final String    NAME                       = AgentsPropertyModificationDialogDefinition.class.getName();

    /**
     * The id of the panel for the vision algorithm of the agent.
     */
    public static final String    VISION_ALGORITHM_PANEL     = "#visionAlgorithmPanel";

    /**
     * The id for the panel containing the visible distance the agent can perceive.
     */
    public static final String    VISIBLE_DISTANCE_PANEL     = "#visibleDistancePanel";

    /**
     * The id for the panel containing the agent field of vision degree.
     */
    public static final String    FOV_PANEL                  = "#FOVPanel";

    /**
     * The id for the checkbox containing whether the agent cone is on or off.
     */
    public static final String    CONE_CHECKBOX              = "#coneEnabled";

    /**
     * The id for the checkbox containing whether the agent auditory sense is enabled or not.
     */
    public static final String    AUDITORY_ENABLED_CHECKBOX  = "#auditoryEnabled";

    /**
     * The id for the checkbox containing whether the agent olfactory sense is enabled or not.
     */
    public static final String    OLFACTORY_ENABLED_CHECKBOX = "#olfactoryEnabled";

    public static final String    AGENT_RANGE_TEXTFIELD      = "#agentRangeTextfield";

    public static final String    APPLY_ALL_CHECKBOX         = "#applyAllCheckbox";

    /**
     * The id for the agent property button.
     */
    public static final String    AGENT_PROPERTY_BUTTON      = "#agent_property_button";

    /**
     * The label size for the panel title.
     */
    public static String          labelSize                  = "*";

    private static CommonBuilders builders                   = new CommonBuilders();

    /**
     * This registers the dialog as a new ControlDefintion with Nifty so that we can
     * later create the dialog dynamically.
     * 
     * @param nifty
     *        The Nifty instance
     */
    public static void register(final Nifty nifty)
    {
        new ControlDefinitionBuilder(NAME)
        {
            {
                controller(new DefaultController());
                panel(new PanelBuilder()
                {
                    {
                        // style("nifty-panel");
                        backgroundColor(new Color(0.0f, 0.0f, 0.0f, 0.4f));

                        padding("5px,10px,5px,10px"); // top, right, bottom, left

                        childLayoutVertical();

                        panel(new PanelBuilder()
                        {
                            {
                                childLayoutVertical();
                                control(builders.createLabel("$title_label", labelSize));
                            }
                        });

                        /*
                         * Agent vision Properties
                         */
                        panel(new PanelBuilder()
                        {
                            {
                                childLayoutVertical();
                                panel(builders.vspacer());
                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutHorizontal();
                                        control(builders.createLabel("Vision"));
                                        panel(builders.hspacer("10px"));
                                        panel(new PanelBuilder(VISION_ALGORITHM_PANEL)
                                        {
                                            {
                                                childLayoutHorizontal();
                                            }
                                        });
                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder(VISIBLE_DISTANCE_PANEL)
                                {
                                    {
                                        childLayoutHorizontal();
                                        panel(builders.hspacer("10px"));
                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder(FOV_PANEL)
                                {
                                    {
                                        childLayoutHorizontal();
                                        panel(builders.hspacer("10px"));
                                    }
                                });
                                panel(builders.vspacer());
                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutHorizontal();
                                        panel(builders.hspacer("10px"));
                                        control(builders.createLabel("Vision Cone"));
                                        panel(builders.hspacer("10px"));
                                        control(new CheckboxBuilder(CONE_CHECKBOX));
                                    }
                                });
                            }
                        });
                        panel(builders.vspacer("5px"));

                        /*
                         * Agent auditory property
                         */
                        panel(new PanelBuilder()
                        {
                            {
                                childLayoutVertical();
                                panel(builders.vspacer());
                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutHorizontal();
                                        control(builders.createLabel("Hearing enabled"));
                                        panel(builders.hspacer("10px"));
                                        control(new CheckboxBuilder(AUDITORY_ENABLED_CHECKBOX));
                                    }
                                });
                            }
                        });
                        panel(builders.vspacer("5px"));

                        /*
                         * Agent olfactory property
                         */
                        panel(new PanelBuilder()
                        {
                            {
                                childLayoutVertical();
                                panel(builders.vspacer());
                                panel(new PanelBuilder()
                                {
                                    {
                                        childLayoutHorizontal();
                                        control(builders.createLabel("Smell enabled"));
                                        panel(builders.hspacer("10px"));
                                        control(new CheckboxBuilder(OLFACTORY_ENABLED_CHECKBOX));
                                    }
                                });
                                panel(builders.vspacer());
                            }
                        });

                        /**
                         * Apply all button
                         */
                        panel(builders.vspacer("5px"));
                        panel(new PanelBuilder()
                        {
                            {
                                childLayoutHorizontal();

                                control(new TextFieldBuilder(AGENT_RANGE_TEXTFIELD)
                                {
                                    {
                                        width("100px");
                                        padding("5px");
                                        alignLeft();
                                        textVAlignCenter();
                                        textHAlignLeft();
                                        text(NiftyAttributes.AGENT_RANGE_EXAMPLE);
                                    }
                                });

                                panel(builders.hspacer("10px"));

                                panel(new PanelBuilder()
                                {
                                    {
                                        // width("42px");
                                        childLayoutHorizontal();
                                        control(new CheckboxBuilder(APPLY_ALL_CHECKBOX));
                                        panel(builders.hspacer("5px"));
                                        control(builders.createLabel("All", "20px"));
                                    }
                                });

                                panel(builders.hspacer("5px"));

                                control(new ButtonBuilder(AGENT_PROPERTY_BUTTON, "Apply")
                                {
                                    {
                                        width("60px");
                                    }
                                });

                            }
                        });
                        panel(builders.vspacer("20px"));
                    }
                });
            }
        }.registerControlDefintion(nifty);
    }
}

2. The “panel” package

In the “dialog” package, we create package “panel”.

To implement the “EvacuationMenuDialog” class:

    • Create a new class inside the “edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.panel” package and name it “EvacuationMenuDialog”.
  • Copy the code given below that describes the full implementation of a “EvacuationMenuDialog” class.

package edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.panel;

import de.lessvoid.nifty.elements.Element;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.customControls.panel.MenuDialog;

/**
 * This class represents the evacuation simulation nifty menu dialog.
 */
public class EvacuationMenuDialog extends MenuDialog
{
    /**
     * Constructs a new evacuation simulation nifty Menu dialog
     * 
     * @param parentElement
     *        The parent element of this dialog
     */
    public EvacuationMenuDialog(Element parentElement)
    {
        super(parentElement);
    }

    @Override
    public String getControllerName()
    {
        return (new EvacuationMenuDialogController()).getClass().getName();
    }
}

To implement the “EvacuationMenuDialogController” class:

    • Create a new class inside the “edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.panel” package and name it “EvacuationMenuDialogController”.
  • Copy the code given below that describes the full implementation of a “EvacuationMenuDialogController” class.
package edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.panel;

import edu.utdallas.mavs.divas.visualization.vis3D.dialog.customControls.AbstractDialog;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.customControls.panel.MenuDialogController;
import edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentsPropertyModification.AgentsPropertyModificationDialog;
import edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.voModification.agentsPropertyModification.AgentsPropertyModificationDialogController;

/**
 * This class represents the controller for the Evacuation MenuDialog Nifty control.
 */
public class EvacuationMenuDialogController extends MenuDialogController
{
    @Override
    protected void createAgentContent()
    {
        super.createAgentContent();
        
        // Specific content for the evacuation agents
        AbstractDialog<AgentsPropertyModificationDialogController> agentsPropertyModificationDialog = new AgentsPropertyModificationDialog(agentContentPanel);
        agentsPropertyModificationDialog.createDialog();
        //breakLine(agentContentPanel);
    }
     
    @Override
    protected void createEnvObjectContent()
    {
        super.createEnvObjectContent();
    }
    
    @Override
    protected void createEventContent()
    {
        super.createEventContent();
    }
}

3. The “EvacuationNiftyScreen” class

To implement the “EvacuationNiftyScreen” class:

    • Create a new class inside the “edu.utdallas.mavs.evacuation.visualization.vis3D.dialog” package and name it “EvacuationNiftyScreen”.
  • Copy the code given below that describes the full implementation of a “EvacuationNiftyScreen” class.

package edu.utdallas.mavs.evacuation.visualization.vis3D.dialog;

import edu.utdallas.mavs.divas.visualization.vis3D.dialog.NiftyScreen;
import edu.utdallas.mavs.divas.visualization.vis3D.dialog.customControls.panel.HelpDialog;
import edu.utdallas.mavs.evacuation.visualization.vis3D.dialog.panel.EvacuationMenuDialog;

/**
 * This class describes a nifty screen for the evacuation simulation.
 */
public class EvacuationNiftyScreen extends NiftyScreen<EvacuationMenuDialog, HelpDialog>
{
    /**
     * The {@link EvacuationNiftyScreen} constructor.
     */
    public EvacuationNiftyScreen()
    {
        super();
    }

    @Override
    protected void createNiftyPanels()
    {
        menuDialog = new EvacuationMenuDialog(menuLayerElement);
        helpDialog = new HelpDialog(helpPanelElement);
    }
}