Class Shoot

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--BaseApplet
                                |
                                +--BaseApplet2
                                      |
                                      +--Shoot

public class Shoot
extends BaseApplet2
implements EnergyListener

Applet to illustrate the shooting method. Displays a schematic of the potential function, with a marker indicating the selected energy level. The Schrodinger equation is "solved" for this energy level, and the resulting function is displayed. (The function is not actually a solution unless it tends to zero towards the extremes of the x axis.

Features include a quadratic potential, the option to plot psi or psi2, and the ability to solve the equation (ie. find energy for which the above condition holds).

See Also:
Serialized Form

Inner Class Summary
protected  class Shoot.EnergyChangeListener
          Listener for changes to the position of the energy slider.
protected  class Shoot.WellResizeListener
          Listener for changes to the position of the "well width" slider.
 
Inner classes inherited from class BaseApplet2
BaseApplet2.FixedButton, BaseApplet2.FixedCheckbox, BaseApplet2.GraphClickListener
 
Inner classes inherited from class BaseApplet
BaseApplet.MozillaWorkaround, BaseApplet.ResizeListener
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
protected static java.awt.Color AXES_COL
           
protected  java.awt.Button chooser
           
protected static int DEFAULT_NWELLS
           
protected static int DEFAULT_STEPS
           
protected  java.awt.TextField depthField
           
protected  java.awt.Label depthLabel
           
protected  java.awt.Button drawButton
           
protected static java.awt.Color ENERGY_COL
           
protected  Shoot.EnergyChangeListener energyChangeListener
          Listener for changes to the position of the energy slider.
protected  java.awt.TextField energyField
           
protected  Schrodinger eqn
          Instance of Schrodinger to use to generate solution data
protected  boolean freehandEnabled
           
protected  BaseApplet2.GraphClickListener freehandListener
           
protected  Function function
          The (piecewise-constant) potential function
protected  int functionIndex
           
protected  java.lang.String[] functionNames
           
protected  Function[] functions
          The (quadratic) potential function
protected  int hSpace1
           
protected  int hSpace2
           
protected  java.awt.TextField intWidthField
           
protected static int MAX_WELLS
           
protected  java.awt.TextField nWellsField
           
protected  java.awt.TextField periodField
           
protected  Plotter2 plotter
           
protected static java.awt.Color POT_COL
           
protected  Plotter2 potPlotter
           
protected  java.awt.Checkbox quadBox
           
protected  java.awt.Button refreshButton
           
protected  double selectedY1
          The first limit for the search interval.
protected  double selectedY2
          The second limit for the search interval.
protected  java.awt.Button solveButton
           
protected  SolnSearcher solveThread
          Thread currently searching for a solution, or null if there is no search in progress.
protected  java.awt.Checkbox squareValues
           
protected  int steps
          The number of x values to sample
protected  java.awt.TextField stepsField
           
protected  int vSpace1
           
protected  int vSpace2
           
protected static java.awt.Color WAVE_FN_COL
           
protected static java.awt.Color WELL_BOUNDS_COL
           
protected  Shoot.WellResizeListener wellResizeListener
          Listener for changes to the position of the "well width" slider.
protected  java.awt.TextField widthField
           
 
Fields inherited from class BaseApplet2
boxes, buttons, enablePrompt, fields, focus, panel, statusLabel, useSwing, V_MARGIN
 
Fields inherited from class BaseApplet
buffer, GRAPH_MARGIN, refresh, resizeListener, safetyLimit, useBuffer
 
Fields inherited from class java.applet.Applet
serialVersionUID, stub
 
Fields inherited from class java.awt.Panel
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
Shoot()
           
 
Method Summary
 void abortSolving()
          Stops a running search.
 void actionPerformed(java.awt.event.ActionEvent ae)
          Subclasses should at least provide an empty implementation of this method.
 java.lang.String[] createFunctionNames()
           
 Function[] createFunctions()
           
 void doPaint(java.awt.Graphics g)
          Called by forcePaint() to actually perform the painting.
 void energyChanged(double newEnergy)
          Called to signal that the best estimate for the energy has changed.
 void init()
          Performs extra initialisation, including adding a panel to the bottom of the applet.
 boolean isSquare()
          Returns true if the potential model consists of square wells.
protected  void potentialChanged()
           
protected  void safeUpdateInput()
          Attempts to update the parameters from the text fields.
 void searchFinished()
          Called to signal that the search has finished.s
 void setFunction(Function f)
           
 void solve()
          Attempts to find an energy for which the Schrodinger equation has a solution.
 void start()
          Applets should use this method to perform any final initialisation necessary to "activate" the applet
 void stop()
          When this method is called, the applet should cease any user interaction.
 void updateInput()
          Reads in (and validates) input from the text fields.
 
Methods inherited from class BaseApplet2
add, add, addButton, addCheckbox, addField, addField, addField, addListeners, focusGained, focusLost, getDouble, getGraphHeight, getInt, lockControls, makeButton, makePanel, paintDashedLineH, paintDashedLineV, register, removeListeners, setComponentsEnabled, setLayout, setPromptEnabled, textValueChanged, toString, unlockControls
 
Methods inherited from class BaseApplet
changeFont, forcePaint, getAppletInfo, getParameterInfo, itemStateChanged, paint, refresh, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getCursorTarget, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paintComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printOneComponent, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, remove, removeAll, removeContainerListener, removeNotify, setCursor, setFocusOwner, setFont, transferFocus, updateCursor, validate, validateTree, writeObject
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

hSpace1

protected int hSpace1

hSpace2

protected int hSpace2

vSpace1

protected int vSpace1

vSpace2

protected int vSpace2

steps

protected int steps
The number of x values to sample

energyField

protected java.awt.TextField energyField

depthField

protected java.awt.TextField depthField

widthField

protected java.awt.TextField widthField

intWidthField

protected java.awt.TextField intWidthField

nWellsField

protected java.awt.TextField nWellsField

stepsField

protected java.awt.TextField stepsField

periodField

protected java.awt.TextField periodField

squareValues

protected java.awt.Checkbox squareValues

quadBox

protected java.awt.Checkbox quadBox

refreshButton

protected java.awt.Button refreshButton

solveButton

protected java.awt.Button solveButton

drawButton

protected java.awt.Button drawButton

chooser

protected java.awt.Button chooser

depthLabel

protected java.awt.Label depthLabel

wellResizeListener

protected Shoot.WellResizeListener wellResizeListener
Listener for changes to the position of the "well width" slider.

energyChangeListener

protected Shoot.EnergyChangeListener energyChangeListener
Listener for changes to the position of the energy slider.

freehandListener

protected BaseApplet2.GraphClickListener freehandListener

eqn

protected Schrodinger eqn
Instance of Schrodinger to use to generate solution data

solveThread

protected SolnSearcher solveThread
Thread currently searching for a solution, or null if there is no search in progress.

selectedY1

protected double selectedY1
The first limit for the search interval.

selectedY2

protected double selectedY2
The second limit for the search interval.

freehandEnabled

protected boolean freehandEnabled

plotter

protected Plotter2 plotter

potPlotter

protected Plotter2 potPlotter

functionIndex

protected int functionIndex

function

protected Function function
The (piecewise-constant) potential function

functions

protected Function[] functions
The (quadratic) potential function

functionNames

protected java.lang.String[] functionNames

POT_COL

protected static java.awt.Color POT_COL

ENERGY_COL

protected static java.awt.Color ENERGY_COL

AXES_COL

protected static java.awt.Color AXES_COL

WAVE_FN_COL

protected static java.awt.Color WAVE_FN_COL

WELL_BOUNDS_COL

protected static java.awt.Color WELL_BOUNDS_COL

DEFAULT_STEPS

protected static int DEFAULT_STEPS

DEFAULT_NWELLS

protected static int DEFAULT_NWELLS

MAX_WELLS

protected static int MAX_WELLS
Constructor Detail

Shoot

public Shoot()
Method Detail

init

public void init()
Description copied from class: BaseApplet2
Performs extra initialisation, including adding a panel to the bottom of the applet.
Overrides:
init in class BaseApplet2

createFunctions

public Function[] createFunctions()

createFunctionNames

public java.lang.String[] createFunctionNames()

potentialChanged

protected void potentialChanged()

setFunction

public void setFunction(Function f)

updateInput

public void updateInput()
Reads in (and validates) input from the text fields.
Throws:
java.lang.IllegalArgumentException - if any input fields are invalid

start

public void start()
Description copied from class: BaseApplet
Applets should use this method to perform any final initialisation necessary to "activate" the applet
Overrides:
start in class BaseApplet2

stop

public void stop()
Description copied from class: BaseApplet
When this method is called, the applet should cease any user interaction. In particular, any threads explicitly started should be stopped, any external resources should be closed. This method should negate the action of start().
Overrides:
stop in class BaseApplet2

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
Description copied from class: BaseApplet
Subclasses should at least provide an empty implementation of this method.
Overrides:
actionPerformed in class BaseApplet

safeUpdateInput

protected void safeUpdateInput()
Attempts to update the parameters from the text fields. If this fails, an error message is displayed in the statusLabel.

doPaint

public void doPaint(java.awt.Graphics g)
Description copied from class: BaseApplet
Called by forcePaint() to actually perform the painting. Subclasses should implement this method as if it were the standard paint() method; buffering will then take place transparently.
Overrides:
doPaint in class BaseApplet
Tags copied from class: BaseApplet
Parameters:
g - The Graphics object on which to paint

solve

public void solve()
Attempts to find an energy for which the Schrodinger equation has a solution. The region searched will be the selected region; if no region is selected, the whole interval will be searched.

If a search is already in progress, this method will stop the search and perform no other action.

This method will also alternate the label of the Solve button between "Solve" and "Cancel" as appropriate.


abortSolving

public void abortSolving()
Stops a running search. If no search is in progress, no action will be taken.

energyChanged

public void energyChanged(double newEnergy)
Description copied from interface: EnergyListener
Called to signal that the best estimate for the energy has changed.
Specified by:
energyChanged in interface EnergyListener
Tags copied from interface: EnergyListener
Parameters:
d - The new energy

searchFinished

public void searchFinished()
Description copied from interface: EnergyListener
Called to signal that the search has finished.s
Specified by:
searchFinished in interface EnergyListener

isSquare

public boolean isSquare()
Returns true if the potential model consists of square wells.