move color settings into style provider
This commit is contained in:
parent
bedf4c5c4d
commit
754a61e989
|
@ -12,4 +12,6 @@ public interface IWaveformStyleProvider {
|
||||||
int getTrackHeight();
|
int getTrackHeight();
|
||||||
|
|
||||||
Color getColor(WaveformColors type);
|
Color getColor(WaveformColors type);
|
||||||
|
|
||||||
|
Color[] computeColor(String name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,4 +112,6 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide
|
||||||
public void addDisposeListener( DisposeListener listener );
|
public void addDisposeListener( DisposeListener listener );
|
||||||
|
|
||||||
public void deleteSelectedTracks();
|
public void deleteSelectedTracks();
|
||||||
|
|
||||||
|
public TrackEntry addWaveform(IWaveform waveform, int pos);
|
||||||
}
|
}
|
|
@ -11,63 +11,12 @@
|
||||||
package com.minres.scviewer.database.ui;
|
package com.minres.scviewer.database.ui;
|
||||||
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
|
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
|
|
||||||
public class TrackEntry {
|
public class TrackEntry {
|
||||||
|
|
||||||
// color info
|
IWaveformStyleProvider styleProvider;
|
||||||
public static Color fallbackColor = new Color(200,0,0);
|
|
||||||
public static Color highlightedFallbackColor = new Color(255,0,0);
|
|
||||||
private Color[]signalColors;
|
|
||||||
|
|
||||||
// list of random colors
|
|
||||||
private static Color[][] randomColors = {
|
|
||||||
{ new Color( 170, 66, 37 ), new Color ( 190, 66, 37 ) },
|
|
||||||
{ new Color( 96, 74, 110 ), new Color ( 96, 74, 130 ) },
|
|
||||||
{ new Color( 133, 105, 128 ), new Color ( 153, 105, 128 ) },
|
|
||||||
{ new Color( 0, 126, 135 ), new Color ( 0, 126, 155 ) },
|
|
||||||
{ new Color( 243, 146, 75 ), new Color ( 255, 146, 75 ) },
|
|
||||||
{ new Color( 206, 135, 163 ), new Color ( 226, 135, 163 ) },
|
|
||||||
{ new Color( 124, 103, 74 ), new Color ( 144, 103, 74 ) },
|
|
||||||
{ new Color( 194, 187, 169 ), new Color ( 214, 187, 169 ) },
|
|
||||||
{ new Color( 104, 73, 71 ), new Color ( 124, 73, 71 ) },
|
|
||||||
{ new Color( 75, 196, 213 ), new Color ( 75, 196, 233 ) },
|
|
||||||
{ new Color( 206, 232, 229 ), new Color ( 206, 252, 229 ) },
|
|
||||||
{ new Color( 169, 221, 199 ), new Color ( 169, 241, 199 ) },
|
|
||||||
{ new Color( 100, 165, 197 ), new Color ( 100, 165, 217 ) },
|
|
||||||
{ new Color( 150, 147, 178 ), new Color ( 150, 147, 198 ) },
|
|
||||||
{ new Color( 200, 222, 182 ), new Color ( 200, 242, 182 ) },
|
|
||||||
{ new Color( 147, 208, 197 ), new Color ( 147, 228, 197 ) }
|
|
||||||
};
|
|
||||||
|
|
||||||
public static Color[] computeColor (String streamValue, Color fallback, Color highlightedFallback) {
|
|
||||||
|
|
||||||
Color[]result = new Color[2];
|
|
||||||
|
|
||||||
result[0] = fallback;
|
|
||||||
result[1] = highlightedFallback;
|
|
||||||
|
|
||||||
// assign "random" color here, one name always results in the same color!
|
|
||||||
if( streamValue!=null && randomColors.length > 0 ) {
|
|
||||||
int index = Math.abs(streamValue.hashCode()) % randomColors.length;
|
|
||||||
result[0] = randomColors[index][0];
|
|
||||||
result[1] = randomColors[index][1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColor(Color changedColor, Color highlightColor) {
|
|
||||||
signalColors[0] = changedColor;
|
|
||||||
signalColors[1] = highlightColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color[] getColors() {
|
|
||||||
return signalColors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ValueDisplay {
|
public enum ValueDisplay {
|
||||||
DEFAULT, SIGNED, UNSIGNED
|
DEFAULT, SIGNED, UNSIGNED
|
||||||
|
@ -92,14 +41,12 @@ public class TrackEntry {
|
||||||
|
|
||||||
public WaveDisplay waveDisplay = WaveDisplay.DEFAULT;
|
public WaveDisplay waveDisplay = WaveDisplay.DEFAULT;
|
||||||
|
|
||||||
public TrackEntry(IWaveform waveform) {
|
public TrackEntry(IWaveform waveform, IWaveformStyleProvider styleProvider) {
|
||||||
this.waveform = waveform;
|
this.waveform = waveform;
|
||||||
|
this.styleProvider=styleProvider;
|
||||||
vOffset=0;
|
vOffset=0;
|
||||||
height=0;
|
height=0;
|
||||||
selected=false;
|
selected=false;
|
||||||
signalColors = new Color[2];
|
|
||||||
signalColors[0] = fallbackColor;
|
|
||||||
signalColors[1] = highlightedFallbackColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IWaveform getWaveform(){
|
public IWaveform getWaveform(){
|
||||||
|
|
|
@ -83,5 +83,10 @@ public class DefaultWaveformStyleProvider implements IWaveformStyleProvider {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return colors[type.ordinal()];
|
return colors[type.ordinal()];
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public Color[] computeColor(String name) {
|
||||||
|
return new Color[] {SWTResourceManager.getColor( 200,0,0), SWTResourceManager.getColor( 255,0,0)};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ 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 {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import java.util.NavigableMap;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
|
|
||||||
|
@ -46,20 +46,6 @@ public class StreamPainter extends TrackPainter{
|
||||||
this.seenTx=new TreeSet<ITx>();
|
this.seenTx=new TreeSet<ITx>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* convert java.awt.Color to org.eclipse.swt.graphics.Color
|
|
||||||
*/
|
|
||||||
static org.eclipse.swt.graphics.Color toSwtColor( GC gc, java.awt.Color awtColor ){
|
|
||||||
return new org.eclipse.swt.graphics.Color( gc.getDevice(), awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue() );
|
|
||||||
}
|
|
||||||
|
|
||||||
static org.eclipse.swt.graphics.Color[] toSwtColors( GC gc, java.awt.Color[] awtColors ){
|
|
||||||
org.eclipse.swt.graphics.Color[] swtColors = new org.eclipse.swt.graphics.Color[awtColors.length];
|
|
||||||
for( int i=0; i<awtColors.length; i++ )
|
|
||||||
swtColors[i] = toSwtColor( gc, awtColors[i] );
|
|
||||||
return swtColors;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void paintArea(Projection proj, Rectangle area) {
|
public void paintArea(Projection proj, Rectangle area) {
|
||||||
if(stream.getEvents().size()==0) return;
|
if(stream.getEvents().size()==0) return;
|
||||||
|
@ -124,10 +110,9 @@ public class StreamPainter extends TrackPainter{
|
||||||
|
|
||||||
protected void drawTx(Projection proj, Rectangle area, ITx tx, boolean highlighted ) {
|
protected void drawTx(Projection proj, Rectangle area, ITx tx, boolean highlighted ) {
|
||||||
// compute colors
|
// compute colors
|
||||||
java.awt.Color[] fallbackColors = trackEntry.getColors();
|
Color[] transColor = waveCanvas.styleProvider.computeColor( tx.getGenerator().getName());
|
||||||
java.awt.Color[] transColor = TrackEntry.computeColor( tx.getGenerator().getName(), fallbackColors[0], fallbackColors[1] );
|
|
||||||
|
|
||||||
proj.setBackground( toSwtColor( proj.getGC(), transColor[highlighted?1:0] ) );
|
proj.setBackground(transColor[highlighted?1:0]);
|
||||||
|
|
||||||
int offset = tx.getConcurrencyIndex()*this.waveCanvas.styleProvider.getTrackHeight();
|
int offset = tx.getConcurrencyIndex()*this.waveCanvas.styleProvider.getTrackHeight();
|
||||||
Rectangle bb = new Rectangle(
|
Rectangle bb = new Rectangle(
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package com.minres.scviewer.database.ui.swt.internal;
|
package com.minres.scviewer.database.ui.swt.internal;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.beans.PropertyChangeSupport;
|
import java.beans.PropertyChangeSupport;
|
||||||
|
@ -723,10 +722,7 @@ public class WaveformView implements IWaveformView {
|
||||||
ITx txSel = (ITx) sel;
|
ITx txSel = (ITx) sel;
|
||||||
TrackEntry trackEntry = getEntryForStream(txSel.getStream());
|
TrackEntry trackEntry = getEntryForStream(txSel.getStream());
|
||||||
if(trackEntry==null && addIfNeeded){
|
if(trackEntry==null && addIfNeeded){
|
||||||
trackEntry=new TrackEntry(txSel.getStream());
|
trackEntry=new TrackEntry(txSel.getStream(), styleProvider);
|
||||||
// compute fallback colors
|
|
||||||
Color fallbackColors[] = TrackEntry.computeColor(txSel.getStream().getName(), TrackEntry.fallbackColor, TrackEntry.highlightedFallbackColor);
|
|
||||||
trackEntry.setColor(fallbackColors[0], fallbackColors[1]);
|
|
||||||
streams.add(trackEntry);
|
streams.add(trackEntry);
|
||||||
}
|
}
|
||||||
currentTxSelection = txSel;
|
currentTxSelection = txSel;
|
||||||
|
@ -1394,4 +1390,14 @@ public class WaveformView implements IWaveformView {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TrackEntry addWaveform(IWaveform waveform, int idx) {
|
||||||
|
TrackEntry e = new TrackEntry(waveform, styleProvider);
|
||||||
|
if(idx<0)
|
||||||
|
getStreamList().add(e);
|
||||||
|
else
|
||||||
|
getStreamList().add(idx, e);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class WaveformPopupMenuContribution {
|
||||||
|
|
||||||
@Inject MPart activePart;
|
@Inject MPart activePart;
|
||||||
|
|
||||||
final TrackEntry nullEntry = new TrackEntry(null);
|
final TrackEntry nullEntry = new TrackEntry(null, null);
|
||||||
|
|
||||||
private boolean selHasBitVector(ISelection sel, boolean checkForDouble) {
|
private boolean selHasBitVector(ISelection sel, boolean checkForDouble) {
|
||||||
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||||
|
|
|
@ -20,13 +20,14 @@ import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
||||||
|
|
||||||
public class WaveformStyleProvider implements IWaveformStyleProvider {
|
public class WaveformStyleProvider implements IWaveformStyleProvider {
|
||||||
|
|
||||||
Composite parent;
|
private Composite parent;
|
||||||
|
|
||||||
private Font nameFont;
|
private Font nameFont;
|
||||||
|
|
||||||
private Font nameFontB;
|
private Color[] colors = new Color[WaveformColors.values().length];
|
||||||
|
|
||||||
Color[] colors = new Color[WaveformColors.values().length];
|
// list of random colors
|
||||||
|
private static Color[][] randomColors;
|
||||||
|
|
||||||
|
|
||||||
public WaveformStyleProvider() {
|
public WaveformStyleProvider() {
|
||||||
|
@ -34,8 +35,9 @@ public class WaveformStyleProvider implements IWaveformStyleProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupDefaults() {
|
private void setupDefaults() {
|
||||||
nameFont = Display.getCurrent().getSystemFont();
|
Display display = Display.getCurrent();
|
||||||
nameFontB = SWTResourceManager.getBoldFont(nameFont);
|
|
||||||
|
nameFont = display.getSystemFont();
|
||||||
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||||
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
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_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
||||||
|
@ -59,6 +61,24 @@ public class WaveformStyleProvider implements IWaveformStyleProvider {
|
||||||
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||||
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
|
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
|
||||||
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
||||||
|
randomColors = new Color[][] {
|
||||||
|
{ SWTResourceManager.getColor( 170, 66, 37 ), SWTResourceManager.getColor( 190, 66, 37 ) },
|
||||||
|
{ SWTResourceManager.getColor( 96, 74, 110 ), SWTResourceManager.getColor( 96, 74, 130 ) },
|
||||||
|
{ SWTResourceManager.getColor( 133, 105, 128 ), SWTResourceManager.getColor( 153, 105, 128 ) },
|
||||||
|
{ SWTResourceManager.getColor( 0, 126, 135 ), SWTResourceManager.getColor( 0, 126, 155 ) },
|
||||||
|
{ SWTResourceManager.getColor( 243, 146, 75 ), SWTResourceManager.getColor( 255, 146, 75 ) },
|
||||||
|
{ SWTResourceManager.getColor( 206, 135, 163 ), SWTResourceManager.getColor( 226, 135, 163 ) },
|
||||||
|
{ SWTResourceManager.getColor( 124, 103, 74 ), SWTResourceManager.getColor( 144, 103, 74 ) },
|
||||||
|
{ SWTResourceManager.getColor( 194, 187, 169 ), SWTResourceManager.getColor( 214, 187, 169 ) },
|
||||||
|
{ SWTResourceManager.getColor( 104, 73, 71 ), SWTResourceManager.getColor( 124, 73, 71 ) },
|
||||||
|
{ SWTResourceManager.getColor( 75, 196, 213 ), SWTResourceManager.getColor( 75, 196, 233 ) },
|
||||||
|
{ SWTResourceManager.getColor( 206, 232, 229 ), SWTResourceManager.getColor( 206, 252, 229 ) },
|
||||||
|
{ SWTResourceManager.getColor( 169, 221, 199 ), SWTResourceManager.getColor( 169, 241, 199 ) },
|
||||||
|
{ SWTResourceManager.getColor( 100, 165, 197 ), SWTResourceManager.getColor( 100, 165, 217 ) },
|
||||||
|
{ SWTResourceManager.getColor( 150, 147, 178 ), SWTResourceManager.getColor( 150, 147, 198 ) },
|
||||||
|
{ SWTResourceManager.getColor( 200, 222, 182 ), SWTResourceManager.getColor( 200, 242, 182 ) },
|
||||||
|
{ SWTResourceManager.getColor( 147, 208, 197 ), SWTResourceManager.getColor( 147, 228, 197 ) }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public WaveformStyleProvider(IEclipsePreferences store) {
|
public WaveformStyleProvider(IEclipsePreferences store) {
|
||||||
|
@ -105,4 +125,16 @@ public class WaveformStyleProvider implements IWaveformStyleProvider {
|
||||||
return colors[type.ordinal()];
|
return colors[type.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color[] computeColor (String streamValue) {
|
||||||
|
Color[] result = new Color[] {SWTResourceManager.getColor( 200,0,0), SWTResourceManager.getColor( 255,0,0)};
|
||||||
|
// assign "random" color here, one name always results in the same color!
|
||||||
|
if( streamValue!=null && randomColors.length > 0 ) {
|
||||||
|
int index = Math.abs(streamValue.hashCode()) % randomColors.length;
|
||||||
|
result[0] = randomColors[index][0];
|
||||||
|
result[1] = randomColors[index][1];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -504,7 +504,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setupColors();
|
waveformPane.setStyleProvider(new WaveformStyleProvider(store));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -537,17 +537,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
@Override
|
@Override
|
||||||
public void preferenceChange(PreferenceChangeEvent event) {
|
public void preferenceChange(PreferenceChangeEvent event) {
|
||||||
if (!PreferenceConstants.DATABASE_RELOAD.equals(event.getKey()) && !PreferenceConstants.SHOW_HOVER.equals(event.getKey())){
|
if (!PreferenceConstants.DATABASE_RELOAD.equals(event.getKey()) && !PreferenceConstants.SHOW_HOVER.equals(event.getKey())){
|
||||||
setupColors();
|
waveformPane.setStyleProvider(new WaveformStyleProvider(store)); }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup colors.
|
|
||||||
*/
|
|
||||||
protected void setupColors() {
|
|
||||||
waveformPane.setStyleProvider(new WaveformStyleProvider(store));
|
|
||||||
}
|
|
||||||
|
|
||||||
class DbLoadJob extends Job {
|
class DbLoadJob extends Job {
|
||||||
final File file;
|
final File file;
|
||||||
public DbLoadJob(String name, final File file) {
|
public DbLoadJob(String name, final File file) {
|
||||||
|
@ -809,7 +801,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
for (int i = 0; i < waves; i++) {
|
for (int i = 0; i < waves; i++) {
|
||||||
IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i));
|
IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i));
|
||||||
if (waveform != null) {
|
if (waveform != null) {
|
||||||
TrackEntry t = new TrackEntry(waveform);
|
TrackEntry t = waveformPane.addWaveform(waveform, -1);
|
||||||
//check if t is selected
|
//check if t is selected
|
||||||
boolean isSelected = Boolean.valueOf(state.get(SHOWN_WAVEFORM + i + WAVEFORM_SELECTED));
|
boolean isSelected = Boolean.valueOf(state.get(SHOWN_WAVEFORM + i + WAVEFORM_SELECTED));
|
||||||
if(isSelected) {
|
if(isSelected) {
|
||||||
|
@ -826,8 +818,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
t.waveDisplay=WaveDisplay.valueOf(s);
|
t.waveDisplay=WaveDisplay.valueOf(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res.size() > 0)
|
|
||||||
waveformPane.getStreamList().addAll(res);
|
|
||||||
Integer cursorLength = state.containsKey(SHOWN_CURSOR+"S")?Integer.parseInt(state.get(SHOWN_CURSOR + "S")):0; //$NON-NLS-1$ //$NON-NLS-2$
|
Integer cursorLength = state.containsKey(SHOWN_CURSOR+"S")?Integer.parseInt(state.get(SHOWN_CURSOR + "S")):0; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
List<ICursor> cursors = waveformPane.getCursorList();
|
List<ICursor> cursors = waveformPane.getCursorList();
|
||||||
if (cursorLength == cursors.size()) {
|
if (cursorLength == cursors.size()) {
|
||||||
|
@ -997,12 +987,10 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
* @param insert the insert
|
* @param insert the insert
|
||||||
*/
|
*/
|
||||||
public void addStreamsToList(IWaveform[] iWaveforms, boolean insert) {
|
public void addStreamsToList(IWaveform[] iWaveforms, boolean insert) {
|
||||||
List<TrackEntry> streams = new LinkedList<>();
|
|
||||||
for (IWaveform stream : iWaveforms)
|
|
||||||
streams.add(new TrackEntry(stream));
|
|
||||||
IStructuredSelection selection = (IStructuredSelection) waveformPane.getSelection();
|
IStructuredSelection selection = (IStructuredSelection) waveformPane.getSelection();
|
||||||
if (selection.size() == 0) {
|
if (selection.size() == 0) {
|
||||||
waveformPane.getStreamList().addAll(streams);
|
for (IWaveform waveform : iWaveforms)
|
||||||
|
waveformPane.addWaveform(waveform, -1);
|
||||||
} else {
|
} else {
|
||||||
Object first = selection.getFirstElement();
|
Object first = selection.getFirstElement();
|
||||||
if(first instanceof ITx) {
|
if(first instanceof ITx) {
|
||||||
|
@ -1010,17 +998,21 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
TrackEntry trackEntry = waveformPane.getEntryForStream(stream);
|
TrackEntry trackEntry = waveformPane.getEntryForStream(stream);
|
||||||
if (insert) {
|
if (insert) {
|
||||||
int index = waveformPane.getStreamList().indexOf(trackEntry);
|
int index = waveformPane.getStreamList().indexOf(trackEntry);
|
||||||
waveformPane.getStreamList().addAll(index, streams);
|
for (IWaveform waveform : iWaveforms)
|
||||||
|
waveformPane.addWaveform(waveform, index++);
|
||||||
} else {
|
} else {
|
||||||
waveformPane.getStreamList().addAll(streams);
|
for (IWaveform waveform : iWaveforms)
|
||||||
|
waveformPane.addWaveform(waveform, -1);
|
||||||
}
|
}
|
||||||
} else if(first instanceof TrackEntry) {
|
} else if(first instanceof TrackEntry) {
|
||||||
TrackEntry trackEntry = (TrackEntry) first;
|
TrackEntry trackEntry = (TrackEntry) first;
|
||||||
if (insert) {
|
if (insert) {
|
||||||
int index = waveformPane.getStreamList().indexOf(trackEntry);
|
int index = waveformPane.getStreamList().indexOf(trackEntry);
|
||||||
waveformPane.getStreamList().addAll(index, streams);
|
for (IWaveform waveform : iWaveforms)
|
||||||
|
waveformPane.addWaveform(waveform, index++);
|
||||||
} else {
|
} else {
|
||||||
waveformPane.getStreamList().addAll(streams);
|
for (IWaveform waveform : iWaveforms)
|
||||||
|
waveformPane.addWaveform(waveform, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -78,7 +77,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||||
|
|
||||||
public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave";
|
public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave";
|
||||||
|
|
||||||
private IWaveformView txDisplay;
|
private IWaveformView waveformView;
|
||||||
|
|
||||||
/** This is the root of the editor's model. */
|
/** This is the root of the editor's model. */
|
||||||
private IWaveformDb database;
|
private IWaveformDb database;
|
||||||
|
@ -106,23 +105,23 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||||
myParent.getDisplay().syncExec(new Runnable() {
|
myParent.getDisplay().syncExec(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
txDisplay.setMaxTime(database.getMaxTime());
|
waveformView.setMaxTime(database.getMaxTime());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
WaveformViewFactory factory = new WaveformViewFactory();
|
WaveformViewFactory factory = new WaveformViewFactory();
|
||||||
txDisplay = factory.createPanel(parent);
|
waveformView = factory.createPanel(parent);
|
||||||
txDisplay.setMaxTime(0);
|
waveformView.setMaxTime(0);
|
||||||
txDisplay.addPropertyChangeListener(IWaveformView.CURSOR_PROPERTY, new PropertyChangeListener() {
|
waveformView.addPropertyChangeListener(IWaveformView.CURSOR_PROPERTY, new PropertyChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
Long time = (Long) evt.getNewValue();
|
Long time = (Long) evt.getNewValue();
|
||||||
cursorStatusLineItem.setText("Cursor: "+ time/1000000+"ns");
|
cursorStatusLineItem.setText("Cursor: "+ time/1000000+"ns");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getSite().setSelectionProvider(txDisplay);
|
getSite().setSelectionProvider(waveformView);
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -133,8 +132,8 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).run();
|
}).run();
|
||||||
zoomStatusLineItem.setText("Zoom level: "+zoomLevel[txDisplay.getZoomLevel()]);
|
zoomStatusLineItem.setText("Zoom level: "+zoomLevel[waveformView.getZoomLevel()]);
|
||||||
cursorStatusLineItem.setText("Cursor: "+ txDisplay.getCursorTime()/1000000+"ns");
|
cursorStatusLineItem.setText("Cursor: "+ waveformView.getCursorTime()/1000000+"ns");
|
||||||
MenuManager menuMgr = new MenuManager("#PopupMenu");
|
MenuManager menuMgr = new MenuManager("#PopupMenu");
|
||||||
// menuMgr.setRemoveAllWhenShown(true);
|
// menuMgr.setRemoveAllWhenShown(true);
|
||||||
// menuMgr.addMenuListener(new IMenuListener() {
|
// menuMgr.addMenuListener(new IMenuListener() {
|
||||||
|
@ -142,9 +141,9 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||||
// fillContextMenu(manager);
|
// fillContextMenu(manager);
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
Menu menu = menuMgr.createContextMenu(txDisplay.getControl());
|
Menu menu = menuMgr.createContextMenu(waveformView.getControl());
|
||||||
txDisplay.getControl().setMenu(menu);
|
waveformView.getControl().setMenu(menu);
|
||||||
getSite().registerContextMenu(menuMgr, txDisplay);
|
getSite().registerContextMenu(menuMgr, waveformView);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +203,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||||
pm.beginTask("Loading database "+files[0].getName(), files.length);
|
pm.beginTask("Loading database "+files[0].getName(), files.length);
|
||||||
try {
|
try {
|
||||||
database.load(files[0]);
|
database.load(files[0]);
|
||||||
database.addPropertyChangeListener(txDisplay);
|
database.addPropertyChangeListener(waveformView);
|
||||||
pm.worked(1);
|
pm.worked(1);
|
||||||
if(pm.isCanceled()) return;
|
if(pm.isCanceled()) return;
|
||||||
if(files.length==2){
|
if(files.length==2){
|
||||||
|
@ -236,16 +235,14 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateTxDisplay() {
|
protected void updateTxDisplay() {
|
||||||
txDisplay.setMaxTime(database.getMaxTime());
|
waveformView.setMaxTime(database.getMaxTime());
|
||||||
if(TxEditorPart.this.getEditorInput() instanceof TxEditorInput &&
|
if(TxEditorPart.this.getEditorInput() instanceof TxEditorInput &&
|
||||||
((TxEditorInput) TxEditorPart.this.getEditorInput()).getStreamNames().size()>0){
|
((TxEditorInput) TxEditorPart.this.getEditorInput()).getStreamNames().size()>0){
|
||||||
LinkedList<TrackEntry> entries= new LinkedList<>();
|
|
||||||
for(String streamName:((TxEditorInput) TxEditorPart.this.getEditorInput()).getStreamNames()){
|
for(String streamName:((TxEditorInput) TxEditorPart.this.getEditorInput()).getStreamNames()){
|
||||||
IWaveform stream = database.getStreamByName(streamName);
|
IWaveform waveform = database.getStreamByName(streamName);
|
||||||
if(stream!=null)
|
if(waveform!=null)
|
||||||
entries.add(new TrackEntry(stream));
|
waveformView.addWaveform(waveform, -1);
|
||||||
}
|
}
|
||||||
txDisplay.getStreamList().addAll(entries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,9 +332,9 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||||
public void addStreamToList(IWaveform obj){
|
public void addStreamToList(IWaveform obj){
|
||||||
if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
|
if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
|
||||||
((TxEditorInput) getEditorInput()).getStreamNames().add(obj.getFullName());
|
((TxEditorInput) getEditorInput()).getStreamNames().add(obj.getFullName());
|
||||||
txDisplay.getStreamList().add(new TrackEntry(obj));
|
waveformView.addWaveform(obj, -1);
|
||||||
} else
|
} else
|
||||||
txDisplay.getStreamList().add(new TrackEntry(obj));
|
waveformView.addWaveform(obj, -1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,13 +348,13 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||||
((TxEditorInput) getEditorInput()).getStreamNames().remove(waveform.getFullName());
|
((TxEditorInput) getEditorInput()).getStreamNames().remove(waveform.getFullName());
|
||||||
}
|
}
|
||||||
TrackEntry entry=null;
|
TrackEntry entry=null;
|
||||||
for(TrackEntry e:txDisplay.getStreamList()) {
|
for(TrackEntry e:waveformView.getStreamList()) {
|
||||||
if(e.waveform==waveform) {
|
if(e.waveform==waveform) {
|
||||||
entry=e;
|
entry=e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txDisplay.getStreamList().remove(entry);
|
waveformView.getStreamList().remove(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeStreamsFromList(IWaveform[] iWaveforms){
|
public void removeStreamsFromList(IWaveform[] iWaveforms){
|
||||||
|
@ -366,20 +363,20 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TrackEntry> getStreamList(){
|
public List<TrackEntry> getStreamList(){
|
||||||
return txDisplay.getStreamList();
|
return waveformView.getStreamList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection(final ISelection selection){
|
public void setSelection(final ISelection selection){
|
||||||
myParent.getDisplay().asyncExec(new Runnable() {
|
myParent.getDisplay().asyncExec(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
txDisplay.setSelection(selection);
|
waveformView.setSelection(selection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISelection getSelection(){
|
public ISelection getSelection(){
|
||||||
return txDisplay.getSelection();
|
return waveformView.getSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -388,19 +385,19 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveSelection(GotoDirection next) {
|
public void moveSelection(GotoDirection next) {
|
||||||
txDisplay.moveSelection( next);
|
waveformView.moveSelection( next);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setZoomLevel(Integer level) {
|
public void setZoomLevel(Integer level) {
|
||||||
txDisplay.setZoomLevel(level);
|
waveformView.setZoomLevel(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setZoomFit() {
|
public void setZoomFit() {
|
||||||
txDisplay.setZoomLevel(6);
|
waveformView.setZoomLevel(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getZoomLevel() {
|
public int getZoomLevel() {
|
||||||
return txDisplay.getZoomLevel();
|
return waveformView.getZoomLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSelected() {
|
public void removeSelected() {
|
||||||
|
|
Loading…
Reference in New Issue