Package org.opensourcephysics.controls
Class OSPControl
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
org.opensourcephysics.display.OSPFrame
org.opensourcephysics.controls.ControlFrame
org.opensourcephysics.controls.OSPControl
- All Implemented Interfaces:
ImageObserver,MenuContainer,PropertyChangeListener,Serializable,EventListener,Accessible,RootPaneContainer,WindowConstants,Control,MainFrame,AppFrame,Hidable
- Direct Known Subclasses:
AnimationControl,CalculationControl
A Control that shows its parameters in a JTable. Custom buttons can be added.
- Version:
- 1.0
- Author:
- Wolfgang Christian
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrameNested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrameNested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
Fields inherited from class org.opensourcephysics.controls.ControlFrame
clearItem, copyItem, displayMenu, editMenu, fileMenu, inspectItem, languageItems, languageMenu, model, ospApp, printFrameItem, readItem, saveAsItem, saveFrameAsEPSItem, sizeDownItem, sizeUpItem, xmlDefaultFields inherited from class org.opensourcephysics.display.OSPFrame
action, animated, autoclear, buttonPanel, childFrames, constructorThreadGroup, customButtons, keepHidden, myFontLevel, strategyFields inherited from class javax.swing.JFrame
accessibleContext, rootPane, rootPaneCheckingEnabledFields 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_CURSORFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface org.opensourcephysics.controls.Control
NOT_EDITABLE_BACKGROUNDFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a custom button to the control's frame.Adds a custom button to the control's frame.voidaddControlListener(String methodName) Adds a ControlTableListener that invokes method in the control's model.voidaddControlListener(String methodName, Object target) Adds a ControlTableListener that invokes method in the given object.voidcalculationDone(String message) A signal that a method has completed.voidRemove all text from the message area.voidRemove all text from the data input area.static OSPControlCreates an OSP control and establishes communication between the control and the model.booleangetBoolean(String par) Reads a parameter value from the input display.doubleReads a parameter value from the input display.intReads a parameter value from the input display.static XML.ObjectLoaderReturns an XML.ObjectLoader to save and load data for this object.Gets this frame.getModel()Gets the object with the specified property name.Reads the current property names.Reads the current property names.Reads a parameter value from the input display.protected voidinit()Initializes this control after all objects have been created.protected JMenuAdds a Display menu to the menu bar.voidPrints text in the message area.voidprintln()Prints a blank line in the message area.voidPrints a line of text in the message area.voidListens for property change events.protected voidRefreshes the user interface in response to display changes such as Language.voidremoveParameter(String par) Removes a parameter from the table.voidsetDividerLocation(int loc) Sets the location of the divider between the control table and the message panel.voidsetEditable(String parameter, boolean editable) Sets the editable property of the given parameter so that it can not be changed from within the GUI.voidsetLockValues(boolean lock) Locks the control's interface.voidAdds an initial boolean value of a parameter to the input display.voidAdds an initial value of a parameter to the input display.voidAdds an initial value of a parameter to the input display.voidAdds a parameter to the input display.toString()Creates a string representation of the control parameters.Methods inherited from class org.opensourcephysics.controls.ControlFrame
copy, getOSPApp, inspectXML, loadXML, loadXML, loadXML, loadXML, readParameters, save, saveXMLMethods inherited from class org.opensourcephysics.display.OSPFrame
addButton, addChildFrame, bufferStrategyShow, clearChildFrames, clearData, clearDataAndRepaint, createBufferStrategy, dispose, getChildFrames, getChooser, getConstructorThreadGroup, getMenu, invalidateImage, isAnimated, isAutoclear, isIconified, isKeepHidden, loadToolsMenu, parseXMLMenu, parseXMLMenu, removeMenu, removeMenuItem, render, setAnimated, setAutoclear, setDefaultCloseOperation, setFontLevel, setKeepHidden, setResizeAction, setSize, setTitle, setVisible, show, wishesToExitMethods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updateMethods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setUndecoratedMethods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setType, toBack, toFrontMethods 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, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTreeMethods 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opensourcephysics.display.AppFrame
getDefaultCloseOperationMethods inherited from interface org.opensourcephysics.controls.MainFrame
addChildFrame, clearChildFrames, getChildFrames, getOSPAppMethods inherited from interface java.awt.MenuContainer
getFont, postEvent
-
Constructor Details
-
OSPControl
Constructs an OSPControl.- Parameters:
_model-
-
-
Method Details
-
getMainFrame
Gets this frame. Implementation of MainFrame interface.- Specified by:
getMainFramein interfaceMainFrame- Returns:
- OSPFrame
-
loadDisplayMenu
Adds a Display menu to the menu bar. Overrides OSPFrame method.- Overrides:
loadDisplayMenuin classControlFrame- Returns:
- the display menu
-
refreshGUI
protected void refreshGUI()Refreshes the user interface in response to display changes such as Language.- Overrides:
refreshGUIin classControlFrame
-
propertyChange
Listens for property change events.- Specified by:
propertyChangein interfacePropertyChangeListener- 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
-
setDividerLocation
public void setDividerLocation(int loc) Sets the location of the divider between the control table and the message panel.- Parameters:
loc- int
-
setEditable
Sets the editable property of the given parameter so that it can not be changed from within the GUI.- Parameters:
parameter- Stringeditable- 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:
setLockValuesin interfaceControl- Parameters:
lock- boolean
-
toString
Creates a string representation of the control parameters. -
setValue
Adds a parameter to the input display. -
setValue
Adds an initial boolean value of a parameter to the input display. -
setValue
Adds an initial value of a parameter to the input display. -
setValue
Adds an initial value of a parameter to the input display. -
removeParameter
Removes a parameter from the table.- Parameters:
par- the parameter name
-
getDouble
Reads a parameter value from the input display. -
getInt
Reads a parameter value from the input display. -
getObject
Gets the object with the specified property name. Throws an UnsupportedOperationException if the named object has not been stored.- Specified by:
getObjectin interfaceControl- Parameters:
par-- Returns:
- the object
- Throws:
UnsupportedOperationException
-
getString
Reads a parameter value from the input display. -
getBoolean
Reads a parameter value from the input display.- Specified by:
getBooleanin interfaceControl- Parameters:
par- the parameter name- Returns:
- the value of of the parameter
-
getPropertyNames
Reads the current property names.- Specified by:
getPropertyNamesin interfaceControl- Returns:
- the property names
-
getPropertyNamesRaw
Reads the current property names.- Specified by:
getPropertyNamesRawin interfaceControl- Returns:
- the property names
-
addButton
Adds a custom button to the control's frame.- Parameters:
methodName- the name of the method; the method has no parameterstext- the button's text label- Returns:
- the custom button
-
addButton
Adds a custom button to the control's frame.- Parameters:
methodName- the name of the method; the method has no parameterstext- the button's text labeltoolTipText- the button's tool tip text- Returns:
- the custom button
-
addControlListener
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
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 parameterstarget- the target for the method
-
println
Prints a line of text in the message area. -
println
public void println()Prints a blank line in the message area. -
print
Prints text in the message area. -
clearMessages
public void clearMessages()Remove all text from the message area.- Specified by:
clearMessagesin interfaceControl
-
clearValues
public void clearValues()Remove all text from the data input area.- Specified by:
clearValuesin interfaceControl
-
calculationDone
A signal that a method has completed. A message is printed in the message area.- Specified by:
calculationDonein interfaceControl- Parameters:
message-
-
getLoader
Returns an XML.ObjectLoader to save and load data for this object.- Returns:
- the object loader
-
createApp
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
-