Class MemoryUsageAndHistoryMonitor.Usage

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
be.gaudry.swing.component.monitor.MemoryUsageAndHistoryMonitor.Usage
All Implemented Interfaces:
MemoryUsageAndHistoryMonitor.MemoryChangeListener, ImageObserver, MenuContainer, Serializable, Accessible
Enclosing class:
MemoryUsageAndHistoryMonitor

public static class MemoryUsageAndHistoryMonitor.Usage extends JPanel implements MemoryUsageAndHistoryMonitor.MemoryChangeListener
Displays the current memory usage.
See Also:
Serialized Form
  • Field Details

    • PREFERRED_WIDTH

      public static final int PREFERRED_WIDTH
      The preferred width.
      See Also:
      Constant Field Values
    • PREFERRED_HEIGHT

      public static final int PREFERRED_HEIGHT
      The preferred height.
      See Also:
      Constant Field Values
    • FONT_SIZE

      protected static final int FONT_SIZE
      The font size.
      See Also:
      Constant Field Values
    • BLOCK_MARGIN

      protected static final int BLOCK_MARGIN
      The blocks margin.
      See Also:
      Constant Field Values
    • BLOCKS

      protected static final int BLOCKS
      The number of blocks.
      See Also:
      Constant Field Values
    • BLOCK_WIDTH

      protected static final double BLOCK_WIDTH
      The blocks width.
      See Also:
      Constant Field Values
    • BLOCK_HEIGHT

      protected static final double BLOCK_HEIGHT
      The blocks height.
      See Also:
      Constant Field Values
    • BLOCK_TYPE

      protected static final int[] BLOCK_TYPE
      The blocks type.
    • usedColors

      protected Color[] usedColors
      The color of the used blocks for each block type.
    • freeColors

      protected Color[] freeColors
      The color of the free blocks for each block type.
    • font

      protected Font font
      The font used to draw the strings.
    • textColor

      protected Color textColor
      The text color.
    • totalMemory

      protected long totalMemory
      The total memory.
    • freeMemory

      protected long freeMemory
      The free memory.
  • Constructor Details

    • Usage

      public Usage()
      Creates a new Usage object.
  • Method Details

    • memoryStateChanged

      public void memoryStateChanged(long total, long free)
      Indicates that the memory state has changed.
      Specified by:
      memoryStateChanged in interface MemoryUsageAndHistoryMonitor.MemoryChangeListener
      Parameters:
      total - The total amount of memory.
      free - The free memory.
    • setTextColor

      public void setTextColor(Color c)
      Sets the text color.
      Parameters:
      c - color to set
    • setLowUsedMemoryColor

      public void setLowUsedMemoryColor(Color c)
      Sets the low used memory block color.
      Parameters:
      c - color to set
    • setMediumUsedMemoryColor

      public void setMediumUsedMemoryColor(Color c)
      Sets the medium used memory block color.
      Parameters:
      c - color to set
    • setHighUsedMemoryColor

      public void setHighUsedMemoryColor(Color c)
      Sets the high used memory block color.
      Parameters:
      c - color to set
    • setLowFreeMemoryColor

      public void setLowFreeMemoryColor(Color c)
      Sets the low free memory block color.
      Parameters:
      c - color to set
    • setMediumFreeMemoryColor

      public void setMediumFreeMemoryColor(Color c)
      Sets the medium free memory block color.
      Parameters:
      c - color to set
    • setHighFreeMemoryColor

      public void setHighFreeMemoryColor(Color c)
      Sets the high free memory block color.
      Parameters:
      c - color to set
    • paintComponent

      protected void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent