FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.gui.SimpleGUI Class Reference

A simple GUI to configure and start FRODO. More...

Inheritance diagram for frodo2.gui.SimpleGUI:

Public Member Functions

 SimpleGUI (String problemFilePath, String agentFilePath, String timeout)
 Constructor defining and building the GUI.
 SimpleGUI (String problemFilePath, String agentFilePath, String timeout, String outputFilePath)
 Constructor defining and building the GUI.
void actionPerformed (ActionEvent e)
 This method is called whenever a button associated with this ActionListener is pressed.
void itemStateChanged (ItemEvent e)
 This method is called when another item is selected from the list of available agent configuration files.

Static Public Member Functions

static void main (String[] args)

Private Member Functions

String readLicense ()
 This method reads the license from the file LICENSE.txt and displays it if the file exists and can be read.
String[] createAgentsList ()
 This method creates the mapping from all currently implemented DCOP solving agents to their paths, and returns an array containing only the file names of the configuration files, in order to display them in the drop down list.
void solveProblem ()
 This method first checks if all the necessary parameters (problem file, agent description file, timeout value) are valid.
void enableProblemDef (boolean enabled)
 Enables or disables input fields used to define the problem (problem instance, agent...).
void editProblemFile ()
 This method creates a dialog containing a text editor to edit the chosen problem file.
void editAgentFile (boolean isCustomFile, String filePath)
 This method creates a dialog containing a text editor to edit the chosen agent configuration file.
void saveFile (String filePath)
 This method saves the current editor content to a file with the given path.

Private Attributes

Map< String, String > agentNamesToPath
 Mapping from agent configuration file names to their absolute path.
JTextField problemField
 Text field containing path of problem file.
JTextField outputField
 Text field containing path to the output file.
JComboBox< String > agentList
 List of DCOP solving agents.
JTextField timeoutField
 Specified timeout value.
JLabel problemError
 Label indicating an error in chosen problem file.
JLabel agentError
 Label indicating an error in chosen agent configuration file.
JLabel timeoutError
 Label indicating an erroneous timeout value.
JDialog editorDialog
 Dialog window containing a text editor to change problem and agent configuration files.
JTextPane editorPane
 Pane containing a text editor to change problem and agent configuration files.
String tempAgentFile = null
 String indicating the path of a temporary agent configuration file, if used.
JButton problemBrowseBtn
 The button to select an input problem file.
JButton outputBrowseBtn
 The button to select an output file.
JButton problemEditBtn
 The button to edit the problem file.
JButton agentEditBtn
 The button to edit the agent file.
JButton solveBtn
 The button to start solving.

Static Private Attributes

static final long serialVersionUID = 4194657988533551087L
 Serial version ID of JFrame.
static final String dotRendererClass = DOTrenderer.class.getName()
 Class name of DOT renderer used to display graphs.

Detailed Description

A simple GUI to configure and start FRODO.

Author
Andreas Schaedeli, Thomas Leaute
Todo

Add the possibility to interrupt an algorithm.

Replace GraphViz by JUNG? http://jung.sourceforge.net/

Display the console messages in a dedicated window?

Constructor & Destructor Documentation

◆ SimpleGUI() [1/2]

frodo2.gui.SimpleGUI.SimpleGUI ( String problemFilePath,
String agentFilePath,
String timeout )

Constructor defining and building the GUI.

Parameters
problemFilePathPath to problem file to use
agentFilePathPath to agent configuration file to use
timeoutTimeout value

References frodo2.timeout.

Referenced by editAgentFile(), main(), and solveProblem().

◆ SimpleGUI() [2/2]

frodo2.gui.SimpleGUI.SimpleGUI ( String problemFilePath,
String agentFilePath,
String timeout,
String outputFilePath )

Constructor defining and building the GUI.

Parameters
problemFilePathPath to problem file to use
agentFilePathPath to agent configuration file to use
timeoutTimeout value
outputFilePathPath to the output file. If null, no output file is created.

References agentEditBtn, agentError, agentList, agentNamesToPath, createAgentsList(), outputBrowseBtn, outputField, problemBrowseBtn, problemEditBtn, problemError, problemField, solveBtn, frodo2.timeout, timeoutError, and timeoutField.

Here is the call graph for this function:

Member Function Documentation

◆ actionPerformed()

void frodo2.gui.SimpleGUI.actionPerformed ( ActionEvent e)

This method is called whenever a button associated with this ActionListener is pressed.

Parameters
eAction event
Todo
Parse the visualizer class from the agent configuration file

References agentList, agentNamesToPath, editAgentFile(), editorDialog, editProblemFile(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.parse(), problemError, problemField, readLicense(), saveFile(), solveProblem(), tempAgentFile, and frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.toDOT().

Here is the call graph for this function:

◆ createAgentsList()

String[] frodo2.gui.SimpleGUI.createAgentsList ( )
private

This method creates the mapping from all currently implemented DCOP solving agents to their paths, and returns an array containing only the file names of the configuration files, in order to display them in the drop down list.

Returns
Array containing the names of all currently implemented DCOP solving agents

References agentNamesToPath.

Referenced by SimpleGUI().

◆ editAgentFile()

void frodo2.gui.SimpleGUI.editAgentFile ( boolean isCustomFile,
String filePath )
private

This method creates a dialog containing a text editor to edit the chosen agent configuration file.

Depending on whether the file is custom or built-in, it allows overwriting the existing file, saving the editor content in a specified location or in a temporary file.

Parameters
isCustomFiletrue if chosen agent configuration file is a custom file, false if it is a built-in file
filePathPath to the chosen agent configuration file

References agentError, editorDialog, editorPane, and SimpleGUI().

Referenced by actionPerformed().

Here is the call graph for this function:

◆ editProblemFile()

void frodo2.gui.SimpleGUI.editProblemFile ( )
private

This method creates a dialog containing a text editor to edit the chosen problem file.

It allows saving the changes by overwriting the existing file.

References editorDialog, editorPane, problemError, and problemField.

Referenced by actionPerformed().

◆ enableProblemDef()

void frodo2.gui.SimpleGUI.enableProblemDef ( boolean enabled)
private

Enables or disables input fields used to define the problem (problem instance, agent...).

Parameters
enabledwhether the input fields should be enabled

Referenced by solveProblem().

◆ itemStateChanged()

void frodo2.gui.SimpleGUI.itemStateChanged ( ItemEvent e)

This method is called when another item is selected from the list of available agent configuration files.

This is mainly used to add custom files.

Parameters
eItem event

References agentError, agentList, agentNamesToPath, and tempAgentFile.

◆ main()

void frodo2.gui.SimpleGUI.main ( String[] args)
static
Parameters
argsArray of parameters containing 3 optional arguments:
  • Path to problem file (must be the first or the only given file)
  • Path to agent configuration file (must be the second given file)
  • -timeout followed by TIMEOUT_VALUE (can be given in any position)

References SimpleGUI(), and frodo2.timeout.

Here is the call graph for this function:

◆ readLicense()

String frodo2.gui.SimpleGUI.readLicense ( )
private

This method reads the license from the file LICENSE.txt and displays it if the file exists and can be read.

Returns
String containing license text

Referenced by actionPerformed().

◆ saveFile()

void frodo2.gui.SimpleGUI.saveFile ( String filePath)
private

This method saves the current editor content to a file with the given path.

Existing files are overwritten.

Parameters
filePathPath and name of file where editor content should be saved

References editorDialog, and editorPane.

Referenced by actionPerformed().

◆ solveProblem()

void frodo2.gui.SimpleGUI.solveProblem ( )
private

This method first checks if all the necessary parameters (problem file, agent description file, timeout value) are valid.

If so, it slightly changes the agent configuration file in order to use a DOT renderer to display graphs, and then starts the solver.

Todo
Check that the output file path is valid

References agentError, agentList, agentNamesToPath, dotRendererClass, enableProblemDef(), frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.end(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.parse(), problemError, problemField, SimpleGUI(), tempAgentFile, timeoutError, and timeoutField.

Referenced by actionPerformed().

Here is the call graph for this function:

Member Data Documentation

◆ agentEditBtn

JButton frodo2.gui.SimpleGUI.agentEditBtn
private

The button to edit the agent file.

Referenced by SimpleGUI().

◆ agentError

JLabel frodo2.gui.SimpleGUI.agentError
private

Label indicating an error in chosen agent configuration file.

Referenced by editAgentFile(), itemStateChanged(), SimpleGUI(), and solveProblem().

◆ agentList

JComboBox<String> frodo2.gui.SimpleGUI.agentList
private

List of DCOP solving agents.

Referenced by actionPerformed(), itemStateChanged(), SimpleGUI(), and solveProblem().

◆ agentNamesToPath

Map<String, String> frodo2.gui.SimpleGUI.agentNamesToPath
private

Mapping from agent configuration file names to their absolute path.

Referenced by actionPerformed(), createAgentsList(), itemStateChanged(), SimpleGUI(), and solveProblem().

◆ dotRendererClass

final String frodo2.gui.SimpleGUI.dotRendererClass = DOTrenderer.class.getName()
staticprivate

Class name of DOT renderer used to display graphs.

Referenced by solveProblem().

◆ editorDialog

JDialog frodo2.gui.SimpleGUI.editorDialog
private

Dialog window containing a text editor to change problem and agent configuration files.

Referenced by actionPerformed(), editAgentFile(), editProblemFile(), and saveFile().

◆ editorPane

JTextPane frodo2.gui.SimpleGUI.editorPane
private

Pane containing a text editor to change problem and agent configuration files.

Referenced by editAgentFile(), editProblemFile(), and saveFile().

◆ outputBrowseBtn

JButton frodo2.gui.SimpleGUI.outputBrowseBtn
private

The button to select an output file.

Referenced by SimpleGUI().

◆ outputField

JTextField frodo2.gui.SimpleGUI.outputField
private

Text field containing path to the output file.

Referenced by SimpleGUI().

◆ problemBrowseBtn

JButton frodo2.gui.SimpleGUI.problemBrowseBtn
private

The button to select an input problem file.

Referenced by SimpleGUI().

◆ problemEditBtn

JButton frodo2.gui.SimpleGUI.problemEditBtn
private

The button to edit the problem file.

Referenced by SimpleGUI().

◆ problemError

JLabel frodo2.gui.SimpleGUI.problemError
private

Label indicating an error in chosen problem file.

Referenced by actionPerformed(), editProblemFile(), SimpleGUI(), and solveProblem().

◆ problemField

JTextField frodo2.gui.SimpleGUI.problemField
private

Text field containing path of problem file.

Referenced by actionPerformed(), editProblemFile(), SimpleGUI(), and solveProblem().

◆ serialVersionUID

final long frodo2.gui.SimpleGUI.serialVersionUID = 4194657988533551087L
staticprivate

Serial version ID of JFrame.

◆ solveBtn

JButton frodo2.gui.SimpleGUI.solveBtn
private

The button to start solving.

Referenced by SimpleGUI().

◆ tempAgentFile

String frodo2.gui.SimpleGUI.tempAgentFile = null
private

String indicating the path of a temporary agent configuration file, if used.

Referenced by actionPerformed(), itemStateChanged(), and solveProblem().

◆ timeoutError

JLabel frodo2.gui.SimpleGUI.timeoutError
private

Label indicating an erroneous timeout value.

Referenced by SimpleGUI(), and solveProblem().

◆ timeoutField

JTextField frodo2.gui.SimpleGUI.timeoutField
private

Specified timeout value.

Referenced by SimpleGUI(), and solveProblem().


The documentation for this class was generated from the following file: