jview
Class JExpressionFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by jview.JExitFrame
                          extended by jview.JConfirmExitFrame
                              extended by jview.JBorderFrame
                                  extended by jview.JExpressionFrame
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants, BorderLabels, Displayable, Initializable, LocalizedAware, LocalizedComposed
Direct Known Subclasses:
JPhaseFrame

public class JExpressionFrame
extends JBorderFrame

An expression frame is a simple border frame that displays on its right hand side the external variables, its values plus a spinner to adjust the parameters.

See Also:
Serialized Form

Nested Class Summary
static class JExpressionFrame.Show
          Class to create the frame and display it.
 
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  JExpressionCanvas canvas
          The expression canvas to put data on.
private  Map<String,NumberFormat> conserr
          To format the constants errors.
private  Map<String,NumberFormat> consform
          To format the constants.
private  Map<String,JLabel> constants
          To trace constants.
private  Map<String,String> consunit
          To units of the parameters.
private  Map<String,List<VectorG>> data
          The original data.
static String EQUAL
          How I separate constant name from value in display labels.
static String KEY_ADJUSTABLE
          The names of the parameters that should be adjustable.
static String KEY_ADJUSTINIT
          The start-up values of the adjustable parameters.
static String KEY_ADJUSTSTEP
          The spinner-step values of the adjustable parameters.
static String KEY_CANVAS
          The properties of the expression canvas to show.
static String KEY_FIXED
          The mapping of fixed parameters to their values.
static String KEY_FIXEDERROR
          The mapping of fixed parameters to their errors number format.
static String KEY_FIXEDFORMAT
          The mapping of fixed parameters to their number format.
static String KEY_FIXEDUNITS
          The mapping of fixed parameters to their unit strings.
private  Map<String,MySpinner> spinners
          To trace the new value.
private  Map<String,Number> vars
          The mapping of variable names to their values.
 
Fields inherited from class jview.JBorderFrame
DATACLEANSE, KEY_ABOUTURL, KEY_ACTIONCLASS, KEY_AIPLOGO, KEY_BIGGERSTRUT, KEY_DATAANALYSER, KEY_EASTALIGNMENT, KEY_FITTERS, KEY_FITTERTIPS, KEY_HELPSIZE, KEY_LESSERSTRUT, KEY_NOLOGO, KEY_NORTHALIGNMENT, KEY_SOUTHALIGNMENT, KEY_WESTALIGNMENT, MODELFITTER
 
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 jview.BorderLabels
KEY_ABOUT, KEY_ABOUTACC, KEY_FILEACCS, KEY_FILEITEMS, KEY_FILEMENU, KEY_FILEMNEMONIC, KEY_HELPMENU, KEY_HELPMNEMONIC, KEY_HELPTITLE, KEY_NOHELP, KEY_NOURLACCESS, KEY_TITLE
 
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
JExpressionFrame(LocalizedSupplying prop)
          Constructs an expression frame from a property container.
JExpressionFrame(Map<String,String> prop)
          Constructs an expression frame from a property mapping.
 
Method Summary
protected  boolean cache(String name, Number val)
          Caches a new variable value in our table.
protected  JExpressionCanvas createCanvas(ResourceSupplying pb)
          The canvas is created from its properties here.
protected  List<VectorG> getData(String setname)
          Gets the original data.
private static Map<String,NumberFormat> getFormatMap(String token)
          Propertizes the input string and parses the values as number formats.
 Component getRepresentation()
          We return our expression canvas.
protected  List getRightItems()
          We return the spinners and constant labels beneath to the right.
 Number getValue(String varname)
          Returns the current value of the named variable.
 void init()
          On init, we initialize the fixed parameter values.
protected  void replot(String ignore)
          The later-invoked update process that can be called savely from the event-dispatch queue.
 void setData(String setname, List<VectorG> plot)
          Sets the data that should be displayed in the frames expression canvas.
protected  void updateCanvas()
          Updates the canvas by ereasing all data and reconstructing it from the original data.
private  void updateConstant(String show, double val, double err)
          External applications might know about constants on run-time, rather than on construct.
private  void updateSpinner(String name, double val, double step)
          Re-adjusts the spinner to show these values.
 boolean updateVariable(String name, double val, double step)
          We update a named variable.
 
Methods inherited from class jview.JBorderFrame
analyserListenTo, createButton, createCheckBox, createDataAnalysers, createFitters, createHelp, createLabel, createLocalizedButton, createLocalizedCheckBox, createLocalizedHelp, createLocalizedLabel, createLocalizedRadioButton, createRadioButton, createStatus, getAboutAction, getActiveFit, getBiggerStrut, getBottomItems, getComposedProperties, getDataAnalysers, getFitterButtonGroup, getFitterComboBox, getIcon, getLeftItems, getLesserStrut, getModelFittings, getStatusField, getTopItems, hasFired, printAlignment, setAlignment, setComposedProperties, setFired
 
Methods inherited from class jview.JConfirmExitFrame
disposeAndExit, disposeImmediately
 
Methods inherited from class jview.JExitFrame
setVisible
 
Methods 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, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, show, 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, 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, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, 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, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

KEY_CANVAS

public static final String KEY_CANVAS
The properties of the expression canvas to show.

See Also:
Constant Field Values

KEY_ADJUSTABLE

public static final String KEY_ADJUSTABLE
The names of the parameters that should be adjustable.

See Also:
Constant Field Values

KEY_ADJUSTINIT

public static final String KEY_ADJUSTINIT
The start-up values of the adjustable parameters.

See Also:
Constant Field Values

KEY_ADJUSTSTEP

public static final String KEY_ADJUSTSTEP
The spinner-step values of the adjustable parameters.

See Also:
Constant Field Values

KEY_FIXED

public static final String KEY_FIXED
The mapping of fixed parameters to their values.

See Also:
Constant Field Values

KEY_FIXEDFORMAT

public static final String KEY_FIXEDFORMAT
The mapping of fixed parameters to their number format.

See Also:
Constant Field Values

KEY_FIXEDERROR

public static final String KEY_FIXEDERROR
The mapping of fixed parameters to their errors number format.

See Also:
Constant Field Values

KEY_FIXEDUNITS

public static final String KEY_FIXEDUNITS
The mapping of fixed parameters to their unit strings.

See Also:
Constant Field Values

EQUAL

public static final String EQUAL
How I separate constant name from value in display labels.

See Also:
Constant Field Values

canvas

private JExpressionCanvas canvas
The expression canvas to put data on.


data

private Map<String,List<VectorG>> data
The original data.


vars

private Map<String,Number> vars
The mapping of variable names to their values.


spinners

private Map<String,MySpinner> spinners
To trace the new value.


constants

private Map<String,JLabel> constants
To trace constants.


consform

private Map<String,NumberFormat> consform
To format the constants.


conserr

private Map<String,NumberFormat> conserr
To format the constants errors.


consunit

private Map<String,String> consunit
To units of the parameters.

Constructor Detail

JExpressionFrame

public JExpressionFrame(Map<String,String> prop)
Constructs an expression frame from a property mapping.


JExpressionFrame

public JExpressionFrame(LocalizedSupplying prop)
Constructs an expression frame from a property container.

Method Detail

init

public void init()
On init, we initialize the fixed parameter values.

Specified by:
init in interface Initializable
Overrides:
init in class JBorderFrame

getRepresentation

public Component getRepresentation()
We return our expression canvas.

Specified by:
getRepresentation in interface Displayable
Overrides:
getRepresentation in class JBorderFrame

setData

public void setData(String setname,
                    List<VectorG> plot)
Sets the data that should be displayed in the frames expression canvas. The data is stored locally to allow re-plotting of the data if the user adjusts some parameters. It then calls the updateCanvas().


getData

protected List<VectorG> getData(String setname)
Gets the original data. Only subclasses might use that.


getValue

public Number getValue(String varname)
Returns the current value of the named variable.


createCanvas

protected JExpressionCanvas createCanvas(ResourceSupplying pb)
The canvas is created from its properties here. Daughter that want to default the expression might override this method, add the expression to the properties and call this method again.


getRightItems

protected List getRightItems()
We return the spinners and constant labels beneath to the right.

Overrides:
getRightItems in class JBorderFrame

updateVariable

public boolean updateVariable(String name,
                              double val,
                              double step)
We update a named variable. In the default implementation, we update our spinner f we have one of the given name. If we have constants of the stated name, we update their values plus errors. In any case, we put the new value in our variables map.

Returns:
True, if updating process has already completed.

cache

protected boolean cache(String name,
                        Number val)
Caches a new variable value in our table. This is atomic, so we return true.

Returns:
True. Subclasses may override

updateConstant

private void updateConstant(String show,
                            double val,
                            double err)
External applications might know about constants on run-time, rather than on construct. The mapping passed over is added to our variables list, where it replaces any values already there. This method should not be used for setting the adjustable parameters.


updateSpinner

private void updateSpinner(String name,
                           double val,
                           double step)
Re-adjusts the spinner to show these values. In the default model, the spinner cannot step lower than 1e-3.


replot

protected void replot(String ignore)
The later-invoked update process that can be called savely from the event-dispatch queue.


updateCanvas

protected void updateCanvas()
Updates the canvas by ereasing all data and reconstructing it from the original data.


getFormatMap

private static Map<String,NumberFormat> getFormatMap(String token)
Propertizes the input string and parses the values as number formats.