fix arrow painter if stream is moved

This commit is contained in:
Eyck Jentzsch 2020-10-17 13:54:34 +02:00
parent dd6a8669b1
commit 9a9b25622c
3 changed files with 18 additions and 14 deletions

View File

@ -49,7 +49,7 @@ public class ArrowPainter implements IPainter {
long scaleFactor; long scaleFactor;
boolean deferredUpdate; boolean deferUpdate;
public ArrowPainter(WaveformCanvas waveCanvas, RelationType relationType) { public ArrowPainter(WaveformCanvas waveCanvas, RelationType relationType) {
this.waveCanvas = waveCanvas; this.waveCanvas = waveCanvas;
@ -80,12 +80,14 @@ public class ArrowPainter implements IPainter {
} }
protected void calculateGeometries() { protected void calculateGeometries() {
deferredUpdate = false; deferUpdate = false;
iRect.clear();
oRect.clear();
ITxStream<?> stream = tx.getStream(); ITxStream<?> stream = tx.getStream();
IWaveformPainter painter = waveCanvas.wave2painterMap.get(stream); IWaveformPainter painter = waveCanvas.wave2painterMap.get(stream);
if (painter == null) { // stream has been added but painter not yet if (painter == null) { // stream has been added but painter not yet
// created // created
deferredUpdate = true; deferUpdate = true;
return; return;
} }
int laneHeight = painter.getHeight() / stream.getMaxConcurrency(); int laneHeight = painter.getHeight() / stream.getMaxConcurrency();
@ -117,11 +119,12 @@ public class ArrowPainter implements IPainter {
Color fgColor = waveCanvas.colors[WaveformColors.REL_ARROW.ordinal()]; Color fgColor = waveCanvas.colors[WaveformColors.REL_ARROW.ordinal()];
Color highliteColor = waveCanvas.colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()]; Color highliteColor = waveCanvas.colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()];
if (deferredUpdate || (tx != null && waveCanvas.getScaleFactor() != scaleFactor)) { if(tx==null) return;
if (!deferUpdate) {
scaleFactor = waveCanvas.getScaleFactor(); scaleFactor = waveCanvas.getScaleFactor();
calculateGeometries(); calculateGeometries();
} }
if(txRectangle == null) return; if(deferUpdate) return;
int correctionValue = (int)(selectionOffset); int correctionValue = (int)(selectionOffset);
Rectangle correctedTargetRectangle = new Rectangle(txRectangle.x+correctionValue, txRectangle.y, txRectangle.width, txRectangle.height); Rectangle correctedTargetRectangle = new Rectangle(txRectangle.x+correctionValue, txRectangle.y, txRectangle.width, txRectangle.height);
for (LinkEntry entry : iRect) { for (LinkEntry entry : iRect) {

View File

@ -395,7 +395,7 @@ public class TransactionDetails {
if( part == null || ! (part.getObject() instanceof WaveformViewer ) ) if( part == null || ! (part.getObject() instanceof WaveformViewer ) )
return; return;
if(treeViewer!=null && selection!=null && !treeViewer.getTree().isDisposed()){ if(treeViewer!=null && selection!=null && !treeViewer.getTree().isDisposed()){
if( selection instanceof IStructuredSelection) { if( selection instanceof IStructuredSelection && !selection.isEmpty()) {
setInput(((IStructuredSelection)selection).getFirstElement()); setInput(((IStructuredSelection)selection).getFirstElement());
} }
} }

View File

@ -1004,6 +1004,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
waveformPane.getStreamList().addAll(streams); waveformPane.getStreamList().addAll(streams);
} else { } else {
Object first = selection.getFirstElement(); Object first = selection.getFirstElement();
if(first instanceof ITx) {
IWaveform stream = (first instanceof ITx) ? ((ITx) first).getStream() : (IWaveform) first; IWaveform stream = (first instanceof ITx) ? ((ITx) first).getStream() : (IWaveform) first;
TrackEntry trackEntry = waveformPane.getEntryForStream(stream); TrackEntry trackEntry = waveformPane.getEntryForStream(stream);
if (insert) { if (insert) {
@ -1012,7 +1013,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
} else { } else {
waveformPane.getStreamList().addAll(streams); waveformPane.getStreamList().addAll(streams);
} }
}
} }
setFocus(); setFocus();
} }