From f6cc12e8c3d75b9447a5cad63f3c69770177b0ab Mon Sep 17 00:00:00 2001 From: eyck Date: Sat, 11 Jul 2020 19:36:45 +0200 Subject: [PATCH] fix analog painting calculation issue --- .../scviewer/database/swt/internal/SignalPainter.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java index 6fe5420..883bfc6 100644 --- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java +++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java @@ -249,7 +249,7 @@ public class SignalPainter extends TrackPainter { final boolean continous; private long minVal; private long range; - + double yRange = (yOffsetB-yOffsetT); public MultiBitStencilAnalog(NavigableMap entries, Object left, boolean continous, boolean signed) { this.continous=continous; Collection values = ((NavigableMap) entries).values(); @@ -276,8 +276,8 @@ public class SignalPainter extends TrackPainter { long leftVal = ((BitVector) left).toUnsignedValue(); long rightVal= ((BitVector) right).toUnsignedValue(); proj.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_REAL.ordinal()]); - int yOffsetLeft = (int) ((leftVal-minVal) / range * (yOffsetB-yOffsetT)); - int yOffsetRight = (int) ((rightVal-minVal) / range * (yOffsetB-yOffsetT)); + int yOffsetLeft = (int) ((leftVal-minVal) * yRange / range); + int yOffsetRight = (int) ((rightVal-minVal) * yRange / range); if(continous) { if (xEnd > maxPosX) { proj.drawLine(xBegin, yOffsetB-yOffsetLeft, maxPosX, yOffsetB-yOffsetRight); @@ -401,8 +401,8 @@ public class SignalPainter extends TrackPainter { } } else { proj.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_REAL.ordinal()]); - int yOffsetLeft = (int) ((leftVal-minVal) / range * (yOffsetB-yOffsetT)); - int yOffsetRight = Double.isNaN(rightVal)?yOffsetLeft:(int) ((rightVal-minVal) / range * (yOffsetB-yOffsetT)); + int yOffsetLeft = (int) ((leftVal-minVal) * (yOffsetB-yOffsetT) / range); + int yOffsetRight = Double.isNaN(rightVal)?yOffsetLeft:(int) ((rightVal-minVal) * (yOffsetB-yOffsetT) / range); if(continous) { if (xEnd > maxPosX) { proj.drawLine(xBegin, yOffsetB-yOffsetLeft, maxPosX, yOffsetB-yOffsetRight);