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

View File

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

View File

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