move settings into style provider
This commit is contained in:
parent
7c27bcec47
commit
bedf4c5c4d
|
@ -76,7 +76,7 @@ class TxStream extends HierNode implements IWaveform {
|
||||||
def rowendtime = [0]
|
def rowendtime = [0]
|
||||||
events.keySet().each{long time ->
|
events.keySet().each{long time ->
|
||||||
def value=events.get(time)
|
def value=events.get(time)
|
||||||
def starts=value.findAll{ITxEvent event ->event.type==EventKind.BEGIN}
|
def starts=value.findAll{IEvent event ->event.kind==EventKind.BEGIN}
|
||||||
starts.each {ITxEvent event ->
|
starts.each {ITxEvent event ->
|
||||||
Tx tx = event.transaction
|
Tx tx = event.transaction
|
||||||
def rowIdx = 0
|
def rowIdx = 0
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.minres.scviewer.database.ui;
|
||||||
|
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.graphics.Font;
|
||||||
|
|
||||||
|
public interface IWaveformStyleProvider {
|
||||||
|
|
||||||
|
Font getNameFont();
|
||||||
|
|
||||||
|
Font getNameFontHighlite();
|
||||||
|
|
||||||
|
int getTrackHeight();
|
||||||
|
|
||||||
|
Color getColor(WaveformColors type);
|
||||||
|
}
|
|
@ -11,7 +11,6 @@
|
||||||
package com.minres.scviewer.database.ui;
|
package com.minres.scviewer.database.ui;
|
||||||
|
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
@ -19,7 +18,6 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||||
import org.eclipse.swt.events.DisposeListener;
|
import org.eclipse.swt.events.DisposeListener;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
|
@ -37,6 +35,8 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
|
||||||
|
|
||||||
public void removeSelectionChangedListener(ISelectionChangedListener listener);
|
public void removeSelectionChangedListener(ISelectionChangedListener listener);
|
||||||
|
|
||||||
|
public void setStyleProvider(IWaveformStyleProvider styleProvider);
|
||||||
|
|
||||||
public void update();
|
public void update();
|
||||||
|
|
||||||
public Control getControl();
|
public Control getControl();
|
||||||
|
@ -103,8 +103,6 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
|
||||||
|
|
||||||
public List<ICursor> getCursorList();
|
public List<ICursor> getCursorList();
|
||||||
|
|
||||||
public void setColors(HashMap<WaveformColors, RGB> colourMap);
|
|
||||||
|
|
||||||
public long getBaselineTime();
|
public long getBaselineTime();
|
||||||
|
|
||||||
public void setBaselineTime(Long scale);
|
public void setBaselineTime(Long scale);
|
||||||
|
|
|
@ -14,4 +14,6 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
public interface IWaveformViewFactory {
|
public interface IWaveformViewFactory {
|
||||||
public IWaveformView createPanel(Composite parent);
|
public IWaveformView createPanel(Composite parent);
|
||||||
|
|
||||||
|
public IWaveformView createPanel(Composite parent, IWaveformStyleProvider styleProvider);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
package com.minres.scviewer.database.ui.swt;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.graphics.Font;
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.wb.swt.SWTResourceManager;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||||
|
import com.minres.scviewer.database.ui.WaveformColors;
|
||||||
|
|
||||||
|
public class DefaultWaveformStyleProvider implements IWaveformStyleProvider {
|
||||||
|
|
||||||
|
Composite parent;
|
||||||
|
|
||||||
|
private Font nameFont;
|
||||||
|
|
||||||
|
private Font nameFontB;
|
||||||
|
|
||||||
|
Color[] colors = new Color[WaveformColors.values().length];
|
||||||
|
|
||||||
|
public DefaultWaveformStyleProvider() {
|
||||||
|
nameFont = Display.getCurrent().getSystemFont();
|
||||||
|
nameFontB = SWTResourceManager.getBoldFont(nameFont);
|
||||||
|
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||||
|
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
||||||
|
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
||||||
|
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
|
||||||
|
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
|
||||||
|
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||||
|
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||||
|
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||||
|
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||||
|
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||||
|
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.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||||
|
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||||
|
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||||
|
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||||
|
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||||
|
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
|
||||||
|
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||||
|
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
|
||||||
|
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* needs redraw() afterwards
|
||||||
|
* @param colourMap
|
||||||
|
*/
|
||||||
|
public void initColors(HashMap<WaveformColors, RGB> colourMap) {
|
||||||
|
Display d = parent.getDisplay();
|
||||||
|
if (colourMap != null) {
|
||||||
|
for (WaveformColors c : WaveformColors.values()) {
|
||||||
|
if (colourMap.containsKey(c))
|
||||||
|
colors[c.ordinal()] = new Color(d, colourMap.get(c));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Font getNameFont() {
|
||||||
|
return nameFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Font getNameFontHighlite() {
|
||||||
|
return nameFontB;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTrackHeight() {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Color getColor(WaveformColors type) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return colors[type.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ package com.minres.scviewer.database.ui.swt;
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||||
import com.minres.scviewer.database.ui.IWaveformView;
|
import com.minres.scviewer.database.ui.IWaveformView;
|
||||||
import com.minres.scviewer.database.ui.IWaveformViewFactory;
|
import com.minres.scviewer.database.ui.IWaveformViewFactory;
|
||||||
import com.minres.scviewer.database.ui.swt.internal.WaveformView;
|
import com.minres.scviewer.database.ui.swt.internal.WaveformView;
|
||||||
|
@ -20,7 +21,12 @@ public class WaveformViewFactory implements IWaveformViewFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IWaveformView createPanel(Composite parent) {
|
public IWaveformView createPanel(Composite parent) {
|
||||||
return new WaveformView(parent);
|
return new WaveformView(parent, new DefaultWaveformStyleProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IWaveformView createPanel(Composite parent, IWaveformStyleProvider styleProvider) {
|
||||||
|
return new WaveformView(parent, styleProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ArrowPainter implements IPainter {
|
||||||
|
|
||||||
private final int xCtrlOffset = 50;
|
private final int xCtrlOffset = 50;
|
||||||
|
|
||||||
private final int yCtrlOffset = 30;
|
private int yCtrlOffset = 30;
|
||||||
|
|
||||||
private WaveformCanvas waveCanvas;
|
private WaveformCanvas waveCanvas;
|
||||||
|
|
||||||
|
@ -101,11 +101,12 @@ public class ArrowPainter implements IPainter {
|
||||||
ITx otherTx = useTarget ? iTxRelation.getTarget() : iTxRelation.getSource();
|
ITx otherTx = useTarget ? iTxRelation.getTarget() : iTxRelation.getSource();
|
||||||
if (waveCanvas.wave2painterMap.containsKey(otherTx.getStream())) {
|
if (waveCanvas.wave2painterMap.containsKey(otherTx.getStream())) {
|
||||||
IWaveformPainter painter = waveCanvas.wave2painterMap.get(otherTx.getStream());
|
IWaveformPainter painter = waveCanvas.wave2painterMap.get(otherTx.getStream());
|
||||||
int laneHeight = painter.getHeight() / tx.getStream().getWidth();
|
int height = waveCanvas.styleProvider.getTrackHeight();
|
||||||
Rectangle bb = new Rectangle((int) (otherTx.getBeginTime() / scaleFactor),
|
Rectangle bb = new Rectangle(
|
||||||
waveCanvas.rulerHeight + painter.getVerticalOffset()
|
(int) (otherTx.getBeginTime() / scaleFactor),
|
||||||
+ laneHeight * otherTx.getConcurrencyIndex(),
|
waveCanvas.rulerHeight + painter.getVerticalOffset() + height * otherTx.getConcurrencyIndex(),
|
||||||
(int) ((otherTx.getEndTime() - otherTx.getBeginTime()) / scaleFactor), laneHeight);
|
(int) ((otherTx.getEndTime() - otherTx.getBeginTime()) / scaleFactor),
|
||||||
|
height);
|
||||||
res.add(new LinkEntry(bb, iTxRelation.getRelationType()));
|
res.add(new LinkEntry(bb, iTxRelation.getRelationType()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,8 +114,9 @@ public class ArrowPainter implements IPainter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintArea(Projection proj, Rectangle clientRect) {
|
public void paintArea(Projection proj, Rectangle clientRect) {
|
||||||
Color fgColor = waveCanvas.colors[WaveformColors.REL_ARROW.ordinal()];
|
yCtrlOffset = waveCanvas.styleProvider.getTrackHeight()/2;
|
||||||
Color highliteColor = waveCanvas.colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()];
|
Color fgColor = waveCanvas.styleProvider.getColor(WaveformColors.REL_ARROW);
|
||||||
|
Color highliteColor = waveCanvas.styleProvider.getColor(WaveformColors.REL_ARROW_HIGHLITE);
|
||||||
|
|
||||||
if(tx==null) return;
|
if(tx==null) return;
|
||||||
if (!deferUpdate) {
|
if (!deferUpdate) {
|
||||||
|
|
|
@ -75,9 +75,9 @@ public class CursorPainter implements IPainter, ICursor {
|
||||||
int x = (int) (time/scaleFactor);
|
int x = (int) (time/scaleFactor);
|
||||||
// distance of marker from the top of Canvas' painting area
|
// distance of marker from the top of Canvas' painting area
|
||||||
int top = id<0?area.y:area.y+15;
|
int top = id<0?area.y:area.y+15;
|
||||||
Color drawColor=waveCanvas.colors[id<0?WaveformColors.CURSOR.ordinal():WaveformColors.MARKER.ordinal()];
|
Color drawColor=waveCanvas.styleProvider.getColor(id<0?WaveformColors.CURSOR:WaveformColors.MARKER);
|
||||||
Color dragColor = waveCanvas.colors[WaveformColors.CURSOR_DRAG.ordinal()];
|
Color dragColor = waveCanvas.styleProvider.getColor(WaveformColors.CURSOR_DRAG);
|
||||||
Color textColor=waveCanvas.colors[id<0?WaveformColors.CURSOR_TEXT.ordinal():WaveformColors.MARKER_TEXT.ordinal()];
|
Color textColor=waveCanvas.styleProvider.getColor(id<0?WaveformColors.CURSOR_TEXT:WaveformColors.MARKER_TEXT);
|
||||||
if(x>=beginPos && x<=maxValX){
|
if(x>=beginPos && x<=maxValX){
|
||||||
proj.setForeground(isDragging?dragColor:drawColor);
|
proj.setForeground(isDragging?dragColor:drawColor);
|
||||||
proj.drawLine(x, top, x, area.y+area.height);
|
proj.drawLine(x, top, x, area.y+area.height);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import com.minres.scviewer.database.DoubleVal;
|
||||||
import com.minres.scviewer.database.IEvent;
|
import com.minres.scviewer.database.IEvent;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
import com.minres.scviewer.database.ui.TrackEntry;
|
import com.minres.scviewer.database.ui.TrackEntry;
|
||||||
|
import com.minres.scviewer.database.ui.TrackEntry.ValueDisplay;
|
||||||
import com.minres.scviewer.database.ui.WaveformColors;
|
import com.minres.scviewer.database.ui.WaveformColors;
|
||||||
|
|
||||||
public class SignalPainter extends TrackPainter {
|
public class SignalPainter extends TrackPainter {
|
||||||
|
@ -88,9 +89,9 @@ public class SignalPainter extends TrackPainter {
|
||||||
public void paintArea(Projection proj, Rectangle area) {
|
public void paintArea(Projection proj, Rectangle area) {
|
||||||
IWaveform signal = trackEntry.waveform;
|
IWaveform signal = trackEntry.waveform;
|
||||||
if (trackEntry.selected)
|
if (trackEntry.selected)
|
||||||
proj.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()]);
|
proj.setBackground(this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_HIGHLITE));
|
||||||
else
|
else
|
||||||
proj.setBackground(this.waveCanvas.colors[even ? WaveformColors.TRACK_BG_EVEN.ordinal() : WaveformColors.TRACK_BG_ODD.ordinal()]);
|
proj.setBackground(this.waveCanvas.styleProvider.getColor(even ? WaveformColors.TRACK_BG_EVEN : WaveformColors.TRACK_BG_ODD));
|
||||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||||
proj.fillRectangle(area);
|
proj.fillRectangle(area);
|
||||||
|
|
||||||
|
@ -108,16 +109,16 @@ public class SignalPainter extends TrackPainter {
|
||||||
} else if (last == null) {
|
} else if (last == null) {
|
||||||
last = signal.getEvents().lastEntry();
|
last = signal.getEvents().lastEntry();
|
||||||
}
|
}
|
||||||
proj.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]);
|
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
|
||||||
proj.setLineStyle(SWT.LINE_SOLID);
|
proj.setLineStyle(SWT.LINE_SOLID);
|
||||||
proj.setLineWidth(1);
|
proj.setLineWidth(1);
|
||||||
NavigableMap<Long, IEvent[]> entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true);
|
NavigableMap<Long, IEvent[]> entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true);
|
||||||
SignalChange left = new SignalChange(first);
|
SignalChange left = new SignalChange(first);
|
||||||
SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first);
|
SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first);
|
||||||
maxPosX = area.x + area.width;
|
maxPosX = area.x + area.width;
|
||||||
yOffsetT = this.waveCanvas.getTrackHeight() / 5 + area.y;
|
yOffsetT = this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||||
yOffsetM = this.waveCanvas.getTrackHeight() / 2 + area.y;
|
yOffsetM = this.waveCanvas.styleProvider.getTrackHeight() / 2 + area.y;
|
||||||
yOffsetB = 4 * this.waveCanvas.getTrackHeight() / 5 + area.y;
|
yOffsetB = 4 * this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||||
int xSigChangeBeginVal = Math.max(area.x, (int) (left.time / this.waveCanvas.getScaleFactor()));
|
int xSigChangeBeginVal = Math.max(area.x, (int) (left.time / this.waveCanvas.getScaleFactor()));
|
||||||
int xSigChangeBeginPos = area.x;
|
int xSigChangeBeginPos = area.x;
|
||||||
int xSigChangeEndPos = Math.max(area.x, getXPosEnd(right.time));
|
int xSigChangeEndPos = Math.max(area.x, getXPosEnd(right.time));
|
||||||
|
@ -195,12 +196,12 @@ public class SignalPainter extends TrackPainter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
||||||
Color colorBorder = waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()];
|
Color colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL0);
|
||||||
BitVector last = (BitVector) left;
|
BitVector last = (BitVector) left;
|
||||||
if (last.getValue().toString().contains("X")) {
|
if (last.getValue().toString().contains("X")) {
|
||||||
colorBorder = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()];
|
colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALX);
|
||||||
} else if (last.getValue().toString().contains("Z")) {
|
} else if (last.getValue().toString().contains("Z")) {
|
||||||
colorBorder = waveCanvas.colors[WaveformColors.SIGNALZ.ordinal()];
|
colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALZ);
|
||||||
}
|
}
|
||||||
int width = xEnd - xBegin;
|
int width = xEnd - xBegin;
|
||||||
if (width > 1) {
|
if (width > 1) {
|
||||||
|
@ -214,7 +215,7 @@ public class SignalPainter extends TrackPainter {
|
||||||
};
|
};
|
||||||
proj.setForeground(colorBorder);
|
proj.setForeground(colorBorder);
|
||||||
proj.drawPolygon(points);
|
proj.drawPolygon(points);
|
||||||
proj.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_TEXT.ordinal()]);
|
proj.setForeground(waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_TEXT));
|
||||||
//TODO: this code should be provided from a central location
|
//TODO: this code should be provided from a central location
|
||||||
String label = null;
|
String label = null;
|
||||||
switch(trackEntry.valueDisplay) {
|
switch(trackEntry.valueDisplay) {
|
||||||
|
@ -249,19 +250,20 @@ public class SignalPainter extends TrackPainter {
|
||||||
private class MultiBitStencilAnalog implements SignalStencil {
|
private class MultiBitStencilAnalog implements SignalStencil {
|
||||||
|
|
||||||
final boolean continous;
|
final boolean continous;
|
||||||
|
final boolean signed;
|
||||||
|
private long maxVal;
|
||||||
private long minVal;
|
private long minVal;
|
||||||
private long range;
|
|
||||||
double yRange = (yOffsetB-yOffsetT);
|
double yRange = (yOffsetB-yOffsetT);
|
||||||
public MultiBitStencilAnalog(NavigableMap<Long, IEvent[]> entries, Object left, boolean continous, boolean signed) {
|
public MultiBitStencilAnalog(NavigableMap<Long, IEvent[]> entries, Object left, boolean continous, boolean signed) {
|
||||||
this.continous=continous;
|
this.continous=continous;
|
||||||
|
this.signed=signed;
|
||||||
Collection<IEvent[]> values = entries.values();
|
Collection<IEvent[]> values = entries.values();
|
||||||
minVal=((BitVector) left).toUnsignedValue();
|
minVal=signed?((BitVector)left).toSignedValue():((BitVector)left).toUnsignedValue();
|
||||||
range=2;
|
|
||||||
if(!values.isEmpty()) {
|
if(!values.isEmpty()) {
|
||||||
long maxVal=minVal;
|
maxVal=minVal;
|
||||||
for (IEvent[] tp : entries.values())
|
for (IEvent[] tp : entries.values())
|
||||||
for(IEvent e: tp) {
|
for(IEvent e: tp) {
|
||||||
long v = ((BitVector)e).toUnsignedValue();
|
long v = signed?((BitVector)e).toSignedValue():((BitVector)e).toUnsignedValue();
|
||||||
maxVal=Math.max(maxVal, v);
|
maxVal=Math.max(maxVal, v);
|
||||||
minVal=Math.min(minVal, v);
|
minVal=Math.min(minVal, v);
|
||||||
}
|
}
|
||||||
|
@ -269,16 +271,18 @@ public class SignalPainter extends TrackPainter {
|
||||||
maxVal--;
|
maxVal--;
|
||||||
minVal++;
|
minVal++;
|
||||||
}
|
}
|
||||||
range = maxVal-minVal;
|
} else {
|
||||||
} else
|
|
||||||
minVal--;
|
minVal--;
|
||||||
|
maxVal=minVal+2;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
||||||
long leftVal = ((BitVector) left).toUnsignedValue();
|
long leftVal = signed?((BitVector)left).toSignedValue():((BitVector)left).toUnsignedValue();
|
||||||
long rightVal= ((BitVector) right).toUnsignedValue();
|
long rightVal= signed?((BitVector)right).toSignedValue():((BitVector)right).toUnsignedValue();
|
||||||
proj.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_REAL.ordinal()]);
|
proj.setForeground(waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_REAL));
|
||||||
|
long range = maxVal-minVal;
|
||||||
int yOffsetLeft = (int) ((leftVal-minVal) * yRange / range);
|
int yOffsetLeft = (int) ((leftVal-minVal) * yRange / range);
|
||||||
int yOffsetRight = (int) ((rightVal-minVal) * yRange / range);
|
int yOffsetRight = (int) ((rightVal-minVal) * yRange / range);
|
||||||
if(continous) {
|
if(continous) {
|
||||||
|
@ -303,24 +307,24 @@ public class SignalPainter extends TrackPainter {
|
||||||
private class SingleBitStencil implements SignalStencil {
|
private class SingleBitStencil implements SignalStencil {
|
||||||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
proj.setForeground(waveCanvas.colors[WaveformColors.SIGNALU.ordinal()]);
|
proj.setForeground(waveCanvas.styleProvider.getColor(WaveformColors.SIGNALU));
|
||||||
proj.drawLine(xBegin, yOffsetT, xBegin, yOffsetB);
|
proj.drawLine(xBegin, yOffsetT, xBegin, yOffsetB);
|
||||||
if(xEnd>xBegin)
|
if(xEnd>xBegin)
|
||||||
proj.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
|
proj.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
|
||||||
} else {
|
} else {
|
||||||
Color color = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()];
|
Color color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALX);
|
||||||
int yOffset = yOffsetM;
|
int yOffset = yOffsetM;
|
||||||
switch (((BitVector) left).getValue()[0]) {
|
switch (((BitVector) left).getValue()[0]) {
|
||||||
case '1':
|
case '1':
|
||||||
color = waveCanvas.colors[WaveformColors.SIGNAL1.ordinal()];
|
color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL1);
|
||||||
yOffset = yOffsetT;
|
yOffset = yOffsetT;
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
color = waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()];
|
color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL0);
|
||||||
yOffset = yOffsetB;
|
yOffset = yOffsetB;
|
||||||
break;
|
break;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
color = waveCanvas.colors[WaveformColors.SIGNALZ.ordinal()];
|
color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALZ);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
@ -385,7 +389,7 @@ public class SignalPainter extends TrackPainter {
|
||||||
double leftVal = ((DoubleVal) left).value;
|
double leftVal = ((DoubleVal) left).value;
|
||||||
double rightVal= ((DoubleVal) right).value;
|
double rightVal= ((DoubleVal) right).value;
|
||||||
if(Double.isNaN(leftVal)) {
|
if(Double.isNaN(leftVal)) {
|
||||||
Color color = waveCanvas.colors[WaveformColors.SIGNAL_NAN.ordinal()];
|
Color color = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_NAN);
|
||||||
int width = xEnd - xBegin;
|
int width = xEnd - xBegin;
|
||||||
if (width > 1) {
|
if (width > 1) {
|
||||||
int[] points = {
|
int[] points = {
|
||||||
|
@ -403,7 +407,7 @@ public class SignalPainter extends TrackPainter {
|
||||||
proj.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
|
proj.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
proj.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_REAL.ordinal()]);
|
proj.setForeground(waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_REAL));
|
||||||
int yOffsetLeft = (int) ((leftVal-minVal) * (yOffsetB-yOffsetT) / range);
|
int yOffsetLeft = (int) ((leftVal-minVal) * (yOffsetB-yOffsetT) / range);
|
||||||
int yOffsetRight = Double.isNaN(rightVal)?yOffsetLeft:(int) ((rightVal-minVal) * (yOffsetB-yOffsetT) / range);
|
int yOffsetRight = Double.isNaN(rightVal)?yOffsetLeft:(int) ((rightVal-minVal) * (yOffsetB-yOffsetT) / range);
|
||||||
if(continous) {
|
if(continous) {
|
||||||
|
|
|
@ -67,10 +67,10 @@ public class StreamPainter extends TrackPainter{
|
||||||
txBase=trackHeight/5;
|
txBase=trackHeight/5;
|
||||||
txHeight=trackHeight*3/5;
|
txHeight=trackHeight*3/5;
|
||||||
if(trackEntry.selected) {
|
if(trackEntry.selected) {
|
||||||
proj.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()]);
|
proj.setBackground(this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_HIGHLITE));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
proj.setBackground(this.waveCanvas.colors[even?WaveformColors.TRACK_BG_EVEN.ordinal():WaveformColors.TRACK_BG_ODD.ordinal()]);
|
proj.setBackground(this.waveCanvas.styleProvider.getColor(even?WaveformColors.TRACK_BG_EVEN:WaveformColors.TRACK_BG_ODD));
|
||||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||||
proj.fillRectangle(area);
|
proj.fillRectangle(area);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class StreamPainter extends TrackPainter{
|
||||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||||
proj.setLineStyle(SWT.LINE_SOLID);
|
proj.setLineStyle(SWT.LINE_SOLID);
|
||||||
proj.setLineWidth(1);
|
proj.setLineWidth(1);
|
||||||
proj.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]);
|
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
|
||||||
|
|
||||||
for( int y1=area.y+trackHeight/2; y1<area.y+trackEntry.height; y1+=trackHeight)
|
for( int y1=area.y+trackHeight/2; y1<area.y+trackEntry.height; y1+=trackHeight)
|
||||||
proj.drawLine(area.x, y1, area.x+area.width, y1);
|
proj.drawLine(area.x, y1, area.x+area.width, y1);
|
||||||
|
@ -98,7 +98,7 @@ public class StreamPainter extends TrackPainter{
|
||||||
seenTx.clear();
|
seenTx.clear();
|
||||||
NavigableMap<Long, IEvent[]> entries = stream.getEvents().subMap(firstTx.getKey(), true, lastTx.getKey(), true);
|
NavigableMap<Long, IEvent[]> entries = stream.getEvents().subMap(firstTx.getKey(), true, lastTx.getKey(), true);
|
||||||
boolean highlighed=false;
|
boolean highlighed=false;
|
||||||
proj.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]);
|
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
|
||||||
|
|
||||||
for(Entry<Long, IEvent[]> entry: entries.entrySet())
|
for(Entry<Long, IEvent[]> entry: entries.entrySet())
|
||||||
for(IEvent evt:entry.getValue()){
|
for(IEvent evt:entry.getValue()){
|
||||||
|
@ -116,7 +116,7 @@ public class StreamPainter extends TrackPainter{
|
||||||
drawTx(proj, area, tx, false);
|
drawTx(proj, area, tx, false);
|
||||||
}
|
}
|
||||||
if(highlighed){
|
if(highlighed){
|
||||||
proj.setForeground(this.waveCanvas.colors[WaveformColors.LINE_HIGHLITE.ordinal()]);
|
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE_HIGHLITE));
|
||||||
drawTx(proj, area, waveCanvas.currentSelection, true);
|
drawTx(proj, area, waveCanvas.currentSelection, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public class StreamPainter extends TrackPainter{
|
||||||
|
|
||||||
proj.setBackground( toSwtColor( proj.getGC(), transColor[highlighted?1:0] ) );
|
proj.setBackground( toSwtColor( proj.getGC(), transColor[highlighted?1:0] ) );
|
||||||
|
|
||||||
int offset = tx.getConcurrencyIndex()*this.waveCanvas.getTrackHeight();
|
int offset = tx.getConcurrencyIndex()*this.waveCanvas.styleProvider.getTrackHeight();
|
||||||
Rectangle bb = new Rectangle(
|
Rectangle bb = new Rectangle(
|
||||||
(int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()), area.y+offset+txBase,
|
(int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()), area.y+offset+txBase,
|
||||||
(int)((tx.getEndTime()-tx.getBeginTime())/this.waveCanvas.getScaleFactor()), txHeight);
|
(int)((tx.getEndTime()-tx.getBeginTime())/this.waveCanvas.getScaleFactor()), txHeight);
|
||||||
|
@ -155,7 +155,7 @@ public class StreamPainter extends TrackPainter{
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITx getClicked(Point point) {
|
public ITx getClicked(Point point) {
|
||||||
int lane=point.y/waveCanvas.getTrackHeight();
|
int lane=point.y/waveCanvas.styleProvider.getTrackHeight();
|
||||||
Entry<Long, IEvent[]> firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
|
Entry<Long, IEvent[]> firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
|
||||||
if(firstTx!=null){
|
if(firstTx!=null){
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class TrackAreaPainter implements IPainter {
|
||||||
|
|
||||||
public void paintArea(Projection proj, Rectangle a) {
|
public void paintArea(Projection proj, Rectangle a) {
|
||||||
Rectangle area = proj.unProject(new Rectangle(a.x, a.y+waveCanvas.rulerHeight, a.width, a.height-waveCanvas.rulerHeight));
|
Rectangle area = proj.unProject(new Rectangle(a.x, a.y+waveCanvas.rulerHeight, a.width, a.height-waveCanvas.rulerHeight));
|
||||||
proj.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_EVEN.ordinal()]);
|
proj.setBackground(this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_EVEN));
|
||||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||||
proj.fillRectangle(area);
|
proj.fillRectangle(area);
|
||||||
if(trackVerticalOffset.size()>0){
|
if(trackVerticalOffset.size()>0){
|
||||||
|
|
|
@ -23,35 +23,29 @@ import org.eclipse.swt.events.PaintEvent;
|
||||||
import org.eclipse.swt.events.PaintListener;
|
import org.eclipse.swt.events.PaintListener;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.widgets.Canvas;
|
import org.eclipse.swt.widgets.Canvas;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
import org.eclipse.swt.widgets.Event;
|
||||||
import org.eclipse.swt.widgets.ScrollBar;
|
import org.eclipse.swt.widgets.ScrollBar;
|
||||||
import org.eclipse.wb.swt.SWTResourceManager;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
import com.minres.scviewer.database.RelationType;
|
import com.minres.scviewer.database.RelationType;
|
||||||
import com.minres.scviewer.database.tx.ITx;
|
import com.minres.scviewer.database.tx.ITx;
|
||||||
|
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||||
import com.minres.scviewer.database.ui.IWaveformView;
|
import com.minres.scviewer.database.ui.IWaveformView;
|
||||||
import com.minres.scviewer.database.ui.TrackEntry;
|
import com.minres.scviewer.database.ui.TrackEntry;
|
||||||
import com.minres.scviewer.database.ui.WaveformColors;
|
|
||||||
import com.minres.scviewer.database.ui.swt.Constants;
|
import com.minres.scviewer.database.ui.swt.Constants;
|
||||||
|
|
||||||
public class WaveformCanvas extends Canvas {
|
public class WaveformCanvas extends Canvas {
|
||||||
|
|
||||||
Color[] colors = new Color[WaveformColors.values().length];
|
|
||||||
|
|
||||||
private boolean doubleBuffering = true;
|
private boolean doubleBuffering = true;
|
||||||
|
|
||||||
private int trackHeight = 50;
|
IWaveformStyleProvider styleProvider;
|
||||||
|
|
||||||
private long scaleFactor = 1000000L; // 1ns
|
private long scaleFactor = 1000000L; // 1ns
|
||||||
|
|
||||||
|
@ -88,8 +82,9 @@ public class WaveformCanvas extends Canvas {
|
||||||
* @param style
|
* @param style
|
||||||
* the style of this control.
|
* the style of this control.
|
||||||
*/
|
*/
|
||||||
public WaveformCanvas(final Composite parent, int style) {
|
public WaveformCanvas(final Composite parent, int style, IWaveformStyleProvider styleProvider) {
|
||||||
super(parent, style | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL);
|
super(parent, style | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||||
|
this.styleProvider=styleProvider;
|
||||||
addControlListener(new ControlAdapter() { /* resize listener. */
|
addControlListener(new ControlAdapter() { /* resize listener. */
|
||||||
public void controlResized(ControlEvent event) {
|
public void controlResized(ControlEvent event) {
|
||||||
syncScrollBars();
|
syncScrollBars();
|
||||||
|
@ -107,7 +102,6 @@ public class WaveformCanvas extends Canvas {
|
||||||
wave2painterMap=new HashMap<>();
|
wave2painterMap=new HashMap<>();
|
||||||
|
|
||||||
initScrollBars();
|
initScrollBars();
|
||||||
initColors(null);
|
|
||||||
// order is important: it is bottom to top
|
// order is important: it is bottom to top
|
||||||
trackAreaPainter=new TrackAreaPainter(this);
|
trackAreaPainter=new TrackAreaPainter(this);
|
||||||
painterList.add(trackAreaPainter);
|
painterList.add(trackAreaPainter);
|
||||||
|
@ -122,31 +116,6 @@ public class WaveformCanvas extends Canvas {
|
||||||
painterList.add(marker);
|
painterList.add(marker);
|
||||||
cursorPainters.add(marker);
|
cursorPainters.add(marker);
|
||||||
wave2painterMap=new HashMap<>();
|
wave2painterMap=new HashMap<>();
|
||||||
// fall back initialization
|
|
||||||
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
|
||||||
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
|
||||||
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
|
||||||
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
|
|
||||||
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
|
|
||||||
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
|
||||||
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
|
||||||
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
|
||||||
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
|
||||||
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
|
||||||
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.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
|
||||||
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
|
||||||
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
|
||||||
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
|
||||||
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
|
||||||
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
|
|
||||||
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
|
||||||
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
|
|
||||||
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCursoPainter(CursorPainter cursorPainter){
|
public void addCursoPainter(CursorPainter cursorPainter){
|
||||||
|
@ -154,17 +123,6 @@ public class WaveformCanvas extends Canvas {
|
||||||
cursorPainters.add(cursorPainter);
|
cursorPainters.add(cursorPainter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initColors(HashMap<WaveformColors, RGB> colourMap) {
|
|
||||||
Display d = getDisplay();
|
|
||||||
if (colourMap != null) {
|
|
||||||
for (WaveformColors c : WaveformColors.values()) {
|
|
||||||
if (colourMap.containsKey(c))
|
|
||||||
colors[c.ordinal()] = new Color(d, colourMap.get(c));
|
|
||||||
}
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHighliteRelation(RelationType relationType){
|
public void setHighliteRelation(RelationType relationType){
|
||||||
if(arrowPainter!=null){
|
if(arrowPainter!=null){
|
||||||
boolean redraw = arrowPainter.getHighlightType()!=relationType;
|
boolean redraw = arrowPainter.getHighlightType()!=relationType;
|
||||||
|
@ -206,15 +164,6 @@ public class WaveformCanvas extends Canvas {
|
||||||
syncScrollBars();
|
syncScrollBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTrackHeight() {
|
|
||||||
return trackHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTrackHeight(int trackHeight) {
|
|
||||||
this.trackHeight = trackHeight;
|
|
||||||
syncScrollBars();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getZoomLevel() {
|
public int getZoomLevel() {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
@ -315,15 +264,6 @@ public class WaveformCanvas extends Canvas {
|
||||||
return cursorPainters;
|
return cursorPainters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Dispose the garbage here
|
|
||||||
*/
|
|
||||||
public void dispose() {
|
|
||||||
for (WaveformColors c : WaveformColors.values())
|
|
||||||
colors[c.ordinal()].dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize the scrollbar and register listeners. */
|
/* Initialize the scrollbar and register listeners. */
|
||||||
private void initScrollBars() {
|
private void initScrollBars() {
|
||||||
ScrollBar horizontal = getHorizontalBar();
|
ScrollBar horizontal = getHorizontalBar();
|
||||||
|
@ -459,7 +399,7 @@ public class WaveformCanvas extends Canvas {
|
||||||
int x = i - origin.x;
|
int x = i - origin.x;
|
||||||
for(IPainter p: wave2painterMap.values()){
|
for(IPainter p: wave2painterMap.values()){
|
||||||
if (p instanceof StreamPainter && ((StreamPainter)p).getStream()==iWaveform) {
|
if (p instanceof StreamPainter && ((StreamPainter)p).getStream()==iWaveform) {
|
||||||
result.add(((StreamPainter) p).getClicked(new Point(x, trackHeight/2)));
|
result.add(((StreamPainter) p).getClicked(new Point(x, styleProvider.getTrackHeight()/2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -486,10 +426,10 @@ public class WaveformCanvas extends Canvas {
|
||||||
}
|
}
|
||||||
for (IWaveformPainter painter : wave2painterMap.values()) {
|
for (IWaveformPainter painter : wave2painterMap.values()) {
|
||||||
if (painter instanceof StreamPainter && ((StreamPainter) painter).getStream() == tx.getStream()) {
|
if (painter instanceof StreamPainter && ((StreamPainter) painter).getStream() == tx.getStream()) {
|
||||||
int top = painter.getVerticalOffset() + trackHeight * tx.getConcurrencyIndex();
|
int top = painter.getVerticalOffset() + styleProvider.getTrackHeight() * tx.getConcurrencyIndex();
|
||||||
int bottom = top + trackHeight;
|
int bottom = top + styleProvider.getTrackHeight();
|
||||||
if (top < -origin.y) {
|
if (top < -origin.y) {
|
||||||
setOrigin(origin.x, -(top-trackHeight));
|
setOrigin(origin.x, -(top-styleProvider.getTrackHeight()));
|
||||||
} else if (bottom > (size.y - origin.y)) {
|
} else if (bottom > (size.y - origin.y)) {
|
||||||
setOrigin(origin.x, size.y - bottom);
|
setOrigin(origin.x, size.y - bottom);
|
||||||
}
|
}
|
||||||
|
@ -508,9 +448,9 @@ public class WaveformCanvas extends Canvas {
|
||||||
if((sb.getStyle()&SWT.SCROLLBAR_OVERLAY)!=0 && sb.isVisible()) // TODO: check on other platform than MacOSX
|
if((sb.getStyle()&SWT.SCROLLBAR_OVERLAY)!=0 && sb.isVisible()) // TODO: check on other platform than MacOSX
|
||||||
size.y-= getHorizontalBar().getSize().y;
|
size.y-= getHorizontalBar().getSize().y;
|
||||||
int top = te.vOffset;
|
int top = te.vOffset;
|
||||||
int bottom = top + trackHeight;
|
int bottom = top + styleProvider.getTrackHeight();
|
||||||
if (top < -origin.y) {
|
if (top < -origin.y) {
|
||||||
setOrigin(origin.x, -(top-trackHeight));
|
setOrigin(origin.x, -(top-styleProvider.getTrackHeight()));
|
||||||
} else if (bottom > (size.y - origin.y)) {
|
} else if (bottom > (size.y - origin.y)) {
|
||||||
setOrigin(origin.x, size.y - bottom);
|
setOrigin(origin.x, size.y - bottom);
|
||||||
}
|
}
|
||||||
|
@ -569,4 +509,9 @@ public class WaveformCanvas extends Canvas {
|
||||||
long getMinVisibleTime() {
|
long getMinVisibleTime() {
|
||||||
return origin.x * scaleFactor;
|
return origin.x * scaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStyleProvider(IWaveformStyleProvider styleProvider) {
|
||||||
|
this.styleProvider=styleProvider;
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
@ -57,10 +56,8 @@ import org.eclipse.swt.events.PaintEvent;
|
||||||
import org.eclipse.swt.events.PaintListener;
|
import org.eclipse.swt.events.PaintListener;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.graphics.Font;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.graphics.TextLayout;
|
import org.eclipse.swt.graphics.TextLayout;
|
||||||
import org.eclipse.swt.layout.FillLayout;
|
import org.eclipse.swt.layout.FillLayout;
|
||||||
|
@ -90,9 +87,9 @@ import com.minres.scviewer.database.tx.ITxEvent;
|
||||||
import com.minres.scviewer.database.tx.ITxRelation;
|
import com.minres.scviewer.database.tx.ITxRelation;
|
||||||
import com.minres.scviewer.database.ui.GotoDirection;
|
import com.minres.scviewer.database.ui.GotoDirection;
|
||||||
import com.minres.scviewer.database.ui.ICursor;
|
import com.minres.scviewer.database.ui.ICursor;
|
||||||
|
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||||
import com.minres.scviewer.database.ui.IWaveformView;
|
import com.minres.scviewer.database.ui.IWaveformView;
|
||||||
import com.minres.scviewer.database.ui.TrackEntry;
|
import com.minres.scviewer.database.ui.TrackEntry;
|
||||||
import com.minres.scviewer.database.ui.WaveformColors;
|
|
||||||
import com.minres.scviewer.database.ui.swt.Constants;
|
import com.minres.scviewer.database.ui.swt.Constants;
|
||||||
|
|
||||||
public class WaveformView implements IWaveformView {
|
public class WaveformView implements IWaveformView {
|
||||||
|
@ -129,11 +126,11 @@ public class WaveformView implements IWaveformView {
|
||||||
|
|
||||||
int selectedMarker = 0;
|
int selectedMarker = 0;
|
||||||
|
|
||||||
private int trackVerticalHeight;
|
private int tracksVerticalHeight;
|
||||||
|
|
||||||
private TreeMap<Integer, TrackEntry> trackVerticalOffset;
|
private TreeMap<Integer, TrackEntry> trackVerticalOffset;
|
||||||
|
|
||||||
private Font nameFont, nameFontB;
|
private IWaveformStyleProvider styleProvider;
|
||||||
|
|
||||||
protected TrackEntry lastClickedEntry;
|
protected TrackEntry lastClickedEntry;
|
||||||
|
|
||||||
|
@ -315,14 +312,13 @@ public class WaveformView implements IWaveformView {
|
||||||
};
|
};
|
||||||
protected WaveformMouseListener waveformMouseListener = new WaveformMouseListener();
|
protected WaveformMouseListener waveformMouseListener = new WaveformMouseListener();
|
||||||
|
|
||||||
public WaveformView(Composite parent) {
|
public WaveformView(Composite parent, IWaveformStyleProvider styleProvider) {
|
||||||
|
this.styleProvider=styleProvider;
|
||||||
|
|
||||||
pcs=new PropertyChangeSupport(this);
|
pcs=new PropertyChangeSupport(this);
|
||||||
|
|
||||||
trackVerticalOffset = new TreeMap<Integer, TrackEntry>();
|
trackVerticalOffset = new TreeMap<Integer, TrackEntry>();
|
||||||
trackVerticalHeight=0;
|
tracksVerticalHeight=0;
|
||||||
|
|
||||||
nameFont = parent.getDisplay().getSystemFont();
|
|
||||||
nameFontB = SWTResourceManager.getBoldFont(nameFont);
|
|
||||||
|
|
||||||
streams = new ObservableList<>();
|
streams = new ObservableList<>();
|
||||||
streams.addPropertyChangeListener("content", this);
|
streams.addPropertyChangeListener("content", this);
|
||||||
|
@ -341,7 +337,7 @@ public class WaveformView implements IWaveformView {
|
||||||
rightSash.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
|
rightSash.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
|
||||||
|
|
||||||
Composite valuePane = new Composite(rightSash, SWT.NONE);
|
Composite valuePane = new Composite(rightSash, SWT.NONE);
|
||||||
waveformCanvas = new WaveformCanvas(rightSash, SWT.NONE);
|
waveformCanvas = new WaveformCanvas(rightSash, SWT.NONE, styleProvider);
|
||||||
|
|
||||||
// create the name pane
|
// create the name pane
|
||||||
createTextPane(namePane, "Name");
|
createTextPane(namePane, "Name");
|
||||||
|
@ -508,17 +504,17 @@ public class WaveformView implements IWaveformView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
trackVerticalHeight = 0;
|
tracksVerticalHeight = 0;
|
||||||
int nameMaxWidth = 0;
|
int nameMaxWidth = 0;
|
||||||
IWaveformPainter painter = null;
|
IWaveformPainter painter = null;
|
||||||
trackVerticalOffset.clear();
|
trackVerticalOffset.clear();
|
||||||
waveformCanvas.clearAllWaveformPainter(false);
|
waveformCanvas.clearAllWaveformPainter(false);
|
||||||
boolean even = true;
|
boolean even = true;
|
||||||
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
||||||
tl.setFont(nameFontB);
|
tl.setFont(styleProvider.getNameFont());
|
||||||
for (TrackEntry streamEntry : streams) {
|
for (TrackEntry streamEntry : streams) {
|
||||||
streamEntry.height = waveformCanvas.getTrackHeight();
|
streamEntry.height = styleProvider.getTrackHeight();
|
||||||
streamEntry.vOffset=trackVerticalHeight;
|
streamEntry.vOffset=tracksVerticalHeight;
|
||||||
if (streamEntry.waveform.getType()==WaveformType.TRANSACTION) {
|
if (streamEntry.waveform.getType()==WaveformType.TRANSACTION) {
|
||||||
streamEntry.currentValue="";
|
streamEntry.currentValue="";
|
||||||
streamEntry.height *= streamEntry.waveform.getWidth();
|
streamEntry.height *= streamEntry.waveform.getWidth();
|
||||||
|
@ -528,15 +524,15 @@ public class WaveformView implements IWaveformView {
|
||||||
painter = new SignalPainter(waveformCanvas, even, streamEntry);
|
painter = new SignalPainter(waveformCanvas, even, streamEntry);
|
||||||
}
|
}
|
||||||
waveformCanvas.addWaveformPainter(painter, false);
|
waveformCanvas.addWaveformPainter(painter, false);
|
||||||
trackVerticalOffset.put(trackVerticalHeight, streamEntry);
|
trackVerticalOffset.put(tracksVerticalHeight, streamEntry);
|
||||||
tl.setText(streamEntry.waveform.getFullName());
|
tl.setText(streamEntry.waveform.getFullName());
|
||||||
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width);
|
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width);
|
||||||
trackVerticalHeight += streamEntry.height;
|
tracksVerticalHeight += streamEntry.height;
|
||||||
even = !even;
|
even = !even;
|
||||||
}
|
}
|
||||||
waveformCanvas.syncScrollBars();
|
waveformCanvas.syncScrollBars();
|
||||||
nameList.setSize(nameMaxWidth + 15, trackVerticalHeight);
|
nameList.setSize(nameMaxWidth + 15, tracksVerticalHeight);
|
||||||
nameListScrolled.setMinSize(nameMaxWidth + 15, trackVerticalHeight);
|
nameListScrolled.setMinSize(nameMaxWidth + 15, tracksVerticalHeight);
|
||||||
nameList.redraw();
|
nameList.redraw();
|
||||||
updateValueList();
|
updateValueList();
|
||||||
waveformCanvas.redraw();
|
waveformCanvas.redraw();
|
||||||
|
@ -548,7 +544,7 @@ public class WaveformView implements IWaveformView {
|
||||||
|
|
||||||
private int calculateValueWidth() {
|
private int calculateValueWidth() {
|
||||||
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
||||||
tl.setFont(nameFontB);
|
tl.setFont(styleProvider.getNameFontHighlite());
|
||||||
int valueMaxWidth = 0;
|
int valueMaxWidth = 0;
|
||||||
for (TrackEntry v : streams) {
|
for (TrackEntry v : streams) {
|
||||||
tl.setText(v.currentValue);
|
tl.setText(v.currentValue);
|
||||||
|
@ -615,8 +611,8 @@ public class WaveformView implements IWaveformView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int width = calculateValueWidth();
|
int width = calculateValueWidth();
|
||||||
valueList.setSize(width, trackVerticalHeight);
|
valueList.setSize(width, tracksVerticalHeight);
|
||||||
valueListScrolled.setMinSize(width, trackVerticalHeight);
|
valueListScrolled.setMinSize(width, tracksVerticalHeight);
|
||||||
valueListScrolled.redraw();
|
valueListScrolled.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,9 +730,6 @@ public class WaveformView implements IWaveformView {
|
||||||
streams.add(trackEntry);
|
streams.add(trackEntry);
|
||||||
}
|
}
|
||||||
currentTxSelection = txSel;
|
currentTxSelection = txSel;
|
||||||
// if(trackEntry!=null) {
|
|
||||||
// currentWaveformSelection.add((TrackEntry)sel);
|
|
||||||
// }
|
|
||||||
selectionChanged = true;
|
selectionChanged = true;
|
||||||
} else if (sel instanceof TrackEntry && !currentWaveformSelection.contains(sel)) {
|
} else if (sel instanceof TrackEntry && !currentWaveformSelection.contains(sel)) {
|
||||||
currentWaveformSelection.add((TrackEntry)sel);
|
currentWaveformSelection.add((TrackEntry)sel);
|
||||||
|
@ -973,7 +966,7 @@ public class WaveformView implements IWaveformView {
|
||||||
if (firstKey == null)
|
if (firstKey == null)
|
||||||
firstKey = trackVerticalOffset.firstKey();
|
firstKey = trackVerticalOffset.firstKey();
|
||||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight());
|
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, styleProvider.getTrackHeight());
|
||||||
if (lastKey == firstKey) {
|
if (lastKey == firstKey) {
|
||||||
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
||||||
IWaveform w = trackEntry.waveform;
|
IWaveform w = trackEntry.waveform;
|
||||||
|
@ -983,7 +976,7 @@ public class WaveformView implements IWaveformView {
|
||||||
} else {
|
} else {
|
||||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()) {
|
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()) {
|
||||||
IWaveform w = entry.getValue().waveform;
|
IWaveform w = entry.getValue().waveform;
|
||||||
subArea.height = waveformCanvas.getTrackHeight();
|
subArea.height = styleProvider.getTrackHeight();
|
||||||
if (w.getType()==WaveformType.TRANSACTION)
|
if (w.getType()==WaveformType.TRANSACTION)
|
||||||
subArea.height *= w.getWidth();
|
subArea.height *= w.getWidth();
|
||||||
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected);
|
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected);
|
||||||
|
@ -1000,7 +993,7 @@ public class WaveformView implements IWaveformView {
|
||||||
if (firstKey == null)
|
if (firstKey == null)
|
||||||
firstKey = trackVerticalOffset.firstKey();
|
firstKey = trackVerticalOffset.firstKey();
|
||||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight());
|
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, styleProvider.getTrackHeight());
|
||||||
if (lastKey == firstKey) {
|
if (lastKey == firstKey) {
|
||||||
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
||||||
IWaveform w = trackEntry.waveform;
|
IWaveform w = trackEntry.waveform;
|
||||||
|
@ -1011,7 +1004,7 @@ public class WaveformView implements IWaveformView {
|
||||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
||||||
.entrySet()) {
|
.entrySet()) {
|
||||||
IWaveform w = entry.getValue().waveform;
|
IWaveform w = entry.getValue().waveform;
|
||||||
subArea.height = waveformCanvas.getTrackHeight();
|
subArea.height = styleProvider.getTrackHeight();
|
||||||
if (w.getType()==WaveformType.TRANSACTION)
|
if (w.getType()==WaveformType.TRANSACTION)
|
||||||
subArea.height *= w.getWidth();
|
subArea.height *= w.getWidth();
|
||||||
drawValue(gc, subArea, entry.getKey(), entry.getValue().currentValue, entry.getValue().selected);
|
drawValue(gc, subArea, entry.getKey(), entry.getValue().currentValue, entry.getValue().selected);
|
||||||
|
@ -1023,10 +1016,10 @@ public class WaveformView implements IWaveformView {
|
||||||
|
|
||||||
protected void drawValue(GC gc, Rectangle subArea, Integer yOffset, String value, boolean highlite) {
|
protected void drawValue(GC gc, Rectangle subArea, Integer yOffset, String value, boolean highlite) {
|
||||||
int beginIndex=0;
|
int beginIndex=0;
|
||||||
for(int offset=0; offset<subArea.height; offset+=waveformCanvas.getTrackHeight()){
|
for(int offset=0; offset<subArea.height; offset+=styleProvider.getTrackHeight()){
|
||||||
int endIndex=value.indexOf('|', beginIndex);
|
int endIndex=value.indexOf('|', beginIndex);
|
||||||
String str = endIndex<0?value.substring(beginIndex):value.substring(beginIndex, endIndex);
|
String str = endIndex<0?value.substring(beginIndex):value.substring(beginIndex, endIndex);
|
||||||
drawTextFormat(gc, new Rectangle(subArea.x, subArea.y, subArea.width, waveformCanvas.getTrackHeight()), yOffset+offset, str, highlite);
|
drawTextFormat(gc, new Rectangle(subArea.x, subArea.y, subArea.width, styleProvider.getTrackHeight()), yOffset+offset, str, highlite);
|
||||||
beginIndex=endIndex<0?beginIndex:endIndex+1;
|
beginIndex=endIndex<0?beginIndex:endIndex+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1037,13 +1030,13 @@ public class WaveformView implements IWaveformView {
|
||||||
gc.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));
|
gc.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));
|
||||||
gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT));
|
gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT));
|
||||||
gc.fillRectangle(subArea.x, subArea.y + yOffset, subArea.width, subArea.height);
|
gc.fillRectangle(subArea.x, subArea.y + yOffset, subArea.width, subArea.height);
|
||||||
gc.setFont(nameFontB);
|
gc.setFont(styleProvider.getNameFontHighlite());
|
||||||
} else {
|
} else {
|
||||||
gc.setBackground(namePaneHeader.getBackground());
|
gc.setBackground(namePaneHeader.getBackground());
|
||||||
gc.setForeground(namePaneHeader.getForeground());
|
gc.setForeground(namePaneHeader.getForeground());
|
||||||
gc.setFont(nameFont);
|
gc.setFont(styleProvider.getNameFont());
|
||||||
}
|
}
|
||||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (waveformCanvas.getTrackHeight() - size.y) / 2, true);
|
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (styleProvider.getTrackHeight() - size.y) / 2, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1143,7 +1136,7 @@ public class WaveformView implements IWaveformView {
|
||||||
dragSource.setTransfer(types);
|
dragSource.setTransfer(types);
|
||||||
dragSource.addDragListener(new DragSourceAdapter() {
|
dragSource.addDragListener(new DragSourceAdapter() {
|
||||||
public void dragStart(DragSourceEvent event) {
|
public void dragStart(DragSourceEvent event) {
|
||||||
if (event.y < trackVerticalHeight) {
|
if (event.y < tracksVerticalHeight) {
|
||||||
event.doit = true;
|
event.doit = true;
|
||||||
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(currentWaveformSelection));
|
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(currentWaveformSelection));
|
||||||
}
|
}
|
||||||
|
@ -1248,7 +1241,7 @@ public class WaveformView implements IWaveformView {
|
||||||
|
|
||||||
public void dropAccept(DropTargetEvent event) {
|
public void dropAccept(DropTargetEvent event) {
|
||||||
Point offset = canvas.toControl(event.x, event.y);
|
Point offset = canvas.toControl(event.x, event.y);
|
||||||
if (event.detail != DND.DROP_MOVE || offset.y > trackVerticalOffset.lastKey() + waveformCanvas.getTrackHeight()) {
|
if (event.detail != DND.DROP_MOVE || offset.y > trackVerticalOffset.lastKey() + styleProvider.getTrackHeight()) {
|
||||||
event.detail = DND.DROP_NONE;
|
event.detail = DND.DROP_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1356,11 +1349,6 @@ public class WaveformView implements IWaveformView {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setColors(HashMap<WaveformColors, RGB> colourMap) {
|
|
||||||
waveformCanvas.initColors(colourMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getBaselineTime() {
|
public long getBaselineTime() {
|
||||||
return -waveformCanvas.getScaleFactorPow10()*waveformCanvas.getOrigin().x;
|
return -waveformCanvas.getScaleFactorPow10()*waveformCanvas.getOrigin().x;
|
||||||
|
@ -1394,8 +1382,16 @@ public class WaveformView implements IWaveformView {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// probably not the way it should be done
|
/// probably not the way it should be done
|
||||||
public void addDisposeListener( DisposeListener listener ) {
|
@Override
|
||||||
|
public void addDisposeListener(DisposeListener listener ) {
|
||||||
waveformCanvas.addDisposeListener(listener);
|
waveformCanvas.addDisposeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStyleProvider(IWaveformStyleProvider styleProvider) {
|
||||||
|
this.styleProvider=styleProvider;
|
||||||
|
waveformCanvas.setStyleProvider(styleProvider);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,18 +152,8 @@ public class BitVector implements IEvent {
|
||||||
currentWord >>= 2;
|
currentWord >>= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i=width; i<64; i++) {
|
if(lastVal!=0)
|
||||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
res |= -1l<<width;
|
||||||
res|=lastVal<<i;
|
|
||||||
bitOffset += 2;
|
|
||||||
if (bitOffset == 32) {
|
|
||||||
wordOffset++;
|
|
||||||
bitOffset = 0;
|
|
||||||
} else {
|
|
||||||
currentWord >>= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class HierNode implements IHierNode {
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
protected String parentName;
|
protected IHierNode parent = null;
|
||||||
|
|
||||||
protected ArrayList<IHierNode> childs;
|
protected ArrayList<IHierNode> childs;
|
||||||
|
|
||||||
|
@ -31,13 +31,14 @@ public class HierNode implements IHierNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public HierNode(String name) {
|
public HierNode(String name) {
|
||||||
this(name, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public HierNode(String name, String parentName) {
|
|
||||||
this();
|
this();
|
||||||
this.name=name;
|
this.name=name;
|
||||||
this.parentName=parentName;
|
}
|
||||||
|
|
||||||
|
public HierNode(String name, IHierNode parent) {
|
||||||
|
this();
|
||||||
|
this.name=name;
|
||||||
|
this.parent=parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,8 +54,8 @@ public class HierNode implements IHierNode {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFullName() {
|
public String getFullName() {
|
||||||
if(parentName!=null && parentName.length()>0)
|
if(parent!=null)
|
||||||
return parentName+"."+name;
|
return parent.getFullName()+"."+name;
|
||||||
else
|
else
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -70,8 +71,8 @@ public class HierNode implements IHierNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentName(String name) {
|
public void setParent(IHierNode parent) {
|
||||||
this.parentName=name;
|
this.parent=parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,7 +82,7 @@ public class HierNode implements IHierNode {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(IHierNode o) {
|
public int compareTo(IHierNode o) {
|
||||||
return name.compareTo(o.getName());
|
return getFullName().compareTo(o.getFullName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public interface IHierNode extends Comparable<IHierNode>{
|
||||||
|
|
||||||
public void setName(String name);
|
public void setName(String name);
|
||||||
|
|
||||||
public void setParentName(String name);
|
public void setParent(IHierNode parent);
|
||||||
|
|
||||||
public List<IHierNode> getChildNodes();
|
public List<IHierNode> getChildNodes();
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,9 @@ package com.minres.scviewer.database.internal;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -34,8 +33,6 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||||
|
|
||||||
private boolean loaded;
|
private boolean loaded;
|
||||||
|
|
||||||
private List<IHierNode> childNodes;
|
|
||||||
|
|
||||||
private List<RelationType> relationTypes;
|
private List<RelationType> relationTypes;
|
||||||
|
|
||||||
private Map<String, IWaveform> waveforms;
|
private Map<String, IWaveform> waveforms;
|
||||||
|
@ -93,7 +90,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||||
buildHierarchyNodes() ;
|
buildHierarchyNodes() ;
|
||||||
relationTypes.addAll(loader.getAllRelationTypes());
|
relationTypes.addAll(loader.getAllRelationTypes());
|
||||||
pcs.firePropertyChange("WAVEFORMS", null, waveforms);
|
pcs.firePropertyChange("WAVEFORMS", null, waveforms);
|
||||||
pcs.firePropertyChange("CHILDS", null, childNodes);
|
pcs.firePropertyChange("CHILDS", null, childs);
|
||||||
loaded = true;
|
loaded = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +113,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
waveforms.clear();
|
waveforms.clear();
|
||||||
childNodes.clear();
|
childs.clear();
|
||||||
loaded=false;
|
loaded=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,61 +122,46 @@ public class WaveformDb extends HierNode implements IWaveformDb {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildHierarchyNodes() throws InputFormatException{
|
private void buildHierarchyNodes() throws InputFormatException{
|
||||||
childNodes= new ArrayList<IHierNode>();
|
|
||||||
for(IWaveform stream:getAllWaves()){
|
for(IWaveform stream:getAllWaves()){
|
||||||
//updateMaxTime(stream);
|
//updateMaxTime(stream);
|
||||||
String[] hier = stream.getName().split("\\.");
|
String[] hier = stream.getName().split("\\.");
|
||||||
IHierNode node = this;
|
IHierNode node = this;
|
||||||
List<String> path=new LinkedList<String>();
|
for(int i=0; i<hier.length-1; ++i){
|
||||||
path.add(name);
|
String name = hier[i];
|
||||||
for(String name:hier){
|
IHierNode childNode = null;
|
||||||
IHierNode n1 = null;
|
|
||||||
for (IHierNode n : node.getChildNodes()) {
|
for (IHierNode n : node.getChildNodes()) {
|
||||||
if (n.getName().equals(name)) {
|
if (n.getName().equals(name)) {
|
||||||
n1=n;
|
childNode=n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(name.equals(hier[hier.length-1])){ //leaf
|
if(childNode != null) {
|
||||||
if(n1!=null) {
|
node = childNode;
|
||||||
if(n1 instanceof HierNode){
|
break;
|
||||||
node.getChildNodes().remove(n1);
|
|
||||||
stream.getChildNodes().addAll(n1.getChildNodes());
|
|
||||||
Collections.sort(stream.getChildNodes());
|
|
||||||
} else {
|
|
||||||
throw new InputFormatException();
|
|
||||||
}
|
}
|
||||||
}
|
HierNode newNode = new HierNode(name, node);
|
||||||
stream.setName(name);
|
|
||||||
stream.setParentName(join(path, "."));
|
|
||||||
node.getChildNodes().add(stream);
|
|
||||||
Collections.sort(node.getChildNodes());
|
|
||||||
node=stream;
|
|
||||||
} else { // intermediate
|
|
||||||
if(n1 != null) {
|
|
||||||
node=n1;
|
|
||||||
} else {
|
|
||||||
HierNode newNode = new HierNode(name, join(path, "."));
|
|
||||||
node.getChildNodes().add(newNode);
|
node.getChildNodes().add(newNode);
|
||||||
Collections.sort(node.getChildNodes());
|
|
||||||
node=newNode;
|
node=newNode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
node.getChildNodes().add(stream);
|
||||||
|
stream.setParent(node);
|
||||||
|
stream.setName(hier[hier.length-1]);
|
||||||
}
|
}
|
||||||
path.add(name);
|
sortRecursive(this);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String join(Collection<?> col, String delim) {
|
private void sortRecursive(IHierNode node) {
|
||||||
StringBuilder sb = new StringBuilder();
|
Collections.sort(node.getChildNodes(), new Comparator<IHierNode>() {
|
||||||
Iterator<?> iter = col.iterator();
|
@Override
|
||||||
if (iter.hasNext())
|
public int compare(IHierNode o1, IHierNode o2) {
|
||||||
sb.append(iter.next().toString());
|
return o1.getName().compareTo(o2.getName()); }
|
||||||
while (iter.hasNext()) {
|
|
||||||
sb.append(delim);
|
});
|
||||||
sb.append(iter.next().toString());
|
for(IHierNode n:node.getChildNodes()) {
|
||||||
|
if(n.getChildNodes().size()>0)
|
||||||
|
sortRecursive(n);
|
||||||
}
|
}
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -75,15 +75,6 @@ public class E4LifeCycle {
|
||||||
}
|
}
|
||||||
final String confFile =opt.getSet().isSet("c")?opt.getSet().getOption("c").getResultValue(0):"";
|
final String confFile =opt.getSet().isSet("c")?opt.getSet().getOption("c").getResultValue(0):"";
|
||||||
|
|
||||||
// react on the first view being created, at that time the UI is available
|
|
||||||
// eventBroker.subscribe(UIEvents.UILifeCycle.ACTIVATE, new EventHandler() {
|
|
||||||
// @Override
|
|
||||||
// public void handleEvent(Event event) {
|
|
||||||
// MPart part = (MPart) event.getProperty("ChangedElement"); //$NON-NLS-1$
|
|
||||||
// if(part!=null){
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new EventHandler() {
|
eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new EventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(Event event) {
|
public void handleEvent(Event event) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class LoadingWaveformDb implements IWaveformDb {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentName(String name) {
|
public void setParent(IHierNode name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.minres.scviewer.e4.application.parts;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||||
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
|
import org.eclipse.jface.resource.StringConverter;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.graphics.Font;
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.wb.swt.SWTResourceManager;
|
||||||
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.ui.IWaveformStyleProvider;
|
||||||
|
import com.minres.scviewer.database.ui.WaveformColors;
|
||||||
|
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
||||||
|
|
||||||
|
public class WaveformStyleProvider implements IWaveformStyleProvider {
|
||||||
|
|
||||||
|
Composite parent;
|
||||||
|
|
||||||
|
private Font nameFont;
|
||||||
|
|
||||||
|
private Font nameFontB;
|
||||||
|
|
||||||
|
Color[] colors = new Color[WaveformColors.values().length];
|
||||||
|
|
||||||
|
|
||||||
|
public WaveformStyleProvider() {
|
||||||
|
setupDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDefaults() {
|
||||||
|
nameFont = Display.getCurrent().getSystemFont();
|
||||||
|
nameFontB = SWTResourceManager.getBoldFont(nameFont);
|
||||||
|
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||||
|
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
||||||
|
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
||||||
|
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
|
||||||
|
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
|
||||||
|
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||||
|
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||||
|
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||||
|
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||||
|
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||||
|
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.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
|
||||||
|
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||||
|
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||||
|
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||||
|
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||||
|
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
|
||||||
|
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||||
|
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
|
||||||
|
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WaveformStyleProvider(IEclipsePreferences store) {
|
||||||
|
setupDefaults();
|
||||||
|
Preferences defaultPrefs= store.parent().parent().node("/"+DefaultScope.SCOPE+"/"+PreferenceConstants.PREFERENCES_SCOPE);
|
||||||
|
HashMap<WaveformColors, RGB> colorPref = new HashMap<>();
|
||||||
|
for (WaveformColors c : WaveformColors.values()) {
|
||||||
|
String key = c.name() + "_COLOR";
|
||||||
|
String prefValue = store.get(key, defaultPrefs.get(key, "")); //$NON-NLS-1$
|
||||||
|
RGB rgb = StringConverter.asRGB(prefValue);
|
||||||
|
colorPref.put(c, rgb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* needs redraw() afterwards
|
||||||
|
* @param colourMap
|
||||||
|
*/
|
||||||
|
public void initColors(HashMap<WaveformColors, RGB> colourMap) {
|
||||||
|
Display d = parent.getDisplay();
|
||||||
|
if (colourMap != null) {
|
||||||
|
for (WaveformColors c : WaveformColors.values()) {
|
||||||
|
if (colourMap.containsKey(c))
|
||||||
|
colors[c.ordinal()] = new Color(d, colourMap.get(c));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Font getNameFont() {
|
||||||
|
return nameFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Font getNameFontHighlite() {
|
||||||
|
return nameFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTrackHeight() {
|
||||||
|
return 25;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Color getColor(WaveformColors type) {
|
||||||
|
return colors[type.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -37,7 +37,6 @@ import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.eclipse.core.runtime.jobs.JobGroup;
|
import org.eclipse.core.runtime.jobs.JobGroup;
|
||||||
import org.eclipse.core.runtime.preferences.DefaultScope;
|
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
|
||||||
|
@ -55,7 +54,6 @@ import org.eclipse.e4.ui.services.EMenuService;
|
||||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||||
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.resource.StringConverter;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
@ -70,7 +68,6 @@ import org.eclipse.swt.events.PaintEvent;
|
||||||
import org.eclipse.swt.events.PaintListener;
|
import org.eclipse.swt.events.PaintListener;
|
||||||
import org.eclipse.swt.graphics.Font;
|
import org.eclipse.swt.graphics.Font;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.layout.FillLayout;
|
import org.eclipse.swt.layout.FillLayout;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
@ -83,7 +80,6 @@ import org.eclipse.swt.widgets.Table;
|
||||||
import org.eclipse.swt.widgets.TableColumn;
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
import org.eclipse.swt.widgets.TableItem;
|
import org.eclipse.swt.widgets.TableItem;
|
||||||
import org.eclipse.swt.widgets.Widget;
|
import org.eclipse.swt.widgets.Widget;
|
||||||
import org.osgi.service.prefs.Preferences;
|
|
||||||
|
|
||||||
import com.minres.scviewer.database.DataType;
|
import com.minres.scviewer.database.DataType;
|
||||||
import com.minres.scviewer.database.IEvent;
|
import com.minres.scviewer.database.IEvent;
|
||||||
|
@ -101,7 +97,6 @@ import com.minres.scviewer.database.ui.IWaveformView;
|
||||||
import com.minres.scviewer.database.ui.TrackEntry;
|
import com.minres.scviewer.database.ui.TrackEntry;
|
||||||
import com.minres.scviewer.database.ui.TrackEntry.ValueDisplay;
|
import com.minres.scviewer.database.ui.TrackEntry.ValueDisplay;
|
||||||
import com.minres.scviewer.database.ui.TrackEntry.WaveDisplay;
|
import com.minres.scviewer.database.ui.TrackEntry.WaveDisplay;
|
||||||
import com.minres.scviewer.database.ui.WaveformColors;
|
|
||||||
import com.minres.scviewer.database.ui.swt.Constants;
|
import com.minres.scviewer.database.ui.swt.Constants;
|
||||||
import com.minres.scviewer.database.ui.swt.ToolTipContentProvider;
|
import com.minres.scviewer.database.ui.swt.ToolTipContentProvider;
|
||||||
import com.minres.scviewer.database.ui.swt.ToolTipHelpTextProvider;
|
import com.minres.scviewer.database.ui.swt.ToolTipHelpTextProvider;
|
||||||
|
@ -301,7 +296,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
transactionList = ContextInjectionFactory.make(TransactionListView.class, ctx);
|
transactionList = ContextInjectionFactory.make(TransactionListView.class, ctx);
|
||||||
|
|
||||||
waveformPane.setMaxTime(0);
|
waveformPane.setMaxTime(0);
|
||||||
setupColors();
|
|
||||||
//set selection to empty selection when opening a new waveformPane
|
//set selection to empty selection when opening a new waveformPane
|
||||||
selectionService.setSelection(new StructuredSelection());
|
selectionService.setSelection(new StructuredSelection());
|
||||||
|
|
||||||
|
@ -510,6 +504,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
setupColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -550,15 +545,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
* Setup colors.
|
* Setup colors.
|
||||||
*/
|
*/
|
||||||
protected void setupColors() {
|
protected void setupColors() {
|
||||||
Preferences defaultPrefs= store.parent().parent().node("/"+DefaultScope.SCOPE+"/"+PreferenceConstants.PREFERENCES_SCOPE);
|
waveformPane.setStyleProvider(new WaveformStyleProvider(store));
|
||||||
HashMap<WaveformColors, RGB> colorPref = new HashMap<>();
|
|
||||||
for (WaveformColors c : WaveformColors.values()) {
|
|
||||||
String key = c.name() + "_COLOR";
|
|
||||||
String prefValue = store.get(key, defaultPrefs.get(key, "")); //$NON-NLS-1$
|
|
||||||
RGB rgb = StringConverter.asRGB(prefValue);
|
|
||||||
colorPref.put(c, rgb);
|
|
||||||
}
|
|
||||||
waveformPane.setColors(colorPref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DbLoadJob extends Job {
|
class DbLoadJob extends Job {
|
||||||
|
|
Loading…
Reference in New Issue