Every member of a group is either a count or a duration or a rate, and the members of one group always agree on which. That constraint is the whole point. Combining stats whose units differ produces a plot that looks meaningful and is not: a count against a byte count, or a per-second rate against a total, flattens the smaller series into the baseline and reads as "nothing happening". Members were therefore checked against their declaring code rather than their names.
Grouping is opt-in via PROP_COMBINE and only takes effect where at least two members are already enabled, so enabling a single stat of a group is never silently changed into a combined plot.
Field Summary
Modifier and TypeFieldDescriptionGroup id to member stat names, in legend order.private static final StringSuffix of a pool's inbound rate, as built by TunnelPool.static final intMost series drawn on one plot.private static final StringSuffix of a pool's outbound rate, as built by TunnelPool.private static final StringMarker at the head of a group id built from an In/Out bandwidth pair rather than declared in the registry.private static final StringSubsystem a generated pair sorts under.static final StringOpt-in property; when false every stat renders on its own as before.Subsystem each group belongs to, used to build the[Subsystem]prefix that makes the graph list sort by area.Display name per group.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionallGroupIds(Set<String> enabledStats) Every group id that may render for an enabled set: the registry, plus the In/Out pairs those stats form.static booleanWhether every group has a display name of its own.combinedRepresentatives(Set<String> enabledStats, boolean combine, boolean showEvents) Work out which stat, if any, stands for each group given the enabled set.static StringcounterpartOf(String statName) The other half of a bandwidth pair, spelled exactly as a stat name.static StringdisplayPrefixOf(String groupId) The sort prefix for a group, ready to prepend to a title.enabledMembers(String groupId, Set<String> enabledStats) The enabled members of a group, capped atMAX_SERIES.groupIds()List every known graph group id.static StringFind the group a stat belongs to.static booleanWhether an id names a generated In/Out pair rather than a registry group.static booleanisSuppressed(String statName, String combined) Whether an individual stat's own graph is replaced by its group.private static StringkeyOfPairId(String groupId) The group id with the pair prefix removed.List the stat names making up a graph group.pairGroupIds(Set<String> enabledStats) The In/Out pairs the enabled stats form.static StringThe directionless name the two rates of a pair share.static booleanshouldCombine(List<String> enabledMembers, boolean combine, boolean showEvents) Whether a group should be drawn as one plot.static StringsubsystemOf(String groupId) The subsystem a group belongs to.private static StringThe in or out suffix of a stat name.suppressedStats(Set<String> enabledStats, boolean combine, boolean showEvents) Every stat drawn on its own after grouping: the enabled stats, minus the members that their group's plot already covers.static StringThe display name of a group, for use as a combined graph title.
Field Details
PROP_COMBINE
Opt-in property; when false every stat renders on its own as before.- See Also:
MAX_SERIES
public static final int MAX_SERIESMost series drawn on one plot.Every group is now at or under
MAX_SERIES: no frame combines more than two, because a tile is too small to read a third line and two hues are all the palette needs. This stays as a hard cap so a group added later cannot silently exceed it, andGraphGroupsTestasserts the current groups all comply.- See Also:
PAIR_PREFIX
Marker at the head of a group id built from an In/Out bandwidth pair rather than declared in the registry.Pool names come from configuration, so the two rates a pool publishes cannot be listed in advance: an HTTP proxy is only there if the user named it one. The marker keeps such an id recognisable, and keeps
members(String)from treating an arbitrary string as a group.Not a plausible stat prefix: rate names are dotted subsystem paths (
netDb.successTime) or, for pools, bracketed.- See Also:
IN_SUFFIX
Suffix of a pool's inbound rate, as built by TunnelPool.- See Also:
OUT_SUFFIX
Suffix of a pool's outbound rate, as built by TunnelPool.- See Also:
PAIR_SUBSYSTEM
Subsystem a generated pair sorts under. A pool's rates answer how much traffic that service is carrying, so they sort with the other service graphs rather than under the tunnel jobs.- See Also:
TITLES
GROUPS
SUBSYSTEMS
Subsystem each group belongs to, used to build the[Subsystem]prefix that makes the graph list sort by area.Deliberately untranslated and kept out of
TITLES: a title is a translation key (Translatereturns the key for English and falls back to it when a bundle lookup misses), so folding a prefix into the title would silently untranslate every group in every locale. A prefix is also only useful for sorting if it is stable, which a translated string is not.
Constructor Details
GraphGroups
private GraphGroups()Utility class, not intended for instantiation.
Method Details
displayPrefixOf
The sort prefix for a group, ready to prepend to a title.Untranslated by design, see
SUBSYSTEMS.- Parameters:
groupId- a group id, or null- Returns:
"[Peers] "including the trailing space, or the empty string when the group has no subsystem or the id is unknown
subsystemOf
The subsystem a group belongs to.A generated In/Out pair is not in
SUBSYSTEMS; it is a pool rate and answers "how much is this service carrying", so it sorts with the other service graphs under the pool subsystem.- Parameters:
groupId- a group id, or null- Returns:
- the subsystem name, or null when the group has none
titleOf
The display name of a group, for use as a combined graph title.A generated pair is named after the directionless half the two rates share, with the brackets a pool name carries dropped:
[skank.i2p]is already a name, and nesting it inside the title's own brackets reads as markup.- Parameters:
groupId- a group id- Returns:
- the title, never null; an unknown id yields the id itself
allGroupsTitled
public static boolean allGroupsTitled()Whether every group has a display name of its own.- Returns:
- true when the title map covers the registry exactly
members
groupIds
isPairId
Whether an id names a generated In/Out pair rather than a registry group.- Parameters:
groupId- a group id, or null- Returns:
- true for a generated pair id
pairKeyOf
counterpartOf
pairGroupIds
The In/Out pairs the enabled stats form.Only pairs the user has switched on both halves of are returned: a group id for a half-enabled pair would render as an empty tile, and pairing must never turn a single enabled stat into a combined plot. Stats the registry already claims are skipped, so a declared group and a generated one can never cover the same rate.
- Parameters:
enabledStats- stat names enabled by the user, without period suffixes; null yields no pairs- Returns:
- the pair ids, in name order; never null
allGroupIds
keyOfPairId
suffixOf
groupOf
enabledMembers
The enabled members of a group, capped atMAX_SERIES.Never null; an empty list means the group has too few enabled members to be worth combining.
- Parameters:
groupId- a group idenabledStats- stat names the user has switched on, without any period suffix- Returns:
- members that are enabled, in legend order
shouldCombine
public static boolean shouldCombine(List<String> enabledMembers, boolean combine, boolean showEvents) Whether a group should be drawn as one plot.Requires the opt-in, at least two enabled members, and no event-graph mode: events change what a datasource means, so they are not combined.
- Parameters:
enabledMembers- result ofenabledMembers(String, Set)combine- value ofPROP_COMBINEshowEvents- whether the graph page is in event mode- Returns:
- true when the members collapse into one graph
isSuppressed
Whether an individual stat's own graph is replaced by its group.- Parameters:
statName- the stat being rendered on its owncombined- the stat name that stands for its group, or null when not combining- Returns:
- true when this stat must be suppressed in favour of the group plot
combinedRepresentatives
public static Map<String,String> combinedRepresentatives(Set<String> enabledStats, boolean combine, boolean showEvents) Work out which stat, if any, stands for each group given the enabled set.- Parameters:
enabledStats- stat names enabled by the usercombine- value ofPROP_COMBINEshowEvents- whether the graph page is in event mode- Returns:
- group id to the member chosen to carry the group's graph; groups that do not qualify are absent
suppressedStats
public static Set<String> suppressedStats(Set<String> enabledStats, boolean combine, boolean showEvents) Every stat drawn on its own after grouping: the enabled stats, minus the members that their group's plot already covers.- Parameters:
enabledStats- stat names enabled by the usercombine- value ofPROP_COMBINEshowEvents- whether the graph page is in event mode- Returns:
- stats to render individually, order unspecified