org.opensourcephysics.controls
Class OSPControl

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended byorg.opensourcephysics.display.OSPFrame
                          extended byorg.opensourcephysics.controls.ControlFrame
                              extended byorg.opensourcephysics.controls.OSPControl
All Implemented Interfaces:
javax.accessibility.Accessible, Control, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.beans.PropertyChangeListener, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants
Direct Known Subclasses:
AnimationControl, CalculationControl

public class OSPControl
extends ControlFrame
implements java.beans.PropertyChangeListener

A Control that shows its parameters in a JTable. Custom bottons can be added.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class org.opensourcephysics.controls.ControlFrame
clearItem, copyItem, displayMenu, editMenu, fileMenu, inspectItem, languageItems, languageMenu, logToFileItem, model, ospApp, readItem, saveAsItem, sizeDownItem, sizeUpItem, xmlDefault
 
Fields inherited from class org.opensourcephysics.display.OSPFrame
animated, applet, appletMode, authorMode, autoclear, buttonPanel, chooserDir, constructorThreadGroup, customButtons, DEFAULT_LOOK_AND_FEEL, defaultLocales, keepHidden, launcherMode, osp_icon_file, strategy
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OSPControl(java.lang.Object _model)
          Constructs an OSPControl.
 
Method Summary
 javax.swing.JButton addButton(java.lang.String methodName, java.lang.String text)
          Adds a custom button to the control's frame.
 javax.swing.JButton addButton(java.lang.String methodName, java.lang.String text, java.lang.String toolTipText)
          Adds a custom button to the control's frame.
 void addControlListener(java.lang.String methodName)
          Adds a ControlTableListener that invokes method in the control's model.
 void addControlListener(java.lang.String methodName, java.lang.Object target)
          Adds a ControlTableListener that invokes method in the given object.
 void calculationDone(java.lang.String message)
          A signal that a method has completed.
 void clearMessages()
          Remove all text from the message area.
 void clearValues()
          Remove all text from the data input area.
static OSPControl createApp(java.lang.Object model)
          Creates an OSP control and establishes communication between the control and the model.
 boolean getBoolean(java.lang.String par)
          Reads a parameter value from the input display.
 double getDouble(java.lang.String par)
          Reads a parameter value from the input display.
 int getInt(java.lang.String par)
          Reads a parameter value from the input display.
static XML.ObjectLoader getLoader()
          Returns an XML.ObjectLoader to save and load data for this object.
 java.lang.Object getModel()
           
 java.lang.Object getObject(java.lang.String par)
          Gets the object with the specified property name.
 java.util.Collection getPropertyNames()
          Reads the current property names.
 java.lang.String getString(java.lang.String par)
          Reads a parameter value from the input display.
protected  void init()
          Initializes this control after all objects have been created.
protected  javax.swing.JMenu loadDisplayMenu()
          Adds a Display menu to the menu bar.
 void print(java.lang.String s)
          Prints text in the message area.
 void println()
          Prints a blank line in the message area.
 void println(java.lang.String s)
          Prints a line of text in the message area.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Listens for property change events.
protected  void refreshGUI()
          Refreshes the user interface in response to display changes such as Language.
 void removeParameter(java.lang.String par)
          Removes a parameter from the table.
 void setDividerLocation(int loc)
          Sets the location of the divider between the control table and the message panel.
 void setEditable(java.lang.String parameter, boolean editable)
          Sets the editable property of the given parameter so that it can not be changed from within the GUI.
 void setLockValues(boolean lock)
          Locks the control's interface.
 void setValue(java.lang.String par, boolean val)
          Adds an initial boolean value of a parameter to the input display.
 void setValue(java.lang.String par, double val)
          Adds an initial value of a parameter to the input display.
 void setValue(java.lang.String par, int val)
          Adds an initial value of a parameter to the input display.
 void setValue(java.lang.String par, java.lang.Object val)
          Adds a parameter to the input display.
 java.lang.String toString()
          Creates a string representation of the control parameters.
 
Methods inherited from class org.opensourcephysics.controls.ControlFrame
copy, getOSPApp, inspectXML, loadXML, loadXML, loadXML, readParameters, save, saveXML, showAboutDialog
 
Methods inherited from class org.opensourcephysics.display.OSPFrame
addButton, bufferStrategyShow, clearData, clearDataAndRepaint, createBufferStrategy, dispose, getChooser, getConstructorThreadGroup, getDefaultLocales, getMenu, invalidateImage, isAnimated, isAuthorMode, isAutoclear, isIconified, isKeepHidden, isLauncherMode, loadToolsMenu, parseXMLMenu, parseXMLMenu, print, removeMenu, removeMenuItem, render, setAnimated, setAuthorMode, setAutoclear, setDefaultCloseOperation, setFontLevel, setKeepHidden, setLauncherMode, setSize, setTitle, setVisible, show, wishesToExit
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

OSPControl

public OSPControl(java.lang.Object _model)
Constructs an OSPControl.

Parameters:
_model -
Method Detail

loadDisplayMenu

protected javax.swing.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(java.beans.PropertyChangeEvent e)
Listens for property change events.

Specified by:
propertyChange in interface java.beans.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 java.lang.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(java.lang.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 java.lang.String toString()
Creates a string representation of the control parameters.

Returns:
the control parameters

setValue

public void setValue(java.lang.String par,
                     java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.String par)
Removes a parameter from the table.

Parameters:
par - the parameter name

getDouble

public double getDouble(java.lang.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(java.lang.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 java.lang.Object getObject(java.lang.String par)
                           throws java.lang.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:
java.lang.UnsupportedOperationException

getString

public java.lang.String getString(java.lang.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(java.lang.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 java.util.Collection getPropertyNames()
Reads the current property names.

Specified by:
getPropertyNames in interface Control
Returns:
the property names

addButton

public javax.swing.JButton addButton(java.lang.String methodName,
                                     java.lang.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 javax.swing.JButton addButton(java.lang.String methodName,
                                     java.lang.String text,
                                     java.lang.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(java.lang.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(java.lang.String methodName,
                               java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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