org.fife.rtext.plugins.heapindicator
Class HeapIndicatorPlugin

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 org.fife.ui.StatusBarPanel
                      extended by org.fife.ui.app.StatusBarPlugin
                          extended by org.fife.rtext.plugins.heapindicator.HeapIndicatorPlugin
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, Plugin

public class HeapIndicatorPlugin
extends StatusBarPlugin

A status bar component displaying the current JVM heap.

Version:
1.0
Author:
Robert Futrell
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
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
HeapIndicatorPlugin(AbstractPluggableGUIApplication app)
          Constructor.
 
Method Summary
protected static long bytesToKb(long bytes)
           
protected  void getData()
          Updates heap memory information.
 java.awt.Color getIconBorderColor()
           
 java.awt.Color getIconForeground()
           
 PluginOptionsDialogPanel getOptionsDialogPanel()
          Returns an options panel for use in an Options dialog.
 java.lang.String getPluginAuthor()
          Returns the author of the plugin.
 javax.swing.Icon getPluginIcon()
          Returns the icon to display beside the name of this plugin in the application's interface.
 java.lang.String getPluginName()
          Returns the name of the plugin.
 java.lang.String getPluginVersion()
          Returns the version of the plugin.
 int getRefreshInterval()
          Returns the refresh interval of the heap indicator.
 java.lang.String getToolTipText()
          Returns the text to display for the tooltip.
 long getTotalMemory()
          Returns the total amount of memory available to the JVM.
 long getUsedMemory()
          Returns the amount of memory currently being used by the JVM.
 boolean getUseSystemColors()
          Returns whether or not system colors are used when painting the heap indicator.
 void install(AbstractPluggableGUIApplication app)
          Called just after a plugin is added to a GUI application.
protected  void installTimer(int interval)
           
protected  void processMouseEvent(java.awt.event.MouseEvent e)
           
 void savePreferences()
          Called when the GUI application is shutting down.
 void setIconBorderColor(java.awt.Color iconBorderColor)
           
 void setIconForeground(java.awt.Color iconForeground)
           
 void setRefreshInterval(int interval)
          Sets the refresh interval for the heap indicator.
 void setUseSystemColors(boolean useSystemColors)
          Sets whether or not to use system colors when painting the heap indicator.
 void setVisible(boolean visible)
           
 boolean uninstall()
          Called just before this Plugin is removed from an GUIApplication.
protected  void uninstallTimer()
           
 
Methods inherited from class org.fife.ui.app.StatusBarPlugin
getOptionsDialogPanelParentPanelID, setOptionsDialogPanelParentPanelName
 
Methods inherited from class org.fife.ui.StatusBarPanel
isShadowEnabled, paintComponent, setShadowEnabled
 
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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, 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, 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
 

Constructor Detail

HeapIndicatorPlugin

public HeapIndicatorPlugin(AbstractPluggableGUIApplication app)
Constructor.

Parameters:
app - The GUI application.
Method Detail

bytesToKb

protected static final long bytesToKb(long bytes)

getData

protected void getData()
Updates heap memory information.


getIconBorderColor

public java.awt.Color getIconBorderColor()

getIconForeground

public java.awt.Color getIconForeground()

getOptionsDialogPanel

public PluginOptionsDialogPanel getOptionsDialogPanel()
Returns an options panel for use in an Options dialog. This panel should contain all options pertaining to this plugin.

Returns:
The options panel.

getPluginAuthor

public java.lang.String getPluginAuthor()
Returns the author of the plugin.

Returns:
The author.

getPluginIcon

public javax.swing.Icon getPluginIcon()
Returns the icon to display beside the name of this plugin in the application's interface.

Returns:
The icon for this plugin. This value may be null to represent no icon.

getPluginName

public java.lang.String getPluginName()
Returns the name of the plugin.

Returns:
The plugin name.

getPluginVersion

public java.lang.String getPluginVersion()
Returns the version of the plugin.

Returns:
The version number of this plugin.

getRefreshInterval

public int getRefreshInterval()
Returns the refresh interval of the heap indicator.

Returns:
The refresh interval, in milliseconds.
See Also:
setRefreshInterval(int)

getToolTipText

public java.lang.String getToolTipText()
Returns the text to display for the tooltip.

Overrides:
getToolTipText in class javax.swing.JComponent
Returns:
The tooltip text.

getTotalMemory

public long getTotalMemory()
Returns the total amount of memory available to the JVM.

Returns:
The total memory available to the JVM, in bytes.
See Also:
getUsedMemory()

getUsedMemory

public long getUsedMemory()
Returns the amount of memory currently being used by the JVM.

Returns:
The memory being used by the JVM, in bytes.
See Also:
getTotalMemory()

getUseSystemColors

public boolean getUseSystemColors()
Returns whether or not system colors are used when painting the heap indicator.

Returns:
Whether or not to use system colors.
See Also:
setUseSystemColors(boolean)

install

public void install(AbstractPluggableGUIApplication app)
Called just after a plugin is added to a GUI application. If this is a GUIPlugin, it has already been added visually. Plugins should use this method to register any listeners to the GUI application and do any other necessary setup.

Parameters:
app - The application to which this plugin was just added.
See Also:
uninstall()

installTimer

protected void installTimer(int interval)

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e)
Overrides:
processMouseEvent in class javax.swing.JComponent

savePreferences

public void savePreferences()
Called when the GUI application is shutting down. When this method is called, the Plugin should save any preferences.


setIconBorderColor

public void setIconBorderColor(java.awt.Color iconBorderColor)

setIconForeground

public void setIconForeground(java.awt.Color iconForeground)

setRefreshInterval

public void setRefreshInterval(int interval)
Sets the refresh interval for the heap indicator.

Parameters:
interval - The new refresh interval, in milliseconds.
See Also:
getRefreshInterval()

setUseSystemColors

public void setUseSystemColors(boolean useSystemColors)
Sets whether or not to use system colors when painting the heap indicator.

Parameters:
useSystemColors - Whether or not to use system colors.
See Also:
getUseSystemColors()

setVisible

public void setVisible(boolean visible)
Overrides:
setVisible in class javax.swing.JComponent

uninstall

public boolean uninstall()
Called just before this Plugin is removed from an GUIApplication. This gives the plugin a chance to clean up any loose ends (kill any threads, close any files, remove listeners, etc.).

Returns:
Whether the uninstall went cleanly.
See Also:
install(org.fife.ui.app.AbstractPluggableGUIApplication)

uninstallTimer

protected void uninstallTimer()