PIRL

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

public class Memory_Panel
extends JPanel

A JPanel that holds information about available Virtual Machine memory. Three values are displayed: free memory, total memory, and maximum memory.

Free memory is the amount of memory not yet in use by the Virtual Machine. This memory has been claimed from the available pool, however.

Total memory is the total amount of memory the Virtual Machine has claimed from the available pool of memory. Free memory is a subset of this quantity; when subtracted from this quantity, the difference is the amount of memory currently in use. This value will change over time as objects are created and destroyed.

Maximum memory is the maximum available pool of memory for the Virtual Machine. Its value is static once the Virtual Machine is instantiated, although runtime switches may be employed to allocate amounts other than the default; see the documentation for the Java Virtual Machine. Total memory is a subset of this quantity.

Version:
1.5
Author:
Christian Schaller - UA/PIRL
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int DEFAULT_UNIT_DIVISOR
          The default unit divisor.
static String DEFAULT_UNITS
          The default unit.
static String ID
          Class identification name with source code version and date.
 
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_Panel()
          Creates a new Memory_Panel.
Memory_Panel(int unit_divisor, String units)
          Creates a new Memory_Panel with the specified unit_divisor and units label.
 
Method Summary
static long free_memory()
          Returns the amount of free memory currently available to the Java Virtual Machine.
static long max_memory()
          Returns the maximum amount of memory the Java Virtual Machine will attempt to use from the host system.
static long total_memory()
          Returns the total amount of memory in the Java Virtual Machine.
 int unit_divisor()
          Gets the common divisor used for each of the three memory quantities.
 void unit_divisor(int unit_divisor)
          Sets the common divisor used for each of the three memory quantities.
 String units()
          Gets the units displayed for each of the three memory quantities.
 void units(String units)
          Sets the units displayued for each of the three memory quantities.
 void update_labels()
          Updates the memory labels.
 
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_UNIT_DIVISOR

public static final int DEFAULT_UNIT_DIVISOR
The default unit divisor. Memory quantities will, by default, be divided by this value for display in the panel. This value is the number of bytes in a megabyte (1024 * 1024).

See Also:
Constant Field Values

DEFAULT_UNITS

public static final String DEFAULT_UNITS
The default unit. Memory quantities will be displayed with this text in the panel.

See Also:
Constant Field Values
Constructor Detail

Memory_Panel

public Memory_Panel(int unit_divisor,
                    String units)
Creates a new Memory_Panel with the specified unit_divisor and units label. The divisor is used to scale the memory values, which are in bytes; the units label should correctly identify the scale.

This panel uses a GridBagLayout.

Parameters:
unit_divisor - the divisor to be used in scaling the displayed memory values.
units - the label that identifies the units used.

Memory_Panel

public Memory_Panel()
Creates a new Memory_Panel. The panel uses the default divisor and default units for its information display.

See Also:
Memory_Panel(int,String)
Method Detail

update_labels

public void update_labels()
Updates the memory labels. This update takes place automatically whenever the units or unit divisors are changed, but one might want to update the labels periodically, polling the system from time to time.


unit_divisor

public int unit_divisor()
Gets the common divisor used for each of the three memory quantities. Each quantity is divided by this value for display.

Returns:
the unit divisor for this Memory_Panel.

unit_divisor

public void unit_divisor(int unit_divisor)
Sets the common divisor used for each of the three memory quantities. Each quantity is divided by this value or display. The displayed labels are updated when this value is changed.

Parameters:
unit_divisor - the new divisor for this Memory_Panel.

units

public String units()
Gets the units displayed for each of the three memory quantities.

Returns:
the units for this Memory_Panel.

units

public void units(String units)
Sets the units displayued for each of the three memory quantities. The displayed labels are updated when this value is changed.

Parameters:
units - the new units for this Memory_Panel.

free_memory

public static long free_memory()
Returns the amount of free memory currently available to the Java Virtual Machine.

Returns:
the free memory in bytes.
See Also:
Runtime.freeMemory()

total_memory

public static long total_memory()
Returns the total amount of memory in the Java Virtual Machine. This value may vary over time as the Virtual Machine claims more memory from the maximum available and releases it.

Returns:
the total memory in bytes.
See Also:
Runtime.totalMemory()

max_memory

public static long max_memory()
Returns the maximum amount of memory the Java Virtual Machine will attempt to use from the host system.

Returns:
the maximum memory in bytes.
See Also:
Runtime.maxMemory()

PIRL

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