Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import java.time.Instant;
import java.util.concurrent.atomic.AtomicInteger;

import org.csstudio.javafx.rtplot.Trace;
import org.csstudio.javafx.rtplot.data.PlotDataItem;
import org.csstudio.javafx.rtplot.internal.YAxisImpl;
import org.epics.vtype.Alarm;
import org.epics.vtype.AlarmSeverity;
import org.epics.vtype.AlarmStatus;
Expand All @@ -23,6 +25,8 @@
import org.epics.vtype.VEnum;
import org.phoebus.archive.vtype.VTypeHelper;
import org.phoebus.pv.TimeHelper;
import org.phoebus.ui.vtype.FormatOption;
import org.phoebus.ui.vtype.FormatOptionHandler;

/** Data Sample from control system ({@link VType})
* with interface for XYGraph
Expand Down Expand Up @@ -237,4 +241,9 @@ public String toString()
{
return VTypeHelper.toString(value);
}

@Override
public String format(YAxisImpl<Instant> axis, Trace<Instant> trace) {
return FormatOptionHandler.format(value, FormatOption.DEFAULT, -1, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
******************************************************************************/
package org.csstudio.javafx.rtplot.data;

import org.csstudio.javafx.rtplot.Trace;
import org.csstudio.javafx.rtplot.internal.YAxisImpl;

import java.time.Instant;

/** One 'point' of a trace in the plot
Expand Down Expand Up @@ -48,4 +51,13 @@ public default String getInfo()

/** @return if this data point is real or just a mechanical point, e.g. the 'now' point. */
public default boolean isVirtual() { return false; }

/** @return a formatted string of this plot sample given the axis it is on */
public default String format(YAxisImpl<XTYPE> axis, Trace<XTYPE> trace) {
String label = axis.getTicks().formatDetailed(getValue());
final String units = trace.getUnits();
if (! units.isEmpty())
label += " " + units;
return label;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ public static void drawMarkers(final Graphics2D gc, final List<CursorMarker> mar
final double value = sample.getValue();
if (Double.isFinite(value) && axis.getValueRange().contains(value))
{
String label = axis.getTicks().formatDetailed(value);
final String units = trace.getUnits();
if (! units.isEmpty())
label += " " + units;
String label = sample.format(axis, trace);
final String info = sample.getInfo();
if (info != null && info.length() > 0)
label += " (" + info + ")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.epics.vtype.VStringArray;
import org.epics.vtype.VTable;
import org.epics.vtype.VType;
import org.epics.vtype.VStatistics;
import org.phoebus.pv.LongString;
import org.phoebus.ui.Preferences;

Expand Down Expand Up @@ -110,6 +111,13 @@ public static String format(final VType value, final FormatOption option,
return text + " " + number.getDisplay().getUnit();
return text;
}
else if (value instanceof VStatistics stats)
{
String text = formatNumber(stats.getAverage(), stats.getDisplay(), option, precision);
if (show_units && !stats.getDisplay().getUnit().isEmpty())
return text + " " + stats.getDisplay().getUnit();
return text;
}
else if (value instanceof VString)
return ((VString)value).getValue();
else if (value instanceof VEnum)
Expand Down