public class MonitorFormat extends Object
This class is an entry point for all client code that needs to create formatted values to be
displayed by monitoring views (some views may choose to call methods of MonitorField
directly for efficiency or other reasons, but not all MonitorField constants support such use).
This class may be used as is or subclassed to modify formatting logic.
As implemented by this class, all convenience methods that take MonitorCell or lists
of data channels (as AgentChannel or DisplayChannel) eventually forward the
call to format(MonitorField, List[AgentChannel]).
That method uses the following logic:
MonitorField.format(channels);
null, indicating that it does not support formatting multiple
channels, call MonitorField.format(channel) for each channel and merge the results
using merge(monitorField, formattedValues);
format(FormattedValue).
FormattedValue.NA,
indication that the data is currently unavailable
MonitorField to format a list of channels can be bypassed by calling
format(MonitorField field, AgentChannel channel)| Modifier and Type | Class and Description |
|---|---|
static class |
MonitorFormat.DefaultMonitorFormat |
| Modifier and Type | Field and Description |
|---|---|
static Color |
COLOR_BG |
static Color |
COLOR_CHANGED |
static Color |
COLOR_DISABLED |
static Color |
COLOR_ERR |
static Color |
COLOR_FG |
static Color |
COLOR_GOOD |
static Color |
COLOR_MULTI |
static Color |
COLOR_NA |
static Color |
COLOR_OFF |
static Color |
COLOR_POPUP |
static EnumMap<org.lsst.ccs.bus.states.DataProviderState,Color> |
COLOR_STATE |
static Color |
COLOR_WARN |
static MonitorFormat.DefaultMonitorFormat |
DEFAULT |
protected String |
DEFAULT_DT_FORMAT |
protected String |
DEFAULT_FLOAT_FORMAT |
protected String |
DEFAULT_INT_FORMAT |
static int |
HA_MULTI |
protected int |
LENGTH_LIMIT |
static String |
TEXT_MULTI |
| Constructor and Description |
|---|
MonitorFormat() |
| Modifier and Type | Method and Description |
|---|---|
static String |
fieldToString(MonitorField field)
Converts
MonitorField to its string representation. |
protected FormattedValue |
format(FormattedValue fv)
Completes formatting of a partially formatted value.
|
boolean |
format(MonitorCell cell)
Convenience method that updates
FormattedValue associated with the specified cell. |
boolean |
format(MonitorCell cell,
DisplayChannel channelHandle)
Convenience method that updates
FormattedValue associated with the specified cell,
assuming that the only possible reason for a change are changes in the specified channel. |
FormattedValue |
format(MonitorField field,
AgentChannel channel)
Produces formatted value, given the monitored field and the data channel whose value needs to be formatted.
|
FormattedValue |
format(MonitorField field,
DisplayChannel channelHandle)
Convenience method that produces formatted value, given the field and the channel handle.
|
FormattedValue |
format(MonitorField field,
List<AgentChannel> channels)
Produces formatted value, given the field and the list of contributing channels.
|
Object |
getValue(MonitorField field,
AgentChannel channel)
Extracts unformatted value corresponding to the specified field from a channel.
|
FormattedValue |
merge(MonitorField field,
List<FormattedValue> values)
Merges zero or more formatted values.
|
Color |
mergeConfigColor(Color c1,
Color c2)
Merges colors used to indicate a state of a configurable parameter.
|
Color |
mergeStateColor(Color c1,
Color c2)
Merges colors used to indicate the channel state.
|
static MonitorField |
stringToField(String field)
Returns
MonitorField given its string representation. |
public static final MonitorFormat.DefaultMonitorFormat DEFAULT
public static final Color COLOR_FG
public static final Color COLOR_BG
public static final Color COLOR_CHANGED
public static final Color COLOR_GOOD
public static final Color COLOR_WARN
public static final Color COLOR_ERR
public static final Color COLOR_DISABLED
public static final Color COLOR_OFF
public static final Color COLOR_POPUP
public static final Color COLOR_MULTI
public static final Color COLOR_NA
public static final EnumMap<org.lsst.ccs.bus.states.DataProviderState,Color> COLOR_STATE
public static final String TEXT_MULTI
public static final int HA_MULTI
protected String DEFAULT_FLOAT_FORMAT
protected String DEFAULT_INT_FORMAT
protected String DEFAULT_DT_FORMAT
protected int LENGTH_LIMIT
public FormattedValue format(MonitorField field, List<AgentChannel> channels)
format(MonitorField field, AgentChannel channel)
for each channel, then merges the results using merge(MonitorField field, List formattedValues).field - Monitored field.channels - Contributing channels.public FormattedValue format(MonitorField field, AgentChannel channel)
MonitorField.format(AgentChannel channel).
If the returned value is not valid, it is forwarded to format(FormattedValue) to finish formatting.field - Monitored field.channel - Data channel.protected FormattedValue format(FormattedValue fv)
value and optionally format
fields set to the unformatted value and the suggested format string, respectively.fv - Partially formatted value.public boolean format(MonitorCell cell)
FormattedValue associated with the specified cell. format(MonitorField field, List channels).cell - Cell to be formatted.public boolean format(MonitorCell cell, DisplayChannel channelHandle)
FormattedValue associated with the specified cell,
assuming that the only possible reason for a change are changes in the specified channel. format(MonitorCell cell),
ignoring the channelHandle argument. Subclasses might implement more efficient formatting
for cells that depend on multiple channels.cell - Cell to be formatted.channelHandle - Handle of the data channel that might have changed.public FormattedValue format(MonitorField field, DisplayChannel channelHandle)
format(MonitorField field, AgentChannel channel).field - Monitored field.channelHandle - Handle of a data channel whose value needs to be formatted.public FormattedValue merge(MonitorField field, List<FormattedValue> values)
field - Monitored field.values - Formatted values to merge.public Color mergeConfigColor(Color c1, Color c2)
merge(MonitorField field, List formattedValues).c1 - First color.c2 - Second color.public Color mergeStateColor(Color c1, Color c2)
merge(MonitorField field, List formattedValues).c1 - First color.c2 - Second color.public Object getValue(MonitorField field, AgentChannel channel)
field.getValue(AgentChannel channel).field - Monitored field.channel - Data channel.null if the value cannot be extracted.public static MonitorField stringToField(String field)
MonitorField given its string representation.
The default implementation selects from #AVAILABLE_GROUP_FIELDS, and returns #DEFAULT_GROUP_FIELD if none matches.field - String representation of MonitorField.MonitorField corresponding to the provided string.public static String fieldToString(MonitorField field)
MonitorField to its string representation.
The default implementation uses toString().field - MonitorField constant to convert.Copyright © 2021 LSST. All rights reserved.