From 82b08a92c87346049ba420c276d6ad24a9a2f927 Mon Sep 17 00:00:00 2001 From: Dennis Hilhorst Date: Fri, 30 Jan 2026 13:13:44 +0100 Subject: [PATCH 1/2] update rtplot data markers to use VType format --- .../trends/databrowser3/model/PlotSample.java | 9 +++++++++ .../csstudio/javafx/rtplot/data/PlotDataItem.java | 12 ++++++++++++ .../javafx/rtplot/internal/CursorMarker.java | 5 +---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/PlotSample.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/PlotSample.java index 8a464a9220..ba9ecc30c4 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/PlotSample.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/PlotSample.java @@ -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; @@ -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 @@ -237,4 +241,9 @@ public String toString() { return VTypeHelper.toString(value); } + + @Override + public String format(YAxisImpl axis, Trace trace) { + return FormatOptionHandler.format(value, FormatOption.DEFAULT, -1, true); + } } diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/data/PlotDataItem.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/data/PlotDataItem.java index a70d3880f0..0e6c77fc85 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/data/PlotDataItem.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/data/PlotDataItem.java @@ -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 @@ -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 axis, Trace trace) { + String label = axis.getTicks().formatDetailed(getValue()); + final String units = trace.getUnits(); + if (! units.isEmpty()) + label += " " + units; + return label; + } } diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/CursorMarker.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/CursorMarker.java index 244fb95d2a..f300a03ded 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/CursorMarker.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/CursorMarker.java @@ -136,10 +136,7 @@ public static void drawMarkers(final Graphics2D gc, final List 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 + ")"; From ae28d7f2a785dcf5eac3ed7e59708566ca4d81b0 Mon Sep 17 00:00:00 2001 From: Dennis Hilhorst Date: Fri, 30 Jan 2026 14:02:59 +0100 Subject: [PATCH 2/2] add VStatistics format handling --- .../java/org/phoebus/ui/vtype/FormatOptionHandler.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/ui/src/main/java/org/phoebus/ui/vtype/FormatOptionHandler.java b/core/ui/src/main/java/org/phoebus/ui/vtype/FormatOptionHandler.java index d4962514c4..ac710e8d66 100644 --- a/core/ui/src/main/java/org/phoebus/ui/vtype/FormatOptionHandler.java +++ b/core/ui/src/main/java/org/phoebus/ui/vtype/FormatOptionHandler.java @@ -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; @@ -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)