Class OSPControl

All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, Control, MainFrame, AppFrame, Hidable
Direct Known Subclasses:
AnimationControl, CalculationControl

public class OSPControl extends ControlFrame implements PropertyChangeListener, MainFrame
A Control that shows its parameters in a JTable. Custom buttons can be added.
Version:
1.0
Author:
Wolfgang Christian
See Also:
  • Constructor Details

    • OSPControl

      public OSPControl(Object _model)
      Constructs an OSPControl.
      Parameters:
      _model -
  • Method Details

    • getMainFrame

      public OSPFrame getMainFrame()
      Gets this frame. Implementation of MainFrame interface.
      Specified by:
      getMainFrame in interface MainFrame
      Returns:
      OSPFrame
    • loadDisplayMenu

      protected JMenu loadDisplayMenu()
      Adds a Display menu to the menu bar. Overrides OSPFrame method.
      Overrides:
      loadDisplayMenu in class ControlFrame
      Returns:
      the display menu
    • refreshGUI

      protected void refreshGUI()
      Refreshes the user interface in response to display changes such as Language.
      Overrides:
      refreshGUI in class ControlFrame
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Listens for property change events.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      e - the property change event
    • init

      protected void init()
      Initializes this control after all objects have been created. Override this method and change the default close operation if this control is used with an applet.
    • getModel

      public Object getModel()
    • setDividerLocation

      public void setDividerLocation(int loc)
      Sets the location of the divider between the control table and the message panel.
      Parameters:
      loc - int
    • setEditable

      public void setEditable(String parameter, boolean editable)
      Sets the editable property of the given parameter so that it can not be changed from within the GUI.
      Parameters:
      parameter - String
      editable - boolean
    • setLockValues

      public void setLockValues(boolean lock)
      Locks the control's interface. Values sent to the control will not update the display until the control is unlocked.
      Specified by:
      setLockValues in interface Control
      Parameters:
      lock - boolean
    • toString

      public String toString()
      Creates a string representation of the control parameters.
      Overrides:
      toString in class Component
      Returns:
      the control parameters
    • setValue

      public void setValue(String par, Object val)
      Adds a parameter to the input display.
      Specified by:
      setValue in interface Control
      Parameters:
      par - the parameter name
      val - the initial parameter value
    • setValue

      public void setValue(String par, boolean val)
      Adds an initial boolean value of a parameter to the input display.
      Specified by:
      setValue in interface Control
      Parameters:
      par - the parameter name
      val - the initial parameter value
    • setValue

      public void setValue(String par, double val)
      Adds an initial value of a parameter to the input display.
      Specified by:
      setValue in interface Control
      Parameters:
      par - the parameter name
      val - the initial parameter value
    • setValue

      public void setValue(String par, int val)
      Adds an initial value of a parameter to the input display.
      Specified by:
      setValue in interface Control
      Parameters:
      par - the parameter name
      val - the initial parameter value
    • removeParameter

      public void removeParameter(String par)
      Removes a parameter from the table.
      Parameters:
      par - the parameter name
    • getDouble

      public double getDouble(String par)
      Reads a parameter value from the input display.
      Specified by:
      getDouble in interface Control
      Parameters:
      par -
      Returns:
      double the value of of the parameter
    • getInt

      public int getInt(String par)
      Reads a parameter value from the input display.
      Specified by:
      getInt in interface Control
      Parameters:
      par -
      Returns:
      int the value of of the parameter
    • getObject

      public Object getObject(String par) throws UnsupportedOperationException
      Gets the object with the specified property name. Throws an UnsupportedOperationException if the named object has not been stored.
      Specified by:
      getObject in interface Control
      Parameters:
      par -
      Returns:
      the object
      Throws:
      UnsupportedOperationException
    • getString

      public String getString(String par)
      Reads a parameter value from the input display.
      Specified by:
      getString in interface Control
      Parameters:
      par - the parameter name
      Returns:
      String the value of of the parameter
    • getBoolean

      public boolean getBoolean(String par)
      Reads a parameter value from the input display.
      Specified by:
      getBoolean in interface Control
      Parameters:
      par - the parameter name
      Returns:
      the value of of the parameter
    • getPropertyNames

      public Collection<String> getPropertyNames()
      Reads the current property names.
      Specified by:
      getPropertyNames in interface Control
      Returns:
      the property names
    • getPropertyNamesRaw

      public Collection<String> getPropertyNamesRaw()
      Reads the current property names.
      Specified by:
      getPropertyNamesRaw in interface Control
      Returns:
      the property names
    • addButton

      public JButton addButton(String methodName, String text)
      Adds a custom button to the control's frame.
      Parameters:
      methodName - the name of the method; the method has no parameters
      text - the button's text label
      Returns:
      the custom button
    • addButton

      public JButton addButton(String methodName, String text, String toolTipText)
      Adds a custom button to the control's frame.
      Parameters:
      methodName - the name of the method; the method has no parameters
      text - the button's text label
      toolTipText - the button's tool tip text
      Returns:
      the custom button
    • addControlListener

      public void addControlListener(String methodName)
      Adds a ControlTableListener that invokes method in the control's model. The method in the model is invoked with the table's variable name passed as a parameter.
      Parameters:
      methodName - the name of the method; the method has no parameters
    • addControlListener

      public void addControlListener(String methodName, Object target)
      Adds a ControlTableListener that invokes method in the given object. The method in the target is invoked with the table's variable name passed as a parameter.
      Parameters:
      methodName - the name of the method; the method has no parameters
      target - the target for the method
    • println

      public void println(String s)
      Prints a line of text in the message area.
      Specified by:
      println in interface Control
      Parameters:
      s -
    • println

      public void println()
      Prints a blank line in the message area.
      Specified by:
      println in interface Control
    • print

      public void print(String s)
      Prints text in the message area.
      Specified by:
      print in interface Control
      Parameters:
      s -
    • clearMessages

      public void clearMessages()
      Remove all text from the message area.
      Specified by:
      clearMessages in interface Control
    • clearValues

      public void clearValues()
      Remove all text from the data input area.
      Specified by:
      clearValues in interface Control
    • calculationDone

      public void calculationDone(String message)
      A signal that a method has completed. A message is printed in the message area.
      Specified by:
      calculationDone in interface Control
      Parameters:
      message -
    • getLoader

      public static XML.ObjectLoader getLoader()
      Returns an XML.ObjectLoader to save and load data for this object.
      Returns:
      the object loader
    • createApp

      public static OSPControl createApp(Object model)
      Creates an OSP control and establishes communication between the control and the model. Custom buttons are usually added to this control to invoke actions in the model.
      Parameters:
      model - Object
      Returns:
      AnimationControl