ikayaki.gui
Class MeasurementControlsPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by ikayaki.gui.ProjectComponent
                      extended by ikayaki.gui.MeasurementControlsPanel
All Implemented Interfaces:
MeasurementListener, ProjectListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class MeasurementControlsPanel
extends ProjectComponent

Has "Measure"/"Pause", "Single step" and "Stop now!" buttons for controlling measurements; "+z/-z" radiobuttons for changing sample orientation used in calculations, help picture for inserting sample, picture of current magnetometer status, and, manual controls.

Listens MeasurementEvents and ProjectEvents, and updates buttons and magnetometer status accordingly.

Author:
Samuli Kaipiainen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  Action abortAction
           
private  JButton abortButton
           
private  ComponentFlasher abortButtonFlasher
           
private  Action autoStepAction
           
private  Action calibrateAction
           
private  MagnetometerStatusPanel magnetometerStatusPanel
          Magnetometer status panel; also holds move-radiobuttons from ManualControlsPanel.
private  MagnetometerStatusPanel.ManualControlsPanel manualControlsPanel
          Magnetometer manual controls.
private  JButton measureButton
           
private  ComponentFlasher measureButtonFlasher
           
private  Action pauseAction
           
private  JButton pauseButton
           
private  ComponentFlasher pauseButtonFlasher
           
private  JLabel sampleInsertIconLabel
           
private  JPanel sampleInsertPanel
          Draws a help image and text for sample inserting: "Put sample in holder arrow up."
private  JLabel sampleInsertTextLabel
           
private  Icon sampleInsertZMinusIcon
           
private  Icon sampleInsertZPlusIcon
           
private  Action singleStepAction
           
private  JButton stepButton
           
private  ComponentFlasher stepButtonFlasher
           
private  ButtonGroup zButtonGroup
          Groups together +z and -z RadioButtons.
private  JRadioButton zMinusRadioButton
           
private  JRadioButton zPlusRadioButton
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MeasurementControlsPanel()
           
 
Method Summary
 Action getAbortAction()
          Event C: On stopButton click - call project.doAbort(); show critical error message if false is returned.
 Action getAutoStepAction()
          Event A: On measureButton click - call project.doAutoStep() or project.doPause(), depending on current button status.
 Action getCalibrateAction()
           
 Action getPauseAction()
           
 Action getSingleStepAction()
          Event B: On stepButton click - call project.doSingleStep(); show error message if false is returned.
 void measurementUpdated(MeasurementEvent event)
          Event F: On MeasurementEvent - call magnetometerStatusPanel.measurementUpdated(MeasurementEvent).
 void projectUpdated(ProjectEvent event)
          Event E: On ProjectEvent - update buttons and manual controls according to project.isXXXEnabled().
private  void setOrientation(Project.Orientation orientation)
          Sets zPlus/Minus radiobutton enabled, and the corresponding image as sample inserting help image.
 void setProject(Project project)
          Call super.setProject(project), update buttons and manual controls according to project.isXXXEnabled().
private  void updateActions()
          Checks the current state of the active project and enables/disables the measurement controls accordingly.
 
Methods inherited from class ikayaki.gui.ProjectComponent
getParentFrame, getProject
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

measureButton

private final JButton measureButton

pauseButton

private final JButton pauseButton

stepButton

private final JButton stepButton

abortButton

private final JButton abortButton

measureButtonFlasher

private final ComponentFlasher measureButtonFlasher

pauseButtonFlasher

private final ComponentFlasher pauseButtonFlasher

stepButtonFlasher

private final ComponentFlasher stepButtonFlasher

abortButtonFlasher

private final ComponentFlasher abortButtonFlasher

zButtonGroup

private final ButtonGroup zButtonGroup
Groups together +z and -z RadioButtons.


zPlusRadioButton

private final JRadioButton zPlusRadioButton

zMinusRadioButton

private final JRadioButton zMinusRadioButton

sampleInsertPanel

private final JPanel sampleInsertPanel
Draws a help image and text for sample inserting: "Put sample in holder arrow up."


sampleInsertTextLabel

private final JLabel sampleInsertTextLabel

sampleInsertZPlusIcon

private final Icon sampleInsertZPlusIcon

sampleInsertZMinusIcon

private final Icon sampleInsertZMinusIcon

sampleInsertIconLabel

private final JLabel sampleInsertIconLabel

manualControlsPanel

private final MagnetometerStatusPanel.ManualControlsPanel manualControlsPanel
Magnetometer manual controls.


magnetometerStatusPanel

private final MagnetometerStatusPanel magnetometerStatusPanel
Magnetometer status panel; also holds move-radiobuttons from ManualControlsPanel.


autoStepAction

private Action autoStepAction

singleStepAction

private Action singleStepAction

calibrateAction

private Action calibrateAction

pauseAction

private Action pauseAction

abortAction

private Action abortAction
Constructor Detail

MeasurementControlsPanel

public MeasurementControlsPanel()
Method Detail

setProject

public void setProject(Project project)
Call super.setProject(project), update buttons and manual controls according to project.isXXXEnabled().

Overrides:
setProject in class ProjectComponent
Parameters:
project - project opened, or null to open no project.

projectUpdated

public void projectUpdated(ProjectEvent event)
Event E: On ProjectEvent - update buttons and manual controls according to project.isXXXEnabled().

Specified by:
projectUpdated in interface ProjectListener
Overrides:
projectUpdated in class ProjectComponent
Parameters:
event - ProjectEvent received.

measurementUpdated

public void measurementUpdated(MeasurementEvent event)
Event F: On MeasurementEvent - call magnetometerStatusPanel.measurementUpdated(MeasurementEvent).

Specified by:
measurementUpdated in interface MeasurementListener
Overrides:
measurementUpdated in class ProjectComponent
Parameters:
event - MeasurementEvent received.

setOrientation

private void setOrientation(Project.Orientation orientation)
Sets zPlus/Minus radiobutton enabled, and the corresponding image as sample inserting help image.


updateActions

private void updateActions()
Checks the current state of the active project and enables/disables the measurement controls accordingly.


getAutoStepAction

public Action getAutoStepAction()
Event A: On measureButton click - call project.doAutoStep() or project.doPause(), depending on current button status. Show error message if false is returned.


getSingleStepAction

public Action getSingleStepAction()
Event B: On stepButton click - call project.doSingleStep(); show error message if false is returned.


getCalibrateAction

public Action getCalibrateAction()

getPauseAction

public Action getPauseAction()

getAbortAction

public Action getAbortAction()
Event C: On stopButton click - call project.doAbort(); show critical error message if false is returned.