Search in sources :

Example 1 with VTypeFormat

use of org.csstudio.archive.vtype.VTypeFormat in project org.csstudio.display.builder by kasemir.

the class ValueFormatter method format.

/**
 * @return Value formatted into columns
 */
public String format(final VType value) {
    final VTypeFormat format_for_this_value;
    if (value instanceof VString || value instanceof VStringArray)
        format_for_this_value = new StringVTypeFormat();
    else {
        if (Double.isNaN(VTypeHelper.toDouble(value))) {
            if (min_max_column)
                return Messages.Export_NoValueMarker + Messages.Export_Delimiter + Messages.Export_NoValueMarker + Messages.Export_Delimiter + Messages.Export_NoValueMarker;
            else
                return Messages.Export_NoValueMarker;
        }
        format_for_this_value = format;
    }
    final VStatistics stats = (value instanceof VStatistics) ? (VStatistics) value : null;
    final StringBuilder buf = new StringBuilder();
    if (stats != null)
        // Show only the average, since min/max handled separately
        format_for_this_value.format(stats.getAverage(), stats, buf);
    else
        format_for_this_value.format(value, buf);
    // Optional min, max
    if (min_max_column) {
        buf.append(Messages.Export_Delimiter);
        if (stats != null) {
            // Turn min..max into negative & positive error
            buf.append(stats.getAverage() - stats.getMin());
            buf.append(Messages.Export_Delimiter);
            buf.append(stats.getMax() - stats.getAverage());
        } else {
            buf.append(0);
            buf.append(Messages.Export_Delimiter);
            buf.append(0);
        }
    }
    return buf.toString();
}
Also used : StringVTypeFormat(org.csstudio.archive.vtype.StringVTypeFormat) VTypeFormat(org.csstudio.archive.vtype.VTypeFormat) StringVTypeFormat(org.csstudio.archive.vtype.StringVTypeFormat) VString(org.diirt.vtype.VString) VStringArray(org.diirt.vtype.VStringArray) VStatistics(org.diirt.vtype.VStatistics)

Aggregations

StringVTypeFormat (org.csstudio.archive.vtype.StringVTypeFormat)1 VTypeFormat (org.csstudio.archive.vtype.VTypeFormat)1 VStatistics (org.diirt.vtype.VStatistics)1 VString (org.diirt.vtype.VString)1 VStringArray (org.diirt.vtype.VStringArray)1