Package controller

Class MainScreenController

java.lang.Object
controller.MainScreenController
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.WindowListener, java.util.EventListener, javax.swing.event.DocumentListener

public class MainScreenController
extends java.lang.Object
implements java.awt.event.ActionListener, javax.swing.event.DocumentListener, java.awt.event.WindowListener
Class providing the controller for the processes related to the main screen of the system (namely, the probing and diagnosis per se, together with the display of the technical logs)
  • Constructor Summary

    Constructors 
    Constructor Description
    MainScreenController​(MainScreen scr, PrologJavaRunner expert)
    Creates a controller object with the main screen GUI and the expert system as parameters
  • Method Summary

    Modifier and Type Method Description
    void actionPerformed​(java.awt.event.ActionEvent e)
    Invoked when an action occurs
    void changedUpdate​(javax.swing.event.DocumentEvent e)
    Gives notification that an attribute or set of attributes changed
    boolean checkResponse​(java.lang.String responseStr)
    Returns true if the patient's vital sign, as supplied by the user, is a nonnegative number; false, otherwise
    void displayDiagnosis()
    Displays the final diagnosis of the medical expert system
    void displayEmergency()
    Updates the log and displays a popup message should the patient report experiencing a symptom that is indicative of an emergency
    void insertUpdate​(javax.swing.event.DocumentEvent e)
    Gives notification that there was an insert into the document
    void removeUpdate​(javax.swing.event.DocumentEvent e)
    Gives notification that a portion of the document has been removed
    void setQuestionNature​(java.lang.String symptom)
    Enables and disables buttons on the screen depending on the nature of the question, given the current symptom being probed
    void windowActivated​(java.awt.event.WindowEvent e)
    Invoked when the Window is set to be the active Window
    void windowClosed​(java.awt.event.WindowEvent e)
    Invoked when a window has been closed as the result of calling dispose on the window
    void windowClosing​(java.awt.event.WindowEvent e)
    Invoked when the user attempts to close the window from the window's system menu
    void windowDeactivated​(java.awt.event.WindowEvent e)
    Invoked when a window is no longer the active window
    void windowDeiconified​(java.awt.event.WindowEvent e)
    Invoked when a window is changed from a minimized to a normal state
    void windowIconified​(java.awt.event.WindowEvent e)
    Invoked when a window is changed from a normal to a minimized state
    void windowOpened​(java.awt.event.WindowEvent e)
    Invoked when a window is made visible

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MainScreenController

      public MainScreenController​(MainScreen scr, PrologJavaRunner expert)
      Creates a controller object with the main screen GUI and the expert system as parameters
      Parameters:
      scr - graphical user interface for the main screen
      expert - expert system featuring a Java interface and a Prolog knowledge base
  • Method Details

    • windowClosing

      public void windowClosing​(java.awt.event.WindowEvent e)
      Invoked when the user attempts to close the window from the window's system menu
      Specified by:
      windowClosing in interface java.awt.event.WindowListener
      Parameters:
      e - window event indicative of a change in status
    • windowActivated

      public void windowActivated​(java.awt.event.WindowEvent e)
      Invoked when the Window is set to be the active Window
      Specified by:
      windowActivated in interface java.awt.event.WindowListener
      Parameters:
      e - window event indicative of a change in status
    • windowClosed

      public void windowClosed​(java.awt.event.WindowEvent e)
      Invoked when a window has been closed as the result of calling dispose on the window
      Specified by:
      windowClosed in interface java.awt.event.WindowListener
      Parameters:
      e - window event indicative of a change in status
    • windowDeactivated

      public void windowDeactivated​(java.awt.event.WindowEvent e)
      Invoked when a window is no longer the active window
      Specified by:
      windowDeactivated in interface java.awt.event.WindowListener
      Parameters:
      e - window event indicative of a change in status
    • windowDeiconified

      public void windowDeiconified​(java.awt.event.WindowEvent e)
      Invoked when a window is changed from a minimized to a normal state
      Specified by:
      windowDeiconified in interface java.awt.event.WindowListener
      Parameters:
      e - window event indicative of a change in status
    • windowIconified

      public void windowIconified​(java.awt.event.WindowEvent e)
      Invoked when a window is changed from a normal to a minimized state
      Specified by:
      windowIconified in interface java.awt.event.WindowListener
      Parameters:
      e - window event indicative of a change in status
    • windowOpened

      public void windowOpened​(java.awt.event.WindowEvent e)
      Invoked when a window is made visible
      Specified by:
      windowOpened in interface java.awt.event.WindowListener
      Parameters:
      e - window event indicative of a change in status
    • actionPerformed

      public void actionPerformed​(java.awt.event.ActionEvent e)
      Invoked when an action occurs
      Specified by:
      actionPerformed in interface java.awt.event.ActionListener
      Parameters:
      e - semantic event indicative that a component-defined action occurred
    • insertUpdate

      public void insertUpdate​(javax.swing.event.DocumentEvent e)
      Gives notification that there was an insert into the document
      Specified by:
      insertUpdate in interface javax.swing.event.DocumentListener
      Parameters:
      e - document event corresponding to a document change
    • removeUpdate

      public void removeUpdate​(javax.swing.event.DocumentEvent e)
      Gives notification that a portion of the document has been removed
      Specified by:
      removeUpdate in interface javax.swing.event.DocumentListener
      Parameters:
      e - document event corresponding to a document change
    • changedUpdate

      public void changedUpdate​(javax.swing.event.DocumentEvent e)
      Gives notification that an attribute or set of attributes changed
      Specified by:
      changedUpdate in interface javax.swing.event.DocumentListener
      Parameters:
      e - document event corresponding to a document change
    • setQuestionNature

      public void setQuestionNature​(java.lang.String symptom)
      Enables and disables buttons on the screen depending on the nature of the question, given the current symptom being probed

      In particular, if the question is of a dichotomous nature, only the yes and no buttons are enabled. If the question is open-ended (for example, it is asking for the body temperature or the heart rate), then only the submit button is enabled.

      Parameters:
      symptom - current symptom being probed
    • displayDiagnosis

      public void displayDiagnosis()
      Displays the final diagnosis of the medical expert system
    • displayEmergency

      public void displayEmergency()
      Updates the log and displays a popup message should the patient report experiencing a symptom that is indicative of an emergency
    • checkResponse

      public boolean checkResponse​(java.lang.String responseStr)
      Returns true if the patient's vital sign, as supplied by the user, is a nonnegative number; false, otherwise
      Parameters:
      responseStr - patient's vital sign, as supplied by the user
      Returns:
      true if the patient's vital sign, as supplied by the user, is a nonnegative number; false, otherwise