Skip to content

Commit 8879081

Browse files
fix: leading point at 'now' is rendered, incorrectly implying it is real data
1 parent 41f71f6 commit 8879081

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/PVSamples.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,17 @@ public PlotSample get(final int index)
115115
if (lock.getReadHoldCount() <= 0 && ! lock.isWriteLockedByCurrentThread())
116116
logger.log(Level.WARNING, "Missing lock", new Exception("Stack Trace"));
117117

118+
// If the data point is 'real'/raw then return it
118119
final int raw_count = getRawSize();
119120
if (index < raw_count)
120121
return getRawSample(index);
121-
// Last sample is valid, so it should still apply 'now'
122+
// Else, create a 'virtual' point by transforming its
123+
// timestamp to 'now' to display the currently implied value
122124
final PlotSample sample = getRawSample(raw_count-1);
123125
if (Instant.now().compareTo(sample.getPosition()) < 0)
124126
return sample;
125127
else
126-
return new PlotSample(sample.getSource(), VTypeHelper.transformTimestampToNow(sample.getVType()));
128+
return new PlotSample(sample.getSource(), VTypeHelper.transformTimestampToNow(sample.getVType()), true);
127129
}
128130

129131
/** Get 'raw' sample, no continuation until 'now'

app/databrowser/src/main/java/org/csstudio/trends/databrowser3/model/PlotSample.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public class PlotSample implements PlotDataItem<Instant>
4747
/** Waveform index */
4848
private AtomicInteger waveform_index;
4949

50+
/** Designates if this is a real data point, or just a 'virtual' one
51+
* created only for mechanical purposes (i.e. to connect the last data point to 'now')
52+
*/
53+
private boolean isVirtualSample = false;
54+
5055
/** Initialize with valid control system value
5156
* @param waveform_index Waveform index
5257
* @param source Info about the source of this sample
@@ -100,6 +105,12 @@ public PlotSample(final String source, final VType value)
100105
this(default_waveform_index, source, value);
101106
}
102107

108+
public PlotSample(final String source, final VType value, boolean isVirtualSample)
109+
{
110+
this(default_waveform_index, source, value);
111+
this.isVirtualSample = isVirtualSample;
112+
}
113+
103114
/** Initialize with (error) info, creating a non-plottable sample 'now'
104115
* @param source Data source hint
105116
* @param info Text used for info as well as error message
@@ -210,6 +221,11 @@ public String getInfo()
210221
return info;
211222
}
212223

224+
@Override
225+
public boolean isVirtual() {
226+
return this.isVirtualSample;
227+
}
228+
213229
@Override
214230
public String toString()
215231
{

app/rtplot/src/main/java/org/csstudio/javafx/rtplot/data/PlotDataItem.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ public default String getInfo()
4545
{
4646
return Double.toString(getValue());
4747
};
48+
49+
/** @return if this data point is real or just a mechanical point, e.g. the 'now' point. */
50+
public default boolean isVirtual() { return false; }
4851
}

app/rtplot/src/main/java/org/csstudio/javafx/rtplot/internal/TracePainter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,18 @@ final private void drawPoints(final Graphics2D gc,
507507
{
508508
final PlotDataItem<XTYPE> item = data.get(i);
509509
final double value = item.getValue();
510+
final XTYPE loc = item.getPosition();
510511
if (!Double.isNaN(value))
511512
{
512513
final int x = clipX(Math.round(x_transform.transform(item.getPosition())));
513514
final int y = clipY(y_axis.getScreenCoord(value));
514515
if (x == last_x && y == last_y)
515516
continue;
517+
// If the point is virtual, draw it without a size; drawing a virtual point visually
518+
// implies the point is real data, and this often is not the case.
519+
if(item.isVirtual()) {
520+
return;
521+
}
516522
switch (point_type)
517523
{
518524
case SQUARES:

0 commit comments

Comments
 (0)