Class Counter


public class Counter extends Component<Counter>

Counter component

The component is a Span component, on which a number is displayed. The component can be used on a menu item, or button, to count information that is relevant to the user. A good example is the number of messages or notifications.

Supported events:

AnimationStart AnimationEnd, Click, DoubleClick, MouseDown, MouseDown, MouseLeave, MouseMove, MouseOver, MouseOut, MouseUp, Wheel, Scrollable TouchCancel, TouchEnd, TouchMove, TouchStart, Drop, DragStart, DragEnd

Since:
4.0
Author:
JBStrap
  • Constructor Details

    • Counter

      public Counter()
      Creates the counter component
    • Counter

      public Counter(String id)
      Creates the counter component with specieid id
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
  • Method Details

    • setValue

      public final Counter setValue(long value)
      Sets the value of the counter component
      Parameters:
      value - The value we want to display in the counter
      Returns:
      The counter component
    • inc

      public final Counter inc()
      Increments the counter value by 1
      Returns:
      The counter component
    • dec

      public final Counter dec()
      Decrements counter value by 1
      Returns:
      The counter component
    • add

      public final Counter add(int value)
      Increments the counter value by the given value
      Parameters:
      value - The value we want to increment the counter by
      Returns:
      The counter component
    • loss

      public final Counter loss(int value)
      Decrements the counter value by the given number
      Parameters:
      value - The value we want to decrement the counter by
      Returns:
      The counter component
    • getValue

      public long getValue()
      Gets the counter value
      Returns:
      The current value of the counter
    • setBackgoundColor

      public final Counter setBackgoundColor(Color color)
      Sets the background color of the counter Default background color is the theme WARNING color
      Parameters:
      color - Counter background color Available colors are listed in the enum Color If the entered value is null, the counter will appear with the default WARNING color.
      Returns:
      The counter component
    • setBackgoundColor

      public final Counter setBackgoundColor(String color)
      Sets the background color of the counter Default background color is the theme WARNING color.
      Parameters:
      color - Counter Counter background color as defined in CSS3. If a null value is set, the counter will appear with the default WARNING color.
      Returns:
      The counter component
    • setTextColor

      public final Counter setTextColor(Color color)
      Sets the text color of the counter Default text color is the theme text color
      Overrides:
      setTextColor in class Component<Counter>
      Parameters:
      color - Counter text color Available colors are listed in the enum Color If the entered value is null, the counter will appear with the default text color.
      Returns:
      The counter component
    • setTextColor

      public final Counter setTextColor(String color)
      Sets the color of the values on the counter. The default color is white.
      Parameters:
      color - The color, specified using CSS3 standard units. If null, the default white color will be used.
      Returns:
      The counter component
    • getBackgoundColor

      public Color getBackgoundColor()
      Gets the background color of the counter component
      Returns:
      The background color of the counter component
    • getTextColor

      public Color getTextColor()
      Gets the counter component’s displayed value color
      Overrides:
      getTextColor in class Component<Counter>
      Returns:
      The counter component’s displayed value color
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<Counter>
      Returns:
      If the componentwas drawn, true, otherwise false