Package gov.nih.mipav.view
Class LineMeter
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- gov.nih.mipav.view.LineMeter
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.lang.Runnable,javax.accessibility.Accessible
public class LineMeter extends javax.swing.JPanel implements java.lang.RunnableLineMeter is a history-graph panel which updates its display once a second, drawing a curve of the history of inputs to setAmplitude(). It resizes to preserve the proportions given in the graph, and will record enough data to display across the entire screen.there are a few artifacts in the drawing routine, namely, that setting the update rate to smaller than the animation rate will cause the background graph to update oddly.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private intanimationFrameDOCUMENT ME!private java.lang.ThreadanimationThreadmonitor animation happens in its own thread.private intaniSampleRateDOCUMENT ME!private intchartHeightDOCUMENT ME!private intchartWidthDOCUMENT ME!private intchartXendDOCUMENT ME!private intchartXstartDOCUMENT ME!private intchartYendDOCUMENT ME!private intchartYstartDOCUMENT ME!private booleancounterLockDOCUMENT ME!private intcountSinceLastUpdateDOCUMENT ME!private java.awt.DimensiondimDOCUMENT ME!private intdrawingHeightDOCUMENT ME!private intdrawingWidthDOCUMENT ME!private java.awt.Graphics2Dg2dDOCUMENT ME!private java.awt.InsetsinsetsDOCUMENT ME!private java.awt.ColorlineColorDOCUMENT ME!private intlineSpacingDOCUMENT ME!private intnumberOfDivisionsDOCUMENT ME!private intnumberOfSamplesDisplayedDOCUMENT ME!private intnumberOfSamplesPerDivisionDOCUMENT ME!private intpanelHeightDOCUMENT ME!private intpanelWidthDOCUMENT ME!private java.awt.ColorpaperColorDOCUMENT ME!private java.awt.ColorpenColorDOCUMENT ME!private intpixelsWidePerSampleDOCUMENT ME!private float[]recentSamplesDOCUMENT ME!private intsampleRateDOCUMENT ME!private intsamplesPerUpdateDOCUMENT ME!private static longserialVersionUIDUse serialVersionUID for interoperability.private intwhitespaceHDOCUMENT ME!private intwhitespaceWDOCUMENT ME!private float[]yLocHistoryDOCUMENT ME!-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description LineMeter()This is the history graph, and sets up and animation thread.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflushRecentSamples()removes the samples from the buffer and transfers them to the history buffer, and resets the recent history to capture new samples.java.awt.DimensiongetMaximumSize()returns the panels maximum size.java.awt.DimensiongetMinimumSize()returns the displays minimum size.java.awt.DimensiongetPreferredSize()returns the panels preferred size.voidpaintComponent(java.awt.Graphics g)repaints the history graph.voidrun()when the thread wakes up, if the panel is showing, it will repaint panel, scrolling the graph.voidsetAmplitude(float amp)Sets the most recent point on the history buffer.voidsetLineChartColor(java.awt.Color c)applies the given color to bars which are "lit" and are up to the set amplitude.voidsetPaperColor(java.awt.Color c)applies the given color to the background.voidsetPenColor(java.awt.Color c)applies the given color to bars which are not lit and are above the set amplitude.voidsetSampleRate(int samRate)adjusts the number of samples to be sent to the history in milliseconds.voidstart()sets the animation/redraw thread up, then runs it.voidstop()shuts the animation thread off.-
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, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Use serialVersionUID for interoperability.- See Also:
- Constant Field Values
-
animationFrame
private int animationFrame
DOCUMENT ME!
-
animationThread
private volatile java.lang.Thread animationThread
monitor animation happens in its own thread.
-
aniSampleRate
private int aniSampleRate
DOCUMENT ME!
-
chartWidth
private int chartWidth
DOCUMENT ME!
-
chartHeight
private int chartHeight
DOCUMENT ME!
-
chartXend
private int chartXend
DOCUMENT ME!
-
chartYend
private int chartYend
DOCUMENT ME!
-
chartXstart
private int chartXstart
DOCUMENT ME!
-
chartYstart
private int chartYstart
DOCUMENT ME!
-
counterLock
private boolean counterLock
DOCUMENT ME!
-
countSinceLastUpdate
private int countSinceLastUpdate
DOCUMENT ME!
-
dim
private java.awt.Dimension dim
DOCUMENT ME!
-
drawingWidth
private int drawingWidth
DOCUMENT ME!
-
drawingHeight
private int drawingHeight
DOCUMENT ME!
-
g2d
private java.awt.Graphics2D g2d
DOCUMENT ME!
-
insets
private java.awt.Insets insets
DOCUMENT ME!
-
lineColor
private java.awt.Color lineColor
DOCUMENT ME!
-
lineSpacing
private int lineSpacing
DOCUMENT ME!
-
numberOfDivisions
private int numberOfDivisions
DOCUMENT ME!
-
numberOfSamplesDisplayed
private int numberOfSamplesDisplayed
DOCUMENT ME!
-
numberOfSamplesPerDivision
private int numberOfSamplesPerDivision
DOCUMENT ME!
-
panelWidth
private int panelWidth
DOCUMENT ME!
-
panelHeight
private int panelHeight
DOCUMENT ME!
-
paperColor
private java.awt.Color paperColor
DOCUMENT ME!
-
penColor
private java.awt.Color penColor
DOCUMENT ME!
-
pixelsWidePerSample
private int pixelsWidePerSample
DOCUMENT ME!
-
recentSamples
private float[] recentSamples
DOCUMENT ME!
-
sampleRate
private int sampleRate
DOCUMENT ME!
-
samplesPerUpdate
private int samplesPerUpdate
DOCUMENT ME!
-
whitespaceH
private int whitespaceH
DOCUMENT ME!
-
whitespaceW
private int whitespaceW
DOCUMENT ME!
-
yLocHistory
private float[] yLocHistory
DOCUMENT ME!
-
-
Method Detail
-
flushRecentSamples
public final void flushRecentSamples()
removes the samples from the buffer and transfers them to the history buffer, and resets the recent history to capture new samples.
-
getMaximumSize
public java.awt.Dimension getMaximumSize()
returns the panels maximum size.- Overrides:
getMaximumSizein classjavax.swing.JComponent- Returns:
- DOCUMENT ME!
-
getMinimumSize
public java.awt.Dimension getMinimumSize()
returns the displays minimum size.- Overrides:
getMinimumSizein classjavax.swing.JComponent- Returns:
- DOCUMENT ME!
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
returns the panels preferred size.- Overrides:
getPreferredSizein classjavax.swing.JComponent- Returns:
- DOCUMENT ME!
-
paintComponent
public void paintComponent(java.awt.Graphics g)
repaints the history graph.- Overrides:
paintComponentin classjavax.swing.JComponent- Parameters:
g- DOCUMENT ME!
-
run
public void run()
when the thread wakes up, if the panel is showing, it will repaint panel, scrolling the graph.- Specified by:
runin interfacejava.lang.Runnable
-
setAmplitude
public void setAmplitude(float amp)
Sets the most recent point on the history buffer.- Parameters:
amp- -- floating point value between (and including) 0 and 1, which represents the y-coordinate on the graph. It is then adjusted to be drawn based on display size.
-
setLineChartColor
public void setLineChartColor(java.awt.Color c)
applies the given color to bars which are "lit" and are up to the set amplitude.- Parameters:
c- DOCUMENT ME!
-
setPaperColor
public void setPaperColor(java.awt.Color c)
applies the given color to the background. Thre same as setBackground()- Parameters:
c- DOCUMENT ME!
-
setPenColor
public void setPenColor(java.awt.Color c)
applies the given color to bars which are not lit and are above the set amplitude.- Parameters:
c- DOCUMENT ME!
-
setSampleRate
public void setSampleRate(int samRate)
adjusts the number of samples to be sent to the history in milliseconds. This allows for a recent buffer for samples not yet displayed. Changes to the sample rate will flush the current set of updates to the history buffer.- Parameters:
samRate- -- number of milliseconds per sample.
-
start
public void start()
sets the animation/redraw thread up, then runs it.
-
stop
public void stop()
shuts the animation thread off.
-
-