PIRL

PIRL.Viewers
Class Memory_Chart_Panel

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 PIRL.Viewers.Memory_Chart_Panel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class Memory_Chart_Panel
extends JPanel

A Memory_Chart_Panel provides panel for a Memory_Chart.

The panel may optionally be provided with a popup menu that includes Memory_Chart controls that are also bound to accelerator keys. In addition to basic Memory_Chart controls, a Save History action is provided that will save the current memory sampling history to a file in comma separated value (CSV) format.

Version:
1.4
Author:
Bradford Castalia - UA/PIRL
See Also:
Memory_Chart, 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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int ANNOTATION_KEY
          Menu mnemonic and keyboard accellerator keys.
static int DEFAULT_SAMPLING_RATE
          The default Memory_Chart sampling rate.
static String ID
          Class identification name with source code version and date.
static int SAMPLING_RATE_KEY
          Menu mnemonic and keyboard accellerator keys.
static int SAVE_HISTORY_KEY
          Menu mnemonic and keyboard accellerator keys.
static int SECONDS_SCALE_KEY
          Menu mnemonic and keyboard accellerator keys.
static int STOP_START_KEY
          Menu mnemonic and keyboard accellerator keys.
 
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
Memory_Chart_Panel()
          Construct a Memory_Chart_Panel with a popup menu and using the DEFAULT_SAMPLING_RATE.
Memory_Chart_Panel(boolean provide_menu)
          Construct a Memory_Chart_Panel with an optional popup menu.
Memory_Chart_Panel(int rate)
          Construct a Memory_Chart_Panel using a sampling rate.
Memory_Chart_Panel(int rate, boolean provide_menu)
          Construct a Memory_Chart_Panel using a sampling rate and optional popup menu.
 
Method Summary
static long Allocated_Memory()
          Get the amount of memory currently in use by the Java runtime environment.
 boolean Annotation()
          Test if the Memory_Chart annotation is enabled.
 Memory_Chart_Panel Annotation(boolean enabled)
          Enable or disable the Memory_Chart annotations.
static long Available_Memory()
          Get the total amount of memory available to the Java runtime environment.
 Memory_Chart_Panel CWD(File file)
          Sets the current working directory for finding parameter files.
static long Free_Memory()
          Get the amount of memory allocated by the Java runtime environment but not currently in use.
 JPopupMenu Menu()
          Get a popup menu with Memory_Chart controls.
 int Previous_Rate()
          Get the previous memory sampling rate.
 int Rate()
          Get the memory sampling rate.
 Memory_Chart_Panel Rate(int rate)
          Set the memory sampling rate.
 Memory_Chart_Panel Run(boolean run)
          Enable or disable the operation of the Memory_Chart.
 boolean Seconds_Scale()
          Test if the Memory_Chart seconds scale is enabled.
 Memory_Chart_Panel Seconds_Scale(boolean enabled)
          Enable or disable the Memory_Chart seconds scale.
 
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, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values

DEFAULT_SAMPLING_RATE

public static final int DEFAULT_SAMPLING_RATE
The default Memory_Chart sampling rate.

See Also:
Constant Field Values

STOP_START_KEY

public static final int STOP_START_KEY
Menu mnemonic and keyboard accellerator keys.

When the menu is visible, each key combined with the ALT key will select the corresponding menu item. When the component has focus, each key combined with the CTL (control) key will cause the corresponding action to occur.

See Also:
Constant Field Values

SAMPLING_RATE_KEY

public static final int SAMPLING_RATE_KEY
Menu mnemonic and keyboard accellerator keys.

When the menu is visible, each key combined with the ALT key will select the corresponding menu item. When the component has focus, each key combined with the CTL (control) key will cause the corresponding action to occur.

See Also:
Constant Field Values

ANNOTATION_KEY

public static final int ANNOTATION_KEY
Menu mnemonic and keyboard accellerator keys.

When the menu is visible, each key combined with the ALT key will select the corresponding menu item. When the component has focus, each key combined with the CTL (control) key will cause the corresponding action to occur.

See Also:
Constant Field Values

SECONDS_SCALE_KEY

public static final int SECONDS_SCALE_KEY
Menu mnemonic and keyboard accellerator keys.

When the menu is visible, each key combined with the ALT key will select the corresponding menu item. When the component has focus, each key combined with the CTL (control) key will cause the corresponding action to occur.

See Also:
Constant Field Values

SAVE_HISTORY_KEY

public static final int SAVE_HISTORY_KEY
Menu mnemonic and keyboard accellerator keys.

When the menu is visible, each key combined with the ALT key will select the corresponding menu item. When the component has focus, each key combined with the CTL (control) key will cause the corresponding action to occur.

See Also:
Constant Field Values
Constructor Detail

Memory_Chart_Panel

public Memory_Chart_Panel(int rate,
                          boolean provide_menu)
Construct a Memory_Chart_Panel using a sampling rate and optional popup menu.

A border with the title "Memory Use" is placed around a Memory_Chart that uses the specified sampling rate. A popup menu is provided if requested.

Parameters:
rate - The memory sampling rate for the Memory_Chart.
provide_menu - If true, a popup menu is provided.

Memory_Chart_Panel

public Memory_Chart_Panel(int rate)
Construct a Memory_Chart_Panel using a sampling rate.

A popup menu is provided.

Parameters:
rate - The memory sampling rate for the Memory_Chart.

Memory_Chart_Panel

public Memory_Chart_Panel(boolean provide_menu)
Construct a Memory_Chart_Panel with an optional popup menu.

The Memory_Chart will use the DEFAULT_SAMPLING_RATE.

Parameters:
provide_menu - If true, a popup menu is provided.

Memory_Chart_Panel

public Memory_Chart_Panel()
Construct a Memory_Chart_Panel with a popup menu and using the DEFAULT_SAMPLING_RATE.

Method Detail

Annotation

public boolean Annotation()
Test if the Memory_Chart annotation is enabled.

Returns:
true if the annotation is enabled; false otherwise.

Seconds_Scale

public boolean Seconds_Scale()
Test if the Memory_Chart seconds scale is enabled.

Returns:
true if the seconds scale is enabled; false otherwise.

Rate

public int Rate()
Get the memory sampling rate.

Returns:
The time, in seconds, between memory samples.
See Also:
Memory_Chart.Rate(int)

Previous_Rate

public int Previous_Rate()
Get the previous memory sampling rate.

Returns:
The previous memory history sampling rate. This will be zero only if there was no non-zero previous sampling rate.
See Also:
Memory_Chart.Previous_Rate()

Free_Memory

public static long Free_Memory()
Get the amount of memory allocated by the Java runtime environment but not currently in use.

Returns:
The amount, in bytes, of allocated but free memory.
See Also:
Memory_History.Available_Memory()

Allocated_Memory

public static long Allocated_Memory()
Get the amount of memory currently in use by the Java runtime environment.

Returns:
The amount, in bytes, of allocated memory.
See Also:
Memory_History.Available_Memory()

Available_Memory

public static long Available_Memory()
Get the total amount of memory available to the Java runtime environment.

Returns:
The total amount of memory, in bytes, available to the Java runtime environment.
See Also:
Memory_History.Available_Memory()

Menu

public JPopupMenu Menu()
Get a popup menu with Memory_Chart controls.

Controls to stop and start memory sampling, set the sampling rate, enable and disable the annotations and seconds scale, and save the current sampling history to a file are provided.

The menu actions are also bound to keyboard accelerators.

The Save History action will use a file chooser to select a file in which the current memory sampling history will be written in comma separated values (CSV) format. The first line provides the names of the values on the following lines (one line per sample): "Sample" is the sample index, starting with zero; "Allocated" followed by a slash characater ('/') and the total amount of memory available is the amount of allocated memory; and "Free" is the amount of free memory in the allocated pool.

Returns:
A JPopupMenu.

Run

public Memory_Chart_Panel Run(boolean run)
Enable or disable the operation of the Memory_Chart.

Parameters:
run - If true, memory sampling will be started if it is not already running. If false, sampling will be stopped.
Returns:
This Memory_Chart_Panel.

Rate

public Memory_Chart_Panel Rate(int rate)
Set the memory sampling rate.

Parameters:
rate - The memory sampling rate.
Returns:
This Memory_Chart_Panel.

Annotation

public Memory_Chart_Panel Annotation(boolean enabled)
Enable or disable the Memory_Chart annotations.

Parameters:
enabled - If true, chart annotations will be shown. If false they will not be shown.
Returns:
This Memory_Chart_Panel.

Seconds_Scale

public Memory_Chart_Panel Seconds_Scale(boolean enabled)
Enable or disable the Memory_Chart seconds scale.

Parameters:
enabled - If true, chart seconds scale will be shown. If false it will not be shown.
Returns:
This Memory_Chart_Panel.

CWD

public Memory_Chart_Panel CWD(File file)
                       throws FileNotFoundException
Sets the current working directory for finding parameter files.

Parameters:
file - A File to which to set the CWD. If null, the "user.dir" System property will be used. If the file does not refer to an existing directory, the file's parent will be used.
Returns:
This Parameter_View.
Throws:
FileNotFoundException - If neither the file nor the file's parent refers to an existing directory.

PIRL

Copyright (C) \ 2003-2009 Bradford Castalia, University of Arizona