unbbayes.controller
Class NetworkController

java.lang.Object
  extended by unbbayes.controller.NetworkController
All Implemented Interfaces:
KeyListener, EventListener

public class NetworkController
extends Object
implements KeyListener

This class is responsible for delegating instructions that is going to be executed in a SingleEntityNetwork or MultiEntityBayesianNetwork. Insert node and propagate evidences, for instance.

Version:
1.5 2006/09/12
Author:
Rommel Novaes Carvalho, Michael S. Onishi

Constructor Summary
protected NetworkController()
          This is the default constructor, initializing nothing.
  NetworkController(SingleEntityNetwork singleEntityNetwork, NetworkWindow screen)
          Constructs a controller for SingleEntityNetwork.
 
Method Summary
 Rectangle calculateNetRectangle()
          Method responsible for calculating the network border.
 void closeWarningDialog()
          Close current warning dialog.
 boolean compileNetwork()
          Compile the SingleEntityNetwork.
 void createContinuousDistribution(ContinuousNode node)
          Creates and shows the panel where the user can edit the continuous node normal distribution.
 void createDiscreteTable(Node node)
          Creates and shows the panel where the user can edit the discrete node table.
 void createTable(Node node)
          Creates and shows the panel to edit the node's table.
 void deleteSelected(Object selected)
          Delete the selected object from the network.
 void evaluateNetwork()
          Change the GUI to allow PN evaluation.
 BaseIO getBaseIO()
          This is the class responsible for storing the network controlled by this controller.
 Graph getGraph()
          Obtains the network in a Graph format
 IInferenceAlgorithm getInferenceAlgorithm()
           
 String getLog()
          This is just a delegator to getLogContent(), which is a delegator to SingleEntityNetwork.getLog().
protected  String getLogContent()
          This method is called inside showLog() to retrieve the content of LOG.
 Network getNetwork()
          Get the network being controlled.
 NetworkWindow getScreen()
          Get the network window.
 Node getSelectedNode()
          Returns the selected node.
 SENController getSENController()
           
 SingleEntityNetwork getSingleEntityNetwork()
          Get the single entity network.
 void initialize()
          Initialize the junction tree beliefs.
 Node insertContinuousNode(double x, double y)
          Insert a new continuous node in the SingleEntityNetwork with the standard label and description.
 Node insertDecisionNode(double x, double y)
          Insert a new decision node in the SingleEntityNetwork with the standard label and description.
 boolean insertEdge(Edge edge)
          Insert a new edge in the network.
 Node insertProbabilisticNode(double x, double y)
          Insert a new probabilistic node in the SingleEntityNetwork with the standard label and description.
 void insertState(Node node)
          Insert a new state for the given node.
 Node insertUtilityNode(double x, double y)
          Insert a new utility node in the SingleEntityNetwork with the standard label and description.
 void keyPressed(KeyEvent e)
          Delete all selected objects of the network when the key (KeyEvent.VK_DELETE) is pressed.
 void keyReleased(KeyEvent e)
          It does nothing when a key is released.
 void keyTyped(KeyEvent e)
          It does nothing when a key is typed.
 JTable makeTable(Node node)
          Construct a potential table of the given node.
 void openWarningDialog()
          Open Warning dialog.
 void previewPrintLog(JTextArea texto, JDialog dialog)
          Deprecated. moved to TextAreaDialog
 void previewPrintNet(JComponent rede, Rectangle retangulo)
          Preview the net printing.
 void previewPrintTable()
          Preview the table printing.
protected  void printLog(JTextArea textArea)
          Deprecated. this method was moved to TextAreaDialog
 void printNet(JComponent network, Rectangle rectangle)
          Print the given area of the given network.
 void printTable()
          Print the table.
 void propagate()
          Propagate the evidences of the SingleEntityNetwork.
 void removeState(Node node)
          Remove the last state from the given node.
protected  void saveComponentAsImage(Component comp, int width, int height, File file)
           
 void saveNetImage()
          Save the network image to a file.
 void saveTableImage()
          Save the table image to a file.
 void selectNode(Node node)
          Selects a node
 void setBaseIO(BaseIO baseIO)
          This is the class responsible for storing the network controlled by this controller.
 void setInferenceAlgorithm(IInferenceAlgorithm inferenceAlgorithm)
           
 void setScreen(NetworkWindow screen)
           
 void showExplanationProperties(ProbabilisticNode node)
          Show the explanation properties for the given node.
 JDialog showLog()
          Deprecated. avoid GUI methods in controllers. Use TextAreaDialog instead
 void unselectAll()
          Unselects all graphical elements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetworkController

protected NetworkController()
This is the default constructor, initializing nothing. This is made protected in order to make it easier to extend.


NetworkController

public NetworkController(SingleEntityNetwork singleEntityNetwork,
                         NetworkWindow screen)
Constructs a controller for SingleEntityNetwork.

Method Detail

getInferenceAlgorithm

public IInferenceAlgorithm getInferenceAlgorithm()

setInferenceAlgorithm

public void setInferenceAlgorithm(IInferenceAlgorithm inferenceAlgorithm)

getSENController

public SENController getSENController()

getSingleEntityNetwork

public SingleEntityNetwork getSingleEntityNetwork()
Get the single entity network.

Returns:
The single entity network.

getNetwork

public Network getNetwork()
Get the network being controlled.

Returns:
The network being controlled.

getGraph

public Graph getGraph()
Obtains the network in a Graph format

Returns:

initialize

public void initialize()
Initialize the junction tree beliefs.


createTable

public void createTable(Node node)
Creates and shows the panel to edit the node's table.

Parameters:
node - The table owner.

createContinuousDistribution

public void createContinuousDistribution(ContinuousNode node)
Creates and shows the panel where the user can edit the continuous node normal distribution.

Parameters:
node - The continuous node to create the distribution pane for.

createDiscreteTable

public void createDiscreteTable(Node node)
Creates and shows the panel where the user can edit the discrete node table.

Parameters:
node - The discrete node to create the table pan for.

makeTable

public JTable makeTable(Node node)
Construct a potential table of the given node.

Parameters:
node - The node to get the data for the table.

propagate

public void propagate()
Propagate the evidences of the SingleEntityNetwork.


compileNetwork

public boolean compileNetwork()
Compile the SingleEntityNetwork.

Returns:
True if it compiles with no error and false otherwise.

evaluateNetwork

public void evaluateNetwork()
Change the GUI to allow PN evaluation.


insertContinuousNode

public Node insertContinuousNode(double x,
                                 double y)
Insert a new continuous node in the SingleEntityNetwork with the standard label and description.

Parameters:
x - The x position of the new node.
y - The y position of the new node.

insertProbabilisticNode

public Node insertProbabilisticNode(double x,
                                    double y)
Insert a new probabilistic node in the SingleEntityNetwork with the standard label and description.

Parameters:
x - The x position of the new node.
y - The y position of the new node.

insertDecisionNode

public Node insertDecisionNode(double x,
                               double y)
Insert a new decision node in the SingleEntityNetwork with the standard label and description.

Parameters:
x - The x position of the new node.
y - The y position of the new node.

insertUtilityNode

public Node insertUtilityNode(double x,
                              double y)
Insert a new utility node in the SingleEntityNetwork with the standard label and description.

Parameters:
x - The x position of the new node.
y - The y position of the new node.

showExplanationProperties

public void showExplanationProperties(ProbabilisticNode node)
Show the explanation properties for the given node.

Parameters:
node - The node to show the explanation properties.

insertEdge

public boolean insertEdge(Edge edge)
                   throws Exception
Insert a new edge in the network.

Parameters:
edge - The new edge to be inserted.
Throws:
Exception

insertState

public void insertState(Node node)
Insert a new state for the given node.

Parameters:
node - The selected node to insert the new state.

removeState

public void removeState(Node node)
Remove the last state from the given node.

Parameters:
node - The selected node to remove the last state.

deleteSelected

public void deleteSelected(Object selected)
Delete the selected object from the network.

Parameters:
selected - The selected object to delete.

keyTyped

public void keyTyped(KeyEvent e)
It does nothing when a key is typed.

Specified by:
keyTyped in interface KeyListener
Parameters:
e - The KeyEvent that is passed from the KeyListener
See Also:
KeyEvent, KeyListener

keyPressed

public void keyPressed(KeyEvent e)
Delete all selected objects of the network when the key (KeyEvent.VK_DELETE) is pressed.

Specified by:
keyPressed in interface KeyListener
Parameters:
e - The KeyEvent that is passed from the KeyListener
See Also:
KeyEvent, KeyListener

keyReleased

public void keyReleased(KeyEvent e)
It does nothing when a key is released.

Specified by:
keyReleased in interface KeyListener
Parameters:
e - The KeyEvent that is passed from the KeyListener
See Also:
KeyEvent, KeyListener

getScreen

public NetworkWindow getScreen()
Get the network window.

Returns:
The network window.

saveNetImage

public void saveNetImage()
Save the network image to a file.


saveComponentAsImage

protected void saveComponentAsImage(Component comp,
                                    int width,
                                    int height,
                                    File file)

saveTableImage

public void saveTableImage()
Save the table image to a file.


getLogContent

protected String getLogContent()
This method is called inside showLog() to retrieve the content of LOG. Extend this method in order to customize the log message (e.g. customize where the log content is stored, and how to retrieve it)

Returns:
a non null string. If singleEntityNetwork is null, it returns an empty string.

getLog

public String getLog()
This is just a delegator to getLogContent(), which is a delegator to SingleEntityNetwork.getLog(). The visibility of getLogContent() was not altered, for backward compatibility.

Returns:
log content

showLog

public JDialog showLog()
Deprecated. avoid GUI methods in controllers. Use TextAreaDialog instead

Show every single step taken during the compilation of the SingleEntityNetwork.


openWarningDialog

public void openWarningDialog()
Open Warning dialog. Currently, this is only a stub.


closeWarningDialog

public void closeWarningDialog()
Close current warning dialog. This is a stub yet.


previewPrintLog

public void previewPrintLog(JTextArea texto,
                            JDialog dialog)
Deprecated. moved to TextAreaDialog

Preview the log printing.


previewPrintTable

public void previewPrintTable()
Preview the table printing.


previewPrintNet

public void previewPrintNet(JComponent rede,
                            Rectangle retangulo)
Preview the net printing.


printNet

public void printNet(JComponent network,
                     Rectangle rectangle)
Print the given area of the given network.

Parameters:
network - A component representing the graphical representation of the network to be printed.
rectangle - The area to be printed.

printTable

public void printTable()
Print the table.


printLog

protected void printLog(JTextArea textArea)
Deprecated. this method was moved to TextAreaDialog

Print the log contained in the given JTextArea.

Parameters:
textArea - The text area containing the log.

calculateNetRectangle

public Rectangle calculateNetRectangle()
Method responsible for calculating the network border. If there are selected objects, the resulting rectangle consider only these objects. Otherwise, all objects from the network are considered.


getSelectedNode

public Node getSelectedNode()
Returns the selected node.

Returns:
the selected node.

selectNode

public void selectNode(Node node)
Selects a node

Parameters:
node -

unselectAll

public void unselectAll()
Unselects all graphical elements


getBaseIO

public BaseIO getBaseIO()
This is the class responsible for storing the network controlled by this controller. setBaseIO(BaseIO) must be set to a correct controller depending to what type of network this controller is dealing.

Returns:
the baseIO

setBaseIO

public void setBaseIO(BaseIO baseIO)
This is the class responsible for storing the network controlled by this controller. setBaseIO(BaseIO) must be set to a correct controller depending to what type of network this controller is dealing.

Parameters:
baseIO - the baseIO to set

setScreen

public void setScreen(NetworkWindow screen)
Parameters:
screen - the screen to set


Copyright © 2001-2010 University of Brasilia - UnB. All Rights Reserved.