Class Figure

java.lang.Object
org.gcube.common.health.api.Figure

public final class Figure extends Object
One figure of a group of Statistics, with the label a page shows and its kind, which tells the page how to draw it:
  • "number": one number, drawn as a tile;
  • "distribution": the parts of a whole by name (e.g. the requests by outcome), drawn as a donut with percentages;
  • "states": the parts of a whole by state (e.g. the Contexts by state), with what each state means (State), drawn like a distribution with the colour of each meaning;
  • "values": a number by name that is not a part of a whole (e.g. an average per depth), drawn as bars, without percentages.
  • Field Details

    • NUMBER

      public static final String NUMBER
      The kind of a figure that is one number.
      See Also:
    • DISTRIBUTION

      public static final String DISTRIBUTION
      The kind of a figure that gives the parts of a whole by name.
      See Also:
    • STATES

      public static final String STATES
      The kind of a figure that gives the parts of a whole by state.
      See Also:
    • VALUES

      public static final String VALUES
      The kind of a figure that gives a number by name, not the parts of a whole.
      See Also:
  • Method Details

    • number

      public static Figure number(String id, String label, Number value)
      Creates a figure that is a number.
      Parameters:
      id - the identifier of the figure in its group, lowerCamelCase
      label - what a page writes next to it, e.g. "Requests since start"
      value - the number
      Returns:
      the figure
    • distribution

      public static Figure distribution(String id, String label, Map<String,? extends Number> parts)
      Creates a figure that gives the parts of a whole by name, in the order given.
      Parameters:
      id - the identifier of the figure in its group, lowerCamelCase
      label - what a page writes next to it, e.g. "Requests by outcome"
      parts - the number of each part, by its name
      Returns:
      the figure
    • states

      public static Figure states(String id, String label, Map<String,? extends Number> parts, Map<String,State> meaning)
      Creates a figure that gives the parts of a whole by state, in the order given, with what each state means.
      Parameters:
      id - the identifier of the figure in its group, lowerCamelCase
      label - what a page writes next to it, e.g. "Contexts by state"
      parts - the number of each state, by its name (e.g. active, suspended)
      meaning - what each state means; every state of parts must have one
      Returns:
      the figure
      Throws:
      IllegalArgumentException - when a state has no meaning
    • values

      public static Figure values(String id, String label, Map<String,? extends Number> values)
      Creates a figure that gives a number by name that is not a part of a whole (e.g. an average, a median or a maximum per depth), in the order given.
      Parameters:
      id - the identifier of the figure in its group, lowerCamelCase
      label - what a page writes next to it, e.g. "Children per Context, average by depth"
      values - the number, by its name
      Returns:
      the figure
    • getId

      public String getId()
    • getLabel

      public String getLabel()
    • getKind

      public String getKind()
      Returns how a page draws the figure: "number", "distribution", "states" or "values".
      Returns:
      the kind
    • getValue

      public Object getValue()
      Returns the value: a Number for "number", an unmodifiable Map of numbers by name for the other kinds.
      Returns:
      the value
    • getStates

      public Map<String,State> getStates()
      Returns what each state of a figure of kind "states" means.
      Returns:
      the meaning by state, null for the other kinds
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object