org.opensourcephysics.controls
Class AbstractCalculation

java.lang.Object
  extended by org.opensourcephysics.controls.AbstractCalculation
All Implemented Interfaces:
Calculation

public abstract class AbstractCalculation
extends java.lang.Object
implements Calculation

AbstractCalculation is a template for simple calculations. Implement the calculate method to create a calculation.

Version:
1.0
Author:
Wolfgang Christian

Field Summary
protected  Control control
           
protected  java.text.DecimalFormat decimalFormat
           
protected  OSPFrame mainFrame
           
 
Constructor Summary
AbstractCalculation()
           
 
Method Summary
 void addChildFrame(javax.swing.JFrame frame)
          Adds a child frame that depends on the main frame.
abstract  void calculate()
          Does the calculation.
 void clearChildFrames()
          Clears the child frames from the main frame.
 java.util.Collection<javax.swing.JFrame> getChildFrames()
          Gets a copy of the ChildFrames collection.
static XML.ObjectLoader getLoader()
          Returns an XML.ObjectLoader to save and load data for this object.
 OSPFrame getMainFrame()
          Gets the main OSPFrame.
 OSPApplication getOSPApp()
          Gets the main OSPFrame.
 void reset()
          Resets the program to its default state.
 void resetCalculation()
          Resets the calculation to a predefined state.
 void setControl(Control control)
          Sets object that controls this calculation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainFrame

protected OSPFrame mainFrame

control

protected Control control

decimalFormat

protected java.text.DecimalFormat decimalFormat
Constructor Detail

AbstractCalculation

public AbstractCalculation()
Method Detail

setControl

public void setControl(Control control)
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 interface Calculation
Parameters:
control -

getMainFrame

public OSPFrame getMainFrame()
Gets the main OSPFrame. The main frame will usually exit program when it is closed.

Returns:
OSPFrame

addChildFrame

public void addChildFrame(javax.swing.JFrame frame)
Adds a child frame that depends on the main frame. Child frames are closed when this frame is closed.

Parameters:
frame - JFrame

getOSPApp

public OSPApplication 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

public java.util.Collection<javax.swing.JFrame> getChildFrames()
Gets a copy of the ChildFrames collection.

Returns:
Collection

calculate

public abstract void calculate()
Does the calculation.

Specified by:
calculate in interface Calculation

resetCalculation

public void resetCalculation()
Resets the calculation to a predefined state.

Specified by:
resetCalculation in interface Calculation

reset

public void reset()
Resets the program to its default state. Override this method to set the program's parameters.


getLoader

public static XML.ObjectLoader getLoader()
Returns an XML.ObjectLoader to save and load data for this object.

Returns:
the object loader