Package org.opensourcephysics.controls
Class AbstractCalculation
java.lang.Object
org.opensourcephysics.controls.AbstractCalculation
- All Implemented Interfaces:
Calculation
AbstractCalculation is a template for simple calculations.
Implement the calculate method to create a calculation.
- Version:
- 1.0
- Author:
- Wolfgang Christian
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChildFrame
(JFrame frame) Adds a child frame that depends on the main frame.abstract void
Does the calculation.void
Clears the child frames from the main frame.Gets a copy of the ChildFrames collection.static XML.ObjectLoader
Returns an XML.ObjectLoader to save and load data for this object.Gets the main OSPFrame.int[]
Gets the Main Frame size.Gets the main OSPFrame.void
reset()
Resets the program to its default state.void
Resets the calculation to a predefined state.void
setControl
(Control control) Sets object that controls this calculation.
-
Field Details
-
mainFrame
-
control
-
decimalFormat
-
-
Constructor Details
-
AbstractCalculation
public AbstractCalculation()
-
-
Method Details
-
setControl
Sets object that controls this calculation. The calculation should use this method to register its parameters with the control. This insures that the control displays the program's parameters when it appears onscreen.- Specified by:
setControl
in interfaceCalculation
- Parameters:
control
-
-
getMainFrame
Gets the main OSPFrame. The main frame will usually exit program when it is closed.- Returns:
- OSPFrame
-
getMainFrameSize
public int[] getMainFrameSize()Gets the Main Frame size. -
addChildFrame
Adds a child frame that depends on the main frame. Child frames are closed when this frame is closed.- Parameters:
frame
- JFrame
-
getOSPApp
Gets the main OSPFrame. The main frame will usually exit program when it is closed.- Returns:
- OSPFrame
-
clearChildFrames
public void clearChildFrames()Clears the child frames from the main frame. -
getChildFrames
Gets a copy of the ChildFrames collection.- Returns:
- Collection
-
calculate
public abstract void calculate()Does the calculation.- Specified by:
calculate
in interfaceCalculation
-
resetCalculation
public void resetCalculation()Resets the calculation to a predefined state.- Specified by:
resetCalculation
in interfaceCalculation
-
reset
public void reset()Resets the program to its default state. Override this method to set the program's parameters. -
getLoader
Returns an XML.ObjectLoader to save and load data for this object.- Returns:
- the object loader
-