From 40a0137dfd4a8d88929b98a4997e15305657ae95 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Jan 2017 13:13:05 +0100 Subject: [PATCH] Fixed compile warnings and performance bottlenecks in drawing --- com.minres.scviewer.database.test/pom.xml | 4 +- com.minres.scviewer.database.text/.classpath | 1 + com.minres.scviewer.database.text/pom.xml | 4 +- .../.settings/org.eclipse.jdt.core.prefs | 94 ++++++ .../database/swt/internal/RulerPainter.java | 7 +- .../database/swt/internal/SignalPainter.java | 283 +++++++++++++----- .../database/swt/internal/WaveformCanvas.java | 5 +- .../database/swt/internal/WaveformViewer.java | 10 +- .../scviewer/database/ui/WaveformColors.java | 2 +- com.minres.scviewer.e4.application/pom.xml | 3 +- .../application/parts/TransactionDetails.java | 14 +- .../e4/application/parts/WaveformViewer.java | 2 - .../preferences/DefaultValuesInitializer.java | 5 +- .../SCViewer (restart).launch | 6 +- com.minres.scviewer.feature/pom.xml | 4 +- com.minres.scviewer.target/mars.target | 8 +- com.minres.scviewer.target/pom.xml | 4 +- com.minres.scviewer.ui/.classpath | 1 + com.minres.scviewer.ui/pom.xml | 4 +- 19 files changed, 332 insertions(+), 129 deletions(-) diff --git a/com.minres.scviewer.database.test/pom.xml b/com.minres.scviewer.database.test/pom.xml index e622c47..27599c8 100644 --- a/com.minres.scviewer.database.test/pom.xml +++ b/com.minres.scviewer.database.test/pom.xml @@ -26,6 +26,4 @@ - com.minres.scviewer - 1.0.0-SNAPSHOT - \ No newline at end of file + \ No newline at end of file diff --git a/com.minres.scviewer.database.text/.classpath b/com.minres.scviewer.database.text/.classpath index 46cec6e..526caf7 100644 --- a/com.minres.scviewer.database.text/.classpath +++ b/com.minres.scviewer.database.text/.classpath @@ -3,5 +3,6 @@ + diff --git a/com.minres.scviewer.database.text/pom.xml b/com.minres.scviewer.database.text/pom.xml index a9c15c1..b9ae982 100644 --- a/com.minres.scviewer.database.text/pom.xml +++ b/com.minres.scviewer.database.text/pom.xml @@ -38,6 +38,4 @@ - com.minres.scviewer - 1.0.0-SNAPSHOT - \ No newline at end of file + \ No newline at end of file diff --git a/com.minres.scviewer.database.ui.swt/.settings/org.eclipse.jdt.core.prefs b/com.minres.scviewer.database.ui.swt/.settings/org.eclipse.jdt.core.prefs index f42de36..e4aff63 100644 --- a/com.minres.scviewer.database.ui.swt/.settings/org.eclipse.jdt.core.prefs +++ b/com.minres.scviewer.database.ui.swt/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,101 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.7 diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RulerPainter.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RulerPainter.java index 46f90e1..c7a2e53 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RulerPainter.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RulerPainter.java @@ -37,16 +37,13 @@ public class RulerPainter implements IPainter { String unit=waveCanvas.getUnitStr(); int unitMultiplier=waveCanvas.getUnitMultiplier(); long scaleFactor=waveCanvas.getScaleFactor(); - long zoomLevel = waveCanvas.getZoomLevel(); +// long zoomLevel = waveCanvas.getZoomLevel(); long start=area.x*scaleFactor; long end=start+area.width*scaleFactor; long rulerTickMinor = rulerTickMinorC*scaleFactor; long rulerTickMajor = rulerTickMajorC*scaleFactor; - if(zoomLevel%3==1){ - rulerTickMinor/=3; - rulerTickMajor/=3; - } + int minorTickY = waveCanvas.rulerHeight-5; int majorTickY = waveCanvas.rulerHeight-15; int textY=waveCanvas.rulerHeight-20; diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java index cde35ea..d41ff93 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java @@ -13,9 +13,13 @@ package com.minres.scviewer.database.swt.internal; import java.util.Map.Entry; import java.util.NavigableMap; +import javax.swing.JPanel; + import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import com.minres.scviewer.database.ISignal; @@ -25,118 +29,233 @@ import com.minres.scviewer.database.ISignalChangeSingle; import com.minres.scviewer.database.ui.TrackEntry; import com.minres.scviewer.database.ui.WaveformColors; -public class SignalPainter extends TrackPainter { - +public class SignalPainter extends TrackPainter { + private class SignalChange { + long time; + ISignalChange value; + boolean fromMap; + + public SignalChange(Entry entry) { + time = entry.getKey(); + value = entry.getValue(); + fromMap = true; + } + + public void set(Entry entry, Long actTime) { + if (entry != null) { + time = entry.getKey(); + value = entry.getValue(); + fromMap = true; + } else { + time = actTime; + fromMap = false; + } + } + + public void assign(SignalChange other) { + time = other.time; + value = other.value; + fromMap = other.fromMap; + } + } + /** * */ + private static final JPanel DUMMY_PANEL = new JPanel(); + private final WaveformCanvas waveCanvas; private ISignal signal; + int yOffsetT; + int yOffsetM; + int yOffsetB; + int maxX; + public SignalPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) { super(trackEntry, even); this.waveCanvas = txDisplay; - this.signal=trackEntry.getSignal(); + this.signal = trackEntry.getSignal(); } - public void paintArea(GC gc, Rectangle area) { - if(trackEntry.selected) + private int getXEnd(long time) { + long ltmp = time / this.waveCanvas.getScaleFactor(); + return ltmp > maxX ? maxX : (int) ltmp; + } + + public void paintArea(GC gc, Rectangle area) { + if (trackEntry.selected) gc.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()]); else - gc.setBackground(this.waveCanvas.colors[even?WaveformColors.TRACK_BG_EVEN.ordinal():WaveformColors.TRACK_BG_ODD.ordinal()]); + gc.setBackground(this.waveCanvas.colors[even ? WaveformColors.TRACK_BG_EVEN.ordinal() : WaveformColors.TRACK_BG_ODD.ordinal()]); gc.setFillRule(SWT.FILL_EVEN_ODD); gc.fillRectangle(area); - Entry firstChange=signal.getEvents().floorEntry(area.x*this.waveCanvas.getScaleFactor()); - Entry lastTx=signal.getEvents().ceilingEntry((area.x+area.width)*this.waveCanvas.getScaleFactor()); - if(firstChange==null){ - if(lastTx==null) return; - firstChange = signal.getEvents().firstEntry(); - } else if(lastTx==null){ - lastTx=signal.getEvents().lastEntry(); + long beginTime = area.x * this.waveCanvas.getScaleFactor(); + long endTime = (area.x + area.width) * this.waveCanvas.getScaleFactor(); + Entry first = signal.getEvents().floorEntry(beginTime); + Entry last = signal.getEvents().floorEntry(endTime); + if (first == null) { + if (last == null) + return; + first = signal.getEvents().firstEntry(); + } else if (last == null) { + last = signal.getEvents().lastEntry(); } gc.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]); gc.setLineStyle(SWT.LINE_SOLID); gc.setLineWidth(1); - Entry left=firstChange; - if(left.getValue() instanceof ISignalChangeSingle){ - NavigableMap entries=signal.getEvents().subMap(firstChange.getKey(), false, lastTx.getKey(), true); - for(Entry right:entries.entrySet()){ - int xEnd= (int)(right.getKey()/this.waveCanvas.getScaleFactor()); - int xBegin= (int)(left.getKey()/this.waveCanvas.getScaleFactor()); - if(xEnd>xBegin){ - int yOffset = this.waveCanvas.getTrackHeight()/2; - Color color = this.waveCanvas.colors[WaveformColors.SIGNALX.ordinal()]; - switch(((ISignalChangeSingle) left.getValue()).getValue()){ - case '1': - color=this.waveCanvas.colors[WaveformColors.SIGNAL1.ordinal()]; - yOffset = this.waveCanvas.getTrackHeight()/5; - break; - case '0': - color=this.waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()]; - yOffset = 4*this.waveCanvas.getTrackHeight()/5; - break; - case 'Z': - color=this.waveCanvas.colors[WaveformColors.SIGNALZ.ordinal()]; - break; - default: - } - yOffset+=area.y; - gc.setForeground(color); - gc.drawLine(xBegin, yOffset, xEnd, yOffset); - int yNext = this.waveCanvas.getTrackHeight()/2; - switch(((ISignalChangeSingle) right.getValue()).getValue()){ - case '1': - yNext = this.waveCanvas.getTrackHeight()/5+area.y; - break; - case '0': - yNext = 4*this.waveCanvas.getTrackHeight()/5+area.y; - break; - default: - } - gc.drawLine(xEnd, yOffset, xEnd, yNext); - } - left=right; + NavigableMap entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true); + SignalChange left = new SignalChange(first); + SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first); + SignalStencil stencil = left.value instanceof ISignalChangeSingle ? new SingleBitStencil() : new MultiBitStencil(gc); + + maxX = area.x + area.width; + yOffsetT = this.waveCanvas.getTrackHeight() / 5 + area.y; + yOffsetM = this.waveCanvas.getTrackHeight() / 2 + area.y; + yOffsetB = 4 * this.waveCanvas.getTrackHeight() / 5 + area.y; + int xBegin = Math.max(area.x, (int) (left.time / this.waveCanvas.getScaleFactor())); + int xEnd = Math.max(area.x, getXEnd(right.time)); + boolean multiple = false; + if (xEnd == xBegin) { + // this can trigger if + // a) left == right + // b) left to close to right + if (left.time == right.time) { + right.time = endTime; + + } else { + multiple = true; + long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor(); + right.set(entries.floorEntry(eTime), endTime); + right.time = eTime; } - } else if(left.getValue() instanceof ISignalChangeMulti){ - NavigableMap entries=signal.getEvents().subMap(firstChange.getKey(), false, lastTx.getKey(), true); - for(Entry right:entries.entrySet()){ - int yOffsetT = this.waveCanvas.getTrackHeight()/5+area.y; - int yOffsetM = this.waveCanvas.getTrackHeight()/2+area.y; - int yOffsetB = 4*this.waveCanvas.getTrackHeight()/5+area.y; - Color colorBorder = this.waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()]; - ISignalChangeMulti last = (ISignalChangeMulti) left.getValue(); - if(last.getValue().toString().contains("X")){ - colorBorder=this.waveCanvas.colors[WaveformColors.SIGNALX.ordinal()]; - }else if(last.getValue().toString().contains("Z")){ - colorBorder=this.waveCanvas.colors[WaveformColors.SIGNALZ.ordinal()]; - } - int beginTime= (int)(left.getKey()/this.waveCanvas.getScaleFactor()); - int endTime= (int)(right.getKey()/this.waveCanvas.getScaleFactor()); - int[] points = { - beginTime,yOffsetM, - beginTime+1,yOffsetT, - endTime-1,yOffsetT, - endTime,yOffsetM, - endTime-1,yOffsetB, - beginTime+1,yOffsetB + xEnd = getXEnd(right.time); + } + + do { + stencil.draw(gc, area, left.value, right.value, xBegin, xEnd, multiple); + if (right.time >= endTime) + break; + left.assign(right); + xBegin = xEnd; + right.set(entries.higherEntry(left.time), endTime); + xEnd = getXEnd(right.time); + multiple = false; + if (xEnd == xBegin) { + multiple = true; + long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor(); + right.set(entries.floorEntry(eTime), endTime); + xEnd = getXEnd(eTime); + } + } while (left.time < endTime); + } + + private interface SignalStencil { + + public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple); + } + + private class MultiBitStencil implements SignalStencil { + + private java.awt.Font tmpAwtFont; + private int height; + + public MultiBitStencil(GC gc) { + FontData fd = gc.getFont().getFontData()[0]; + height = gc.getDevice().getDPI().y * fd.getHeight() / 72; + tmpAwtFont = new java.awt.Font(fd.getName(), fd.getStyle(), height); + } + + public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) { + Color colorBorder = waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()]; + ISignalChangeMulti last = (ISignalChangeMulti) left; + if (last.getValue().toString().contains("X")) { + colorBorder = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()]; + } else if (last.getValue().toString().contains("Z")) { + colorBorder = waveCanvas.colors[WaveformColors.SIGNALZ.ordinal()]; + } + int width = xEnd - xBegin; + if (width > 1) { + int[] points = { + xBegin, yOffsetM, + xBegin + 1, yOffsetT, + xEnd - 1, yOffsetT, + xEnd, yOffsetM, + xEnd - 1, yOffsetB, + xBegin + 1, yOffsetB }; gc.setForeground(colorBorder); gc.drawPolygon(points); - gc.setForeground(this.waveCanvas.colors[WaveformColors.SIGNAL_TEXT.ordinal()]); - int size = gc.getDevice().getDPI().y * gc.getFont().getFontData()[0].getHeight()/72; - if(beginTime6) { + gc.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_TEXT.ordinal()]); + String label = "h'" + last.getValue().toHexString(); + Point bb = getBoxWidth(gc, label); + if (xBegin < area.x) { + xBegin = area.x; + width = xEnd - xBegin; + } + if (width > (bb.x+1)) { Rectangle old = gc.getClipping(); - gc.setClipping(beginTime+3, yOffsetT, endTime-beginTime-5, yOffsetB-yOffsetT); - gc.drawText("h'"+last.getValue().toHexString(), beginTime+3, yOffsetM-size/2-1); + gc.setClipping(xBegin + 3, yOffsetT, xEnd - xBegin - 5, yOffsetB - yOffsetT); + gc.drawText(label, xBegin + 3, yOffsetM - bb.y / 2 - 1); gc.setClipping(old); } - left=right; + } else { + gc.setForeground(colorBorder); + gc.drawLine(xEnd, yOffsetT, xEnd, yOffsetB); } } + + private Point getBoxWidth(GC gc, String label) { + return new Point(DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(label), height); + } + } + private class SingleBitStencil implements SignalStencil { + public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) { + if (multiple) { + gc.setForeground(waveCanvas.colors[WaveformColors.SIGNALU.ordinal()]); + gc.drawLine(xBegin, yOffsetT, xBegin, yOffsetB); + gc.drawLine(xEnd, yOffsetT, xEnd, yOffsetB); + } else { + Color color = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()]; + int yOffset = yOffsetM; + switch (((ISignalChangeSingle) left).getValue()) { + case '1': + color = waveCanvas.colors[WaveformColors.SIGNAL1.ordinal()]; + yOffset = yOffsetT; + break; + case '0': + color = waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()]; + yOffset = yOffsetB; + break; + case 'Z': + color = waveCanvas.colors[WaveformColors.SIGNALZ.ordinal()]; + break; + default: + } + gc.setForeground(color); + if (xEnd > maxX) { + gc.drawLine(xBegin, yOffset, maxX, yOffset); + } else { + gc.drawLine(xBegin, yOffset, xEnd, yOffset); + int yNext = yOffsetM; + switch (((ISignalChangeSingle) right).getValue()) { + case '1': + yNext = yOffsetT; + break; + case '0': + yNext = yOffsetB; + break; + default: + } + if (yOffset != yNext) + gc.drawLine(xEnd, yOffset, xEnd, yNext); + } + } + } + + } public ISignal getSignal() { return signal; diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java index 841e80b..333cb4f 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java @@ -153,8 +153,9 @@ public class WaveformCanvas extends Canvas { colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN); colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN); - colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY); - colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 128, 182); + colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW); + colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51); + colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW); colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY); diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java index 3b88ad1..2d3a7dd 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java @@ -724,10 +724,12 @@ public class WaveformViewer implements IWaveformViewer { public void moveCursor(GotoDirection direction) { long time = getCursorTime(); NavigableMap map=null; - if(currentWaveformSelection.isStream()){ - map=currentWaveformSelection.getStream().getEvents(); - } else if(currentWaveformSelection.isSignal()){ - map=currentWaveformSelection.getSignal().getEvents(); + if(currentWaveformSelection!=null) { + if(currentWaveformSelection.isStream()){ + map=currentWaveformSelection.getStream().getEvents(); + } else if(currentWaveformSelection.isSignal()){ + map=currentWaveformSelection.getSignal().getEvents(); + } } if(map!=null){ Entry entry=direction==GotoDirection.PREV?map.lowerEntry(time):map.higherEntry(time); diff --git a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/WaveformColors.java b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/WaveformColors.java index c46ec0c..382f526 100644 --- a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/WaveformColors.java +++ b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/WaveformColors.java @@ -14,7 +14,7 @@ public enum WaveformColors { LINE, LINE_HIGHLITE, TRACK_BG_EVEN, TRACK_BG_ODD, TRACK_BG_HIGHLITE, TX_BG, TX_BG_HIGHLITE, TX_BORDER, - SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNAL_TEXT, + SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT, CURSOR, CURSOR_DRAG, CURSOR_TEXT, MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE } \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/pom.xml b/com.minres.scviewer.e4.application/pom.xml index 3634a4c..827f795 100644 --- a/com.minres.scviewer.e4.application/pom.xml +++ b/com.minres.scviewer.e4.application/pom.xml @@ -9,5 +9,4 @@ eclipse-plugin 1.1.0-SNAPSHOT - com.minres.scviewer - \ No newline at end of file + \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java index 9adeebe..2085398 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java @@ -36,7 +36,7 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewerColumn; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; @@ -125,7 +125,7 @@ public class TransactionDetails { treeViewer.setLabelProvider(new TxPropertiesLabelProvider()); treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); treeViewer.addFilter(attributeFilter); - treeViewer.setSorter(viewSorter); + treeViewer.setComparator(viewSorter); treeViewer.setAutoExpandLevel(2); // Set up the table @@ -138,7 +138,7 @@ public class TransactionDetails { col1.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.NAME))); col1.getColumn().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - ((TxAttributeViewerSorter) treeViewer.getSorter()).doSort(COLUMN_FIRST); + ((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_FIRST); treeViewer.refresh(); } }); @@ -149,7 +149,7 @@ public class TransactionDetails { col2.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.TYPE))); col2.getColumn().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - ((TxAttributeViewerSorter) treeViewer.getSorter()).doSort(COLUMN_SECOND); + ((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_SECOND); treeViewer.refresh(); } }); @@ -160,7 +160,7 @@ public class TransactionDetails { col3.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.VALUE))); col3.getColumn().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - ((TxAttributeViewerSorter) treeViewer.getSorter()).doSort(COLUMN_SECOND); + ((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_SECOND); treeViewer.refresh(); } }); @@ -290,7 +290,7 @@ public class TransactionDetails { /** * The Class TxAttributeViewerSorter. */ - class TxAttributeViewerSorter extends ViewerSorter { + class TxAttributeViewerSorter extends ViewerComparator { /** The Constant ASCENDING. */ private static final int ASCENDING = 0; @@ -345,7 +345,7 @@ public class TransactionDetails { rc = getComparator().compare(p1.getDataType().name(), p2.getDataType().name()); break; case COLUMN_THIRD: - rc = getComparator().compare(p1.getValue(), p2.getValue()); + rc = getComparator().compare(p1.getValue().toString(), p2.getValue().toString()); break; } // If descending order, flip the direction diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index 94408db..ae99c02 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -14,7 +14,6 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -22,7 +21,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java index 9bea8a5..ee338b3 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java @@ -43,8 +43,9 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer { colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN); colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN); - colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY); - colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 128, 182); + colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW); + colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51); + colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW); colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY); diff --git a/com.minres.scviewer.e4.product/SCViewer (restart).launch b/com.minres.scviewer.e4.product/SCViewer (restart).launch index 723a487..69fd561 100644 --- a/com.minres.scviewer.e4.product/SCViewer (restart).launch +++ b/com.minres.scviewer.e4.product/SCViewer (restart).launch @@ -16,13 +16,13 @@ - + - + - + diff --git a/com.minres.scviewer.feature/pom.xml b/com.minres.scviewer.feature/pom.xml index 12f4d7f..a67671a 100644 --- a/com.minres.scviewer.feature/pom.xml +++ b/com.minres.scviewer.feature/pom.xml @@ -8,6 +8,4 @@ 1.0.0-SNAPSHOT ../com.minres.scviewer.parent - com.minres.scviewer - 1.0.0-SNAPSHOT - \ No newline at end of file + \ No newline at end of file diff --git a/com.minres.scviewer.target/mars.target b/com.minres.scviewer.target/mars.target index 51b6ba5..0155555 100644 --- a/com.minres.scviewer.target/mars.target +++ b/com.minres.scviewer.target/mars.target @@ -1,15 +1,15 @@ - + - + + - - + diff --git a/com.minres.scviewer.target/pom.xml b/com.minres.scviewer.target/pom.xml index 08e9ea3..417a65b 100644 --- a/com.minres.scviewer.target/pom.xml +++ b/com.minres.scviewer.target/pom.xml @@ -16,6 +16,4 @@ ../com.minres.scviewer.parent - com.minres.scviewer - 1.0.0-SNAPSHOT - \ No newline at end of file + \ No newline at end of file diff --git a/com.minres.scviewer.ui/.classpath b/com.minres.scviewer.ui/.classpath index b9a5b1e..6dde652 100644 --- a/com.minres.scviewer.ui/.classpath +++ b/com.minres.scviewer.ui/.classpath @@ -3,5 +3,6 @@ + diff --git a/com.minres.scviewer.ui/pom.xml b/com.minres.scviewer.ui/pom.xml index 724502a..5c71fb2 100644 --- a/com.minres.scviewer.ui/pom.xml +++ b/com.minres.scviewer.ui/pom.xml @@ -8,6 +8,4 @@ ../com.minres.scviewer.parent eclipse-plugin - com.minres.scviewer - 1.0.0-SNAPSHOT - \ No newline at end of file + \ No newline at end of file