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:
ImageObserver,MenuContainer,Serializable,Runnable,Accessible
LineMeter 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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intDOCUMENT ME!private Threadmonitor animation happens in its own thread.private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private booleanDOCUMENT ME!private intDOCUMENT ME!private DimensionDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private Graphics2DDOCUMENT ME!private InsetsDOCUMENT ME!private ColorDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private ColorDOCUMENT ME!private ColorDOCUMENT ME!private intDOCUMENT ME!private float[]DOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private static final longUse serialVersionUID for interoperability.private intDOCUMENT ME!private intDOCUMENT ME!private float[]DOCUMENT 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_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidremoves the samples from the buffer and transfers them to the history buffer, and resets the recent history to capture new samples.returns the panels maximum size.returns the displays minimum size.returns the panels preferred size.voidrepaints 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.voidapplies the given color to bars which are "lit" and are up to the set amplitude.voidapplies the given color to the background.voidsetPenColor(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, updateUIMethods 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, updateMethods 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, validateTreeMethods 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 Details
-
serialVersionUID
private static final long serialVersionUIDUse serialVersionUID for interoperability.- See Also:
-
animationFrame
private int animationFrameDOCUMENT ME! -
animationThread
monitor animation happens in its own thread. -
aniSampleRate
private int aniSampleRateDOCUMENT ME! -
chartWidth
private int chartWidthDOCUMENT ME! -
chartHeight
private int chartHeightDOCUMENT ME! -
chartXend
private int chartXendDOCUMENT ME! -
chartYend
private int chartYendDOCUMENT ME! -
chartXstart
private int chartXstartDOCUMENT ME! -
chartYstart
private int chartYstartDOCUMENT ME! -
counterLock
private boolean counterLockDOCUMENT ME! -
countSinceLastUpdate
private int countSinceLastUpdateDOCUMENT ME! -
dim
DOCUMENT ME! -
drawingWidth
private int drawingWidthDOCUMENT ME! -
drawingHeight
private int drawingHeightDOCUMENT ME! -
g2d
DOCUMENT ME! -
insets
DOCUMENT ME! -
lineColor
DOCUMENT ME! -
lineSpacing
private int lineSpacingDOCUMENT ME! -
numberOfDivisions
private int numberOfDivisionsDOCUMENT ME! -
numberOfSamplesDisplayed
private int numberOfSamplesDisplayedDOCUMENT ME! -
numberOfSamplesPerDivision
private int numberOfSamplesPerDivisionDOCUMENT ME! -
panelWidth
private int panelWidthDOCUMENT ME! -
panelHeight
private int panelHeightDOCUMENT ME! -
paperColor
DOCUMENT ME! -
penColor
DOCUMENT ME! -
pixelsWidePerSample
private int pixelsWidePerSampleDOCUMENT ME! -
recentSamples
private float[] recentSamplesDOCUMENT ME! -
sampleRate
private int sampleRateDOCUMENT ME! -
samplesPerUpdate
private int samplesPerUpdateDOCUMENT ME! -
whitespaceH
private int whitespaceHDOCUMENT ME! -
whitespaceW
private int whitespaceWDOCUMENT ME! -
yLocHistory
private float[] yLocHistoryDOCUMENT ME!
-
-
Constructor Details
-
LineMeter
public LineMeter()This is the history graph, and sets up and animation thread. The history will be large enough to display samples across the entire screen-size
-
-
Method Details
-
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
returns the panels maximum size.- Overrides:
getMaximumSizein classJComponent- Returns:
- DOCUMENT ME!
-
getMinimumSize
returns the displays minimum size.- Overrides:
getMinimumSizein classJComponent- Returns:
- DOCUMENT ME!
-
getPreferredSize
returns the panels preferred size.- Overrides:
getPreferredSizein classJComponent- Returns:
- DOCUMENT ME!
-
paintComponent
repaints the history graph.- Overrides:
paintComponentin classJComponent- 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. -
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
applies the given color to bars which are "lit" and are up to the set amplitude.- Parameters:
c- DOCUMENT ME!
-
setPaperColor
applies the given color to the background. Thre same as setBackground()- Parameters:
c- DOCUMENT ME!
-
setPenColor
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.
-