Class FlatLedIndicator

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.jjazz.flatcomponents.api.FlatLedIndicator
All Implemented Interfaces:
MouseListener, ImageObserver, MenuContainer, Serializable, EventListener

public class FlatLedIndicator extends JComponent implements MouseListener
A simple activity indicator.

Call showActivity() to indicate activity on the led: led color goes from colorMin (minimum activity) to colorMax.

Color transition is done by first filling the led with colorMin, then overwriting it with colorMax with the transparency (alpha) channel set. When showActivity() is called, colorMax alpha channel is increased by getAlphaStepActivity(). Every DECAY_TIME_MS, colorMax alpha channel is decreased by getAlphaStepDecay().

See Also:
  • Field Details

  • Constructor Details

    • FlatLedIndicator

      public FlatLedIndicator()
  • Method Details

    • paintComponent

      public void paintComponent(Graphics g)
    • showActivity

      public void showActivity()
      Send an "activity event".
    • getColorMax

      public Color getColorMax()
      The color to show maximal activity.
      Returns:
      the colorMax
    • setColorMax

      public final void setColorMax(Color colorMax)
      Parameters:
      colorMax - the colorMax to set
    • getColorMin

      public Color getColorMin()
      The color to show minimal activity.
      Returns:
      the colorMin
    • setColorMin

      public final void setColorMin(Color colorMin)
      Parameters:
      colorMin - the colorMin to set
    • getAlphaStepDecay

      public int getAlphaStepDecay()
      Returns:
      the alphaStepDecay
    • setAlphaStepDecay

      public final void setAlphaStepDecay(int alphaStepDecay)
      Every DECAY_TIME_MS, the alpha channel of colorMax is decreased by alphaStepDecay.
      Parameters:
      alphaStepDecay - the alphaStepDecay to set
    • getAlphaStepActivity

      public int getAlphaStepActivity()
      Returns:
      the alphaStepActivity
    • setAlphaStepActivity

      public final void setAlphaStepActivity(int alphaStepActivity)
      Each time showActivity() is called, the alpha channel of colorMax is increased by alphaStepActivity.
      Parameters:
      alphaStepActivity - the alphaStepActivity to set
    • getDiameter

      public int getDiameter()
      Returns:
      the diameter
    • setDiameter

      public final void setDiameter(int diameter)
      Parameters:
      diameter - the diameter to set
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • getMaximumSize

      public Dimension getMaximumSize()
      Overrides:
      getMaximumSize in class JComponent
    • getMinimumSize

      public Dimension getMinimumSize()
      Overrides:
      getMinimumSize in class JComponent