fix sonar lint reported issues in UI plugins
This commit is contained in:
parent
6c5032da10
commit
70ccf35fe4
|
@ -17,7 +17,6 @@ public class TrackEntry {
|
|||
|
||||
IWaveformStyleProvider styleProvider;
|
||||
|
||||
|
||||
public enum ValueDisplay {
|
||||
DEFAULT, SIGNED, UNSIGNED
|
||||
|
||||
|
@ -49,10 +48,6 @@ public class TrackEntry {
|
|||
selected=false;
|
||||
}
|
||||
|
||||
public IWaveform getWaveform(){
|
||||
return waveform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof TrackEntry){
|
||||
|
|
|
@ -2,11 +2,13 @@ package com.minres.scviewer.database.ui.swt;
|
|||
|
||||
public class Constants {
|
||||
|
||||
public static final String[] unitString={"fs", "ps", "ns", "us", "ms"};//, "s"};
|
||||
public static final String[] UNIT_STRING={"fs", "ps", "ns", "us", "ms"};//, "s"};
|
||||
|
||||
public static final int[] unitMultiplier={1, 3, 10, 30, 100, 300};
|
||||
public static final int[] UNIT_MULTIPLIER={1, 3, 10, 30, 100, 300};
|
||||
|
||||
public static final String CONTENT_PROVIDER_TAG = "TOOLTIP_CONTENT_PROVIDER";
|
||||
public static final String HELP_PROVIDER_TAG = "TOOLTIP_HELP_PROVIDER";
|
||||
|
||||
private Constants() {}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,11 +17,13 @@ import org.osgi.framework.BundleContext;
|
|||
|
||||
public class DatabaseUiPlugin extends Plugin {
|
||||
|
||||
public void start(BundleContext context) throws Exception {
|
||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Starting org.eclipse.e4.core bundle..."));
|
||||
}
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Starting org.eclipse.e4.core bundle..."));
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Stopping org.eclipse.e4.core bundle..."));
|
||||
}
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Stopping org.eclipse.e4.core bundle..."));
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.minres.scviewer.database.ui.swt;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
|
@ -54,7 +54,7 @@ public class DefaultWaveformStyleProvider implements IWaveformStyleProvider {
|
|||
* needs redraw() afterwards
|
||||
* @param colourMap
|
||||
*/
|
||||
public void initColors(HashMap<WaveformColors, RGB> colourMap) {
|
||||
public void initColors(Map<WaveformColors, RGB> colourMap) {
|
||||
Display d = parent.getDisplay();
|
||||
if (colourMap != null) {
|
||||
for (WaveformColors c : WaveformColors.values()) {
|
||||
|
@ -80,7 +80,6 @@ public class DefaultWaveformStyleProvider implements IWaveformStyleProvider {
|
|||
}
|
||||
@Override
|
||||
public Color getColor(WaveformColors type) {
|
||||
// TODO Auto-generated method stub
|
||||
return colors[type.ordinal()];
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.minres.scviewer.database.ui.WaveformColors;
|
|||
|
||||
public class ArrowPainter implements IPainter {
|
||||
|
||||
private final int xCtrlOffset = 50;
|
||||
private static final float X_CTRL_OFFSET = 50;
|
||||
|
||||
private int yCtrlOffset = 30;
|
||||
|
||||
|
@ -151,10 +151,10 @@ public class ArrowPainter implements IPainter {
|
|||
path.moveTo(point1.x, point1.y);
|
||||
if (point1.y == point2.y) {
|
||||
Point center = new Point((point1.x + point2.x) / 2, point1.y - yCtrlOffset);
|
||||
path.cubicTo(point1.x + xCtrlOffset, point1.y, center.x - xCtrlOffset, center.y, center.x, center.y);
|
||||
path.cubicTo(center.x + xCtrlOffset, center.y, point2.x - xCtrlOffset, point2.y, point2.x, point2.y);
|
||||
path.cubicTo(point1.x + X_CTRL_OFFSET, point1.y, center.x - X_CTRL_OFFSET, center.y, center.x, center.y);
|
||||
path.cubicTo(center.x + X_CTRL_OFFSET, center.y, point2.x - X_CTRL_OFFSET, point2.y, point2.x, point2.y);
|
||||
} else
|
||||
path.cubicTo(point1.x + xCtrlOffset, point1.y, point2.x - xCtrlOffset, point2.y, point2.x, point2.y);
|
||||
path.cubicTo(point1.x + X_CTRL_OFFSET, point1.y, point2.x - X_CTRL_OFFSET, point2.y, point2.x, point2.y);
|
||||
|
||||
proj.setAntialias(SWT.ON);
|
||||
proj.setForeground(fgColor);
|
||||
|
@ -167,8 +167,8 @@ public class ArrowPainter implements IPainter {
|
|||
}
|
||||
|
||||
class LinkEntry {
|
||||
public Rectangle rectangle;
|
||||
public RelationType relationType;
|
||||
public final Rectangle rectangle;
|
||||
public final RelationType relationType;
|
||||
|
||||
public LinkEntry(Rectangle rectangle, RelationType relationType) {
|
||||
super();
|
||||
|
|
|
@ -63,7 +63,7 @@ public class CursorPainter implements IPainter, ICursor {
|
|||
|
||||
public void paintArea(Projection proj, Rectangle clientRect) {
|
||||
Rectangle area = proj.unProject(clientRect);
|
||||
if(this.waveCanvas.painterList.size()>0){
|
||||
if(!waveCanvas.painterList.isEmpty()){
|
||||
|
||||
long scaleFactor=waveCanvas.getScaleFactor();
|
||||
long beginPos = area.x;
|
||||
|
@ -83,7 +83,7 @@ public class CursorPainter implements IPainter, ICursor {
|
|||
proj.drawLine(x, top, x, area.y+area.height);
|
||||
proj.setBackground(drawColor);
|
||||
proj.setForeground(textColor);
|
||||
Double dTime=new Double(time);
|
||||
double dTime=time;
|
||||
proj.drawText((dTime/waveCanvas.getScaleFactorPow10())+waveCanvas.getUnitStr(), x+1, top);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class ObservableList<E> implements List<E> {
|
|||
public static final String CONTENT_PROPERTY = "content";
|
||||
|
||||
public ObservableList() {
|
||||
this(new ArrayList<E>());
|
||||
this(new ArrayList<>());
|
||||
}
|
||||
|
||||
public ObservableList(List<E> delegate) {
|
||||
|
@ -100,7 +100,7 @@ public class ObservableList<E> implements List<E> {
|
|||
|
||||
boolean success = this.delegate.addAll(c);
|
||||
if ((success) && (c != null)) {
|
||||
List<E> values = new ArrayList<E>();
|
||||
List<E> values = new ArrayList<>();
|
||||
for (Iterator<? extends E> i = c.iterator(); i.hasNext();) {
|
||||
values.add(i.next());
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ public class ObservableList<E> implements List<E> {
|
|||
boolean success = this.delegate.addAll(index, c);
|
||||
|
||||
if ((success) && (c != null)) {
|
||||
List<E> values = new ArrayList<E>();
|
||||
List<E> values = new ArrayList<>();
|
||||
for (Iterator<? extends E> i = c.iterator(); i.hasNext();) {
|
||||
values.add(i.next());
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public class ObservableList<E> implements List<E> {
|
|||
|
||||
public void clear() {
|
||||
int oldSize = size();
|
||||
List<E> values = new ArrayList<E>();
|
||||
List<E> values = new ArrayList<>();
|
||||
values.addAll(this.delegate);
|
||||
this.delegate.clear();
|
||||
if (!(values.isEmpty())) {
|
||||
|
@ -215,14 +215,12 @@ public class ObservableList<E> implements List<E> {
|
|||
return false;
|
||||
}
|
||||
|
||||
List<E> values = new ArrayList<E>();
|
||||
if (c != null) {
|
||||
for (Iterator<?> i = c.iterator(); i.hasNext();) {
|
||||
@SuppressWarnings("unchecked")
|
||||
E element = (E) i.next();
|
||||
if (this.delegate.contains(element)) {
|
||||
values.add(element);
|
||||
}
|
||||
List<E> values = new ArrayList<>();
|
||||
for (Iterator<?> i = c.iterator(); i.hasNext();) {
|
||||
@SuppressWarnings("unchecked")
|
||||
E element = (E) i.next();
|
||||
if (this.delegate.contains(element)) {
|
||||
values.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,14 +239,12 @@ public class ObservableList<E> implements List<E> {
|
|||
return false;
|
||||
}
|
||||
|
||||
List<E> values = new ArrayList<E>();
|
||||
List<E> values = new ArrayList<>();
|
||||
Iterator<? extends E> i;
|
||||
if (c != null) {
|
||||
for (i = this.delegate.iterator(); i.hasNext();) {
|
||||
E element = i.next();
|
||||
if (!(c.contains(element))) {
|
||||
values.add(element);
|
||||
}
|
||||
for (i = this.delegate.iterator(); i.hasNext();) {
|
||||
E element = i.next();
|
||||
if (!(c.contains(element))) {
|
||||
values.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,7 +323,7 @@ public class ObservableList<E> implements List<E> {
|
|||
*/
|
||||
private static final long serialVersionUID = 7819626246672640599L;
|
||||
|
||||
private List<Object> values = new ArrayList<Object>();
|
||||
private List<Object> values = new ArrayList<>();
|
||||
|
||||
public MultiElementUpdatedEvent(Object source, List<?> values) {
|
||||
super(source, ObservableList.ChangeType.oldValue, ObservableList.ChangeType.newValue, 0,
|
||||
|
@ -336,7 +332,7 @@ public class ObservableList<E> implements List<E> {
|
|||
this.values.addAll(values);
|
||||
}
|
||||
|
||||
public List<?> getValues() {
|
||||
public List<Object> getValues() {
|
||||
return Collections.unmodifiableList(this.values);
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +343,7 @@ public class ObservableList<E> implements List<E> {
|
|||
*/
|
||||
private static final long serialVersionUID = 7819626246672640599L;
|
||||
|
||||
private List<Object> values = new ArrayList<Object>();
|
||||
private List<Object> values = new ArrayList<>();
|
||||
|
||||
public MultiElementRemovedEvent(Object source, List<?> values) {
|
||||
super(source, ObservableList.ChangeType.oldValue, ObservableList.ChangeType.newValue, 0,
|
||||
|
@ -356,7 +352,7 @@ public class ObservableList<E> implements List<E> {
|
|||
this.values.addAll(values);
|
||||
}
|
||||
|
||||
public List<?> getValues() {
|
||||
public List<Object> getValues() {
|
||||
return Collections.unmodifiableList(this.values);
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +362,7 @@ public class ObservableList<E> implements List<E> {
|
|||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -116376519087713082L;
|
||||
private List<Object> values = new ArrayList<Object>();
|
||||
private List<Object> values = new ArrayList<>();
|
||||
|
||||
public MultiElementAddedEvent(Object source, int index, List<?> values) {
|
||||
super(source, ObservableList.ChangeType.oldValue, ObservableList.ChangeType.newValue, index,
|
||||
|
@ -375,7 +371,7 @@ public class ObservableList<E> implements List<E> {
|
|||
this.values.addAll(values);
|
||||
}
|
||||
|
||||
public List<?> getValues() {
|
||||
public List<Object> getValues() {
|
||||
return Collections.unmodifiableList(this.values);
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +381,7 @@ public class ObservableList<E> implements List<E> {
|
|||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8654027608903811577L;
|
||||
private List<Object> values = new ArrayList<Object>();
|
||||
private List<Object> values = new ArrayList<>();
|
||||
|
||||
public ElementClearedEvent(Object source, List<?> values) {
|
||||
super(source, ObservableList.ChangeType.oldValue, ObservableList.ChangeType.newValue, 0,
|
||||
|
@ -394,7 +390,7 @@ public class ObservableList<E> implements List<E> {
|
|||
this.values.addAll(values);
|
||||
}
|
||||
|
||||
public List<?> getValues() {
|
||||
public List<Object> getValues() {
|
||||
return Collections.unmodifiableList(this.values);
|
||||
}
|
||||
}
|
||||
|
@ -432,7 +428,7 @@ public class ObservableList<E> implements List<E> {
|
|||
}
|
||||
}
|
||||
|
||||
public static abstract class ElementEvent extends PropertyChangeEvent {
|
||||
public abstract static class ElementEvent extends PropertyChangeEvent {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -441,7 +437,7 @@ public class ObservableList<E> implements List<E> {
|
|||
private final int index;
|
||||
|
||||
public ElementEvent(Object source, Object oldValue, Object newValue, int index, ObservableList.ChangeType type) {
|
||||
super(source, "content", oldValue, newValue);
|
||||
super(source, CONTENT_PROPERTY, oldValue, newValue);
|
||||
this.type = type;
|
||||
this.index = index;
|
||||
}
|
||||
|
@ -463,7 +459,7 @@ public class ObservableList<E> implements List<E> {
|
|||
}
|
||||
}
|
||||
|
||||
public static enum ChangeType {
|
||||
public enum ChangeType {
|
||||
ADDED, UPDATED, REMOVED, CLEARED, MULTI_ADD, MULTI_UPDATED, MULTI_REMOVE, NONE;
|
||||
|
||||
public static final Object oldValue;
|
||||
|
@ -483,9 +479,9 @@ public class ObservableList<E> implements List<E> {
|
|||
return MULTI_REMOVE;
|
||||
case 6:
|
||||
return NONE;
|
||||
case 1:
|
||||
default:
|
||||
return UPDATED;
|
||||
}
|
||||
return UPDATED;
|
||||
}
|
||||
|
||||
static {
|
||||
|
@ -554,6 +550,7 @@ public class ObservableList<E> implements List<E> {
|
|||
return this.iterDelegate.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
int oldSize = ObservableList.this.size();
|
||||
Object element = ObservableList.this.get(this.cursor);
|
||||
|
|
|
@ -24,7 +24,7 @@ class RelSelectionDialog extends Dialog {
|
|||
|
||||
private ITxRelation selected = null;
|
||||
|
||||
public RelSelectionDialog(Shell shell, ArrayList<ITxRelation> candidates, boolean target) {
|
||||
public RelSelectionDialog(Shell shell, java.util.List<ITxRelation> candidates, boolean target) {
|
||||
super(shell);
|
||||
entries = candidates;
|
||||
entryTx = entries.stream().map(r->target?r.getTarget():r.getSource()).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
|
|
@ -21,8 +21,8 @@ import org.eclipse.wb.swt.SWTResourceManager;
|
|||
public class RulerPainter implements IPainter {
|
||||
protected WaveformCanvas waveCanvas;
|
||||
|
||||
static final int rulerTickMinorC = 10;
|
||||
static final int rulerTickMajorC = 100;
|
||||
static final int RULER_TICK_MINOR = 10;
|
||||
static final int RULER_TICK_MAJOR = 100;
|
||||
|
||||
static final DecimalFormat df = new DecimalFormat("#.00####");
|
||||
|
||||
|
@ -47,8 +47,8 @@ public class RulerPainter implements IPainter {
|
|||
long startVal=startPos - proj.getTranslation().x*scaleFactor;
|
||||
long endPos=startPos+area.width*scaleFactor;
|
||||
|
||||
long rulerTickMinor = rulerTickMinorC*scaleFactor;
|
||||
long rulerTickMajor = rulerTickMajorC*scaleFactor;
|
||||
long rulerTickMinor = RULER_TICK_MINOR*scaleFactor;
|
||||
long rulerTickMajor = RULER_TICK_MAJOR*scaleFactor;
|
||||
|
||||
int minorTickY = waveCanvas.rulerHeight-5;
|
||||
int majorTickY = waveCanvas.rulerHeight-15;
|
||||
|
@ -68,13 +68,13 @@ public class RulerPainter implements IPainter {
|
|||
gc.drawLine(area.x, area.y+bottom, area.x+area.width, area.y+bottom);
|
||||
|
||||
for (long pos = startMinorIncrPos, tick = startMinorIncrVal; pos < endPos; pos+= rulerTickMinor, tick += rulerTickMinor) {
|
||||
int x0_pos = (int) (pos/scaleFactor);
|
||||
long x0_val = tick/scaleFactor;
|
||||
int x0Pos = (int) (pos/scaleFactor);
|
||||
long x0Val = tick/scaleFactor;
|
||||
if ((tick % rulerTickMajor) == 0) {
|
||||
gc.drawText(df.format(x0_val*unitMultiplier)+unit, x0_pos, area.y+textY);
|
||||
gc.drawLine(x0_pos, area.y+majorTickY, x0_pos,area.y+ bottom);
|
||||
gc.drawText(df.format(x0Val*unitMultiplier)+unit, x0Pos, area.y+textY);
|
||||
gc.drawLine(x0Pos, area.y+majorTickY, x0Pos,area.y+ bottom);
|
||||
} else {
|
||||
gc.drawLine(x0_pos, area.y+minorTickY, x0_pos, area.y+bottom);
|
||||
gc.drawLine(x0Pos, area.y+minorTickY, x0Pos, area.y+bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.ui.swt.internal;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
|
@ -140,7 +141,7 @@ public class SignalPainter extends TrackPainter {
|
|||
|
||||
|
||||
SignalStencil stencil = getStencil(proj.getGC(), left, entries);
|
||||
do {
|
||||
if(stencil!=null) do {
|
||||
stencil.draw(proj, area, left.value, right.value, xSigChangeBeginPos, xSigChangeEndPos, multiple);
|
||||
if (right.time >= endTime)
|
||||
break;
|
||||
|
@ -197,9 +198,9 @@ public class SignalPainter extends TrackPainter {
|
|||
public void draw(Projection proj, Rectangle area, IEvent left, IEvent right, int xBegin, int xEnd, boolean multiple) {
|
||||
Color colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL0);
|
||||
BitVector last = (BitVector) left;
|
||||
if (last.getValue().toString().contains("X")) {
|
||||
if (Arrays.toString(last.getValue()).contains("X")) {
|
||||
colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALX);
|
||||
} else if (last.getValue().toString().contains("Z")) {
|
||||
} else if (Arrays.toString(last.getValue()).contains("Z")) {
|
||||
colorBorder = waveCanvas.styleProvider.getColor(WaveformColors.SIGNALZ);
|
||||
}
|
||||
int width = xEnd - xBegin;
|
||||
|
@ -215,7 +216,6 @@ public class SignalPainter extends TrackPainter {
|
|||
proj.setForeground(colorBorder);
|
||||
proj.drawPolygon(points);
|
||||
proj.setForeground(waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_TEXT));
|
||||
//TODO: this code should be provided from a central location
|
||||
String label = null;
|
||||
switch(trackEntry.valueDisplay) {
|
||||
case SIGNED:
|
||||
|
@ -351,7 +351,8 @@ public class SignalPainter extends TrackPainter {
|
|||
|
||||
private class RealStencil implements SignalStencil {
|
||||
|
||||
double minVal, range;
|
||||
double minVal;
|
||||
double range;
|
||||
|
||||
final double scaleFactor = 1.05;
|
||||
|
||||
|
@ -359,22 +360,23 @@ public class SignalPainter extends TrackPainter {
|
|||
|
||||
public RealStencil(NavigableMap<Long, IEvent[]> entries, Object left, boolean continous) {
|
||||
this.continous=continous;
|
||||
Collection<IEvent[]> values = ((NavigableMap<Long, IEvent[]>) entries).values();
|
||||
Collection<IEvent[]> values = entries.values();
|
||||
minVal=(Double) left;
|
||||
range=2.0;
|
||||
if(!values.isEmpty()) {
|
||||
double maxVal=minVal;
|
||||
for (Object e : entries.values()) {
|
||||
double v = ((Double)e);
|
||||
if(Double.isNaN(maxVal))
|
||||
maxVal=v;
|
||||
else if(!Double.isNaN(v))
|
||||
maxVal=Math.max(maxVal, v);
|
||||
if(Double.isNaN(minVal))
|
||||
minVal=v;
|
||||
else if(!Double.isNaN(v))
|
||||
minVal=Math.min(minVal, v);
|
||||
}
|
||||
for (IEvent[] val : entries.values())
|
||||
for(IEvent e:val) {
|
||||
double v = ((DoubleVal)e).value;
|
||||
if(Double.isNaN(maxVal))
|
||||
maxVal=v;
|
||||
else if(!Double.isNaN(v))
|
||||
maxVal=Math.max(maxVal, v);
|
||||
if(Double.isNaN(minVal))
|
||||
minVal=v;
|
||||
else if(!Double.isNaN(v))
|
||||
minVal=Math.min(minVal, v);
|
||||
}
|
||||
if(Double.isNaN(maxVal)){
|
||||
maxVal=minVal=0.0;
|
||||
}
|
||||
|
|
|
@ -35,15 +35,15 @@ public class StreamPainter extends TrackPainter{
|
|||
*/
|
||||
private final WaveformCanvas waveCanvas;
|
||||
private IWaveform stream;
|
||||
private int txBase, txHeight;
|
||||
private boolean even;
|
||||
private int txBase;
|
||||
private int txHeight;
|
||||
private TreeSet<ITx> seenTx;
|
||||
|
||||
public StreamPainter(WaveformCanvas waveCanvas, boolean even, TrackEntry trackEntry) {
|
||||
super(trackEntry, even);
|
||||
this.waveCanvas = waveCanvas;
|
||||
this.stream=trackEntry.waveform;
|
||||
this.seenTx=new TreeSet<ITx>();
|
||||
this.seenTx=new TreeSet<>();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -63,7 +63,6 @@ public class StreamPainter extends TrackPainter{
|
|||
long scaleFactor = this.waveCanvas.getScaleFactor();
|
||||
long beginPos = area.x;
|
||||
long beginTime = beginPos*scaleFactor;
|
||||
//long endPos = beginPos + area.width;
|
||||
long endTime = beginTime + area.width*scaleFactor;
|
||||
|
||||
Entry<Long, ?> firstTx=stream.getEvents().floorEntry(beginTime);
|
||||
|
@ -127,11 +126,11 @@ public class StreamPainter extends TrackPainter{
|
|||
bb.width = bb.width-(area.x-bb.x)+5;
|
||||
bb.x=area.x-5;
|
||||
}
|
||||
int bb_x2 = bb.x+bb.width;
|
||||
int area_x2 = area.x+area.width;
|
||||
if(bb_x2>area_x2){
|
||||
bb_x2=area_x2+5;
|
||||
bb.width= bb_x2-bb.x;
|
||||
int bbX2 = bb.x+bb.width;
|
||||
int areaX2 = area.x+area.width;
|
||||
if(bbX2>areaX2){
|
||||
bbX2=areaX2+5;
|
||||
bb.width= bbX2-bb.x;
|
||||
}
|
||||
int arc = bb.width<10?1:5;
|
||||
proj.fillRoundRectangle(bb.x, bb.y, bb.width, bb.height, arc, arc);
|
||||
|
|
|
@ -26,7 +26,7 @@ class ToolTipHandler {
|
|||
private Widget tipWidget; // widget this tooltip is hovering over
|
||||
private Point tipPosition; // the position being hovered over
|
||||
|
||||
private static final int hoverYOffset = 1;
|
||||
private static final int HOVER_YOFFSET = 1;
|
||||
|
||||
/**
|
||||
* Creates a new tooltip handler
|
||||
|
@ -45,56 +45,57 @@ class ToolTipHandler {
|
|||
*/
|
||||
public void activateHoverHelp(final Control control) {
|
||||
Listener listener = new Listener () {
|
||||
Shell tip = null;
|
||||
Shell shell = null;
|
||||
@Override
|
||||
public void handleEvent (Event event) {
|
||||
switch (event.type) {
|
||||
case SWT.KeyDown:{
|
||||
if (tip != null && tip.isVisible() && event.keyCode == SWT.F2) {
|
||||
tip.setFocus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
case SWT.KeyDown:
|
||||
if (shell != null && shell.isVisible() && event.keyCode == SWT.F2)
|
||||
shell.setFocus();
|
||||
break;
|
||||
case SWT.Dispose:
|
||||
case SWT.MouseMove:
|
||||
case SWT.MouseDown: {
|
||||
if (tip != null){
|
||||
tip.dispose ();
|
||||
tip = null;
|
||||
case SWT.MouseDown:
|
||||
if (shell != null){
|
||||
shell.dispose ();
|
||||
shell = null;
|
||||
tipWidget=null;
|
||||
}
|
||||
break;
|
||||
case SWT.MouseHover:
|
||||
createHoverWindow(control, event);
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
}
|
||||
case SWT.MouseHover: {
|
||||
Object o = control.getData(Constants.CONTENT_PROVIDER_TAG);
|
||||
if(o != null && o instanceof ToolTipContentProvider) {
|
||||
ToolTipContentProvider provider = ((ToolTipContentProvider)o);
|
||||
Point pt = new Point (event.x, event.y);
|
||||
tipPosition = control.toDisplay(pt);
|
||||
if (tip != null && !tip.isDisposed ()) tip.dispose ();
|
||||
tip = new Shell (parentShell, SWT.NO_FOCUS | SWT.TOOL);
|
||||
tip.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
|
||||
GridLayout layout = new GridLayout(1, true);
|
||||
layout.verticalSpacing=0;
|
||||
layout.horizontalSpacing=0;
|
||||
layout.marginWidth = 0;
|
||||
layout.marginHeight = 0;
|
||||
tip.setLayout(layout);
|
||||
boolean visible = provider.createContent(tip, pt);
|
||||
tip.pack();
|
||||
tip.setSize(tip.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||
setHoverLocation(tip, tipPosition);
|
||||
tip.setVisible (visible);
|
||||
if(visible)
|
||||
tipWidget=event.widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void createHoverWindow(final Control control, Event event) {
|
||||
Object o = control.getData(Constants.CONTENT_PROVIDER_TAG);
|
||||
if(o instanceof ToolTipContentProvider) {
|
||||
ToolTipContentProvider provider = ((ToolTipContentProvider)o);
|
||||
Point pt = new Point (event.x, event.y);
|
||||
tipPosition = control.toDisplay(pt);
|
||||
if (shell != null && !shell.isDisposed ()) shell.dispose ();
|
||||
shell = new Shell (parentShell, SWT.NO_FOCUS | SWT.TOOL);
|
||||
shell.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
|
||||
GridLayout layout = new GridLayout(1, true);
|
||||
layout.verticalSpacing=0;
|
||||
layout.horizontalSpacing=0;
|
||||
layout.marginWidth = 0;
|
||||
layout.marginHeight = 0;
|
||||
shell.setLayout(layout);
|
||||
boolean visible = provider.createContent(shell, pt);
|
||||
shell.pack();
|
||||
shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||
setHoverLocation(shell, tipPosition);
|
||||
shell.setVisible (visible);
|
||||
if(visible)
|
||||
tipWidget=event.widget;
|
||||
}
|
||||
}
|
||||
};
|
||||
control.addListener (SWT.Dispose, listener);
|
||||
control.addListener (SWT.KeyDown, listener);
|
||||
//control.addListener (SWT.MouseMove, listener);
|
||||
control.addListener (SWT.MouseHover, listener);
|
||||
control.addListener (SWT.MouseDown, listener);
|
||||
|
||||
|
@ -119,11 +120,6 @@ class ToolTipHandler {
|
|||
helpShell.open();
|
||||
}
|
||||
});
|
||||
// control.addKeyListener(KeyListener.keyPressedAdapter( e-> {
|
||||
// if (e.keyCode == SWT.F2 && shell.isVisible()) {
|
||||
// shell.setFocus();
|
||||
// }
|
||||
// }));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,7 +132,7 @@ class ToolTipHandler {
|
|||
Rectangle displayBounds = shell.getDisplay().getBounds();
|
||||
Rectangle shellBounds = shell.getBounds();
|
||||
shellBounds.x = Math.max(Math.min(position.x, displayBounds.width - shellBounds.width), 0);
|
||||
shellBounds.y = Math.max(Math.min(position.y + hoverYOffset, displayBounds.height - shellBounds.height), 0);
|
||||
shellBounds.y = Math.max(Math.min(position.y + HOVER_YOFFSET, displayBounds.height - shellBounds.height), 0);
|
||||
shell.setBounds(shellBounds);
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ public class TrackAreaPainter implements IPainter {
|
|||
*/
|
||||
private final WaveformCanvas waveCanvas;
|
||||
|
||||
TreeMap<Integer, IWaveformPainter> trackVerticalOffset;
|
||||
final TreeMap<Integer, IWaveformPainter> trackVerticalOffset;
|
||||
/**
|
||||
* @param txDisplay
|
||||
*/
|
||||
|
@ -44,7 +44,7 @@ public class TrackAreaPainter implements IPainter {
|
|||
if(firstKey==null) firstKey=trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(area.y+area.height);
|
||||
Rectangle subArea = new Rectangle(area.x, 0, area.width, 0);
|
||||
if(lastKey==firstKey){
|
||||
if(lastKey.equals(firstKey)){
|
||||
subArea.y=firstKey;
|
||||
IWaveformPainter p = trackVerticalOffset.get(firstKey);
|
||||
subArea.height=p.getHeight();
|
||||
|
@ -59,10 +59,6 @@ public class TrackAreaPainter implements IPainter {
|
|||
}
|
||||
}
|
||||
|
||||
public TreeMap<Integer, IWaveformPainter> getTrackVerticalOffset() {
|
||||
return trackVerticalOffset;
|
||||
}
|
||||
|
||||
public void addTrackPainter(IWaveformPainter trackPainter){
|
||||
trackVerticalOffset.put(trackPainter.getVerticalOffset()+waveCanvas.rulerHeight, trackPainter);
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.eclipse.swt.SWT;
|
|||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
|
@ -86,16 +85,13 @@ public class WaveformCanvas extends Canvas {
|
|||
super(parent, style | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
this.styleProvider=styleProvider;
|
||||
addControlListener(new ControlAdapter() { /* resize listener. */
|
||||
public void controlResized(ControlEvent event) {
|
||||
@Override
|
||||
public void controlResized(ControlEvent event) {
|
||||
syncScrollBars();
|
||||
}
|
||||
});
|
||||
addPaintListener(new PaintListener() { /* paint listener. */
|
||||
public void paintControl(final PaintEvent event) {
|
||||
paint(event.gc);
|
||||
}
|
||||
});
|
||||
painterList = new LinkedList<IPainter>();
|
||||
addPaintListener((final PaintEvent event) -> paint(event.gc));
|
||||
painterList = new LinkedList<>();
|
||||
origin = new Point(0, 0);
|
||||
selectionListeners = new LinkedList<>();
|
||||
cursorPainters= new ArrayList<>();
|
||||
|
@ -169,7 +165,7 @@ public class WaveformCanvas extends Canvas {
|
|||
}
|
||||
|
||||
public int getMaxZoomLevel(){
|
||||
return Constants.unitMultiplier.length*Constants.unitString.length-1;
|
||||
return Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length-1;
|
||||
}
|
||||
|
||||
public void setZoomLevel(int level) {
|
||||
|
@ -181,8 +177,8 @@ public class WaveformCanvas extends Canvas {
|
|||
//FIXME: keep center if zoom-out and cursor is not in view
|
||||
long oldScaleFactor=scaleFactor;
|
||||
if(level<0) level = 0;
|
||||
if(level<Constants.unitMultiplier.length*Constants.unitString.length){
|
||||
this.scaleFactor = (long) Math.pow(10, level/2);
|
||||
if(level<Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length){
|
||||
this.scaleFactor = (long) Math.pow(10, level/2d);
|
||||
if(level%2==1) this.scaleFactor*=3;
|
||||
ITx tx = arrowPainter.getTx();
|
||||
arrowPainter.setTx(null);
|
||||
|
@ -213,17 +209,17 @@ public class WaveformCanvas extends Canvas {
|
|||
}
|
||||
|
||||
public long getScaleFactorPow10() {
|
||||
int scale = level/Constants.unitMultiplier.length;
|
||||
int scale = level/Constants.UNIT_MULTIPLIER.length;
|
||||
double res = Math.pow(1000, scale);
|
||||
return (long) res;
|
||||
}
|
||||
|
||||
public String getUnitStr(){
|
||||
return Constants.unitString[level/Constants.unitMultiplier.length];
|
||||
return Constants.UNIT_STRING[level/Constants.UNIT_MULTIPLIER.length];
|
||||
}
|
||||
|
||||
public int getUnitMultiplier(){
|
||||
return Constants.unitMultiplier[level%Constants.unitMultiplier.length];
|
||||
return Constants.UNIT_MULTIPLIER[level%Constants.UNIT_MULTIPLIER.length];
|
||||
}
|
||||
|
||||
public long getTimeForOffset(int xOffset){
|
||||
|
@ -245,7 +241,7 @@ public class WaveformCanvas extends Canvas {
|
|||
}
|
||||
|
||||
void clearAllWaveformPainter(boolean update) {
|
||||
trackAreaPainter.getTrackVerticalOffset().clear();
|
||||
trackAreaPainter.trackVerticalOffset.clear();
|
||||
wave2painterMap.clear();
|
||||
if(update) syncScrollBars();
|
||||
}
|
||||
|
@ -270,8 +266,9 @@ public class WaveformCanvas extends Canvas {
|
|||
horizontal.setEnabled(false);
|
||||
horizontal.setVisible(true);
|
||||
horizontal.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (painterList.size() == 0)
|
||||
if (painterList.isEmpty())
|
||||
return;
|
||||
setOrigin(-((ScrollBar) event.widget).getSelection(), origin.y);
|
||||
}
|
||||
|
@ -280,8 +277,9 @@ public class WaveformCanvas extends Canvas {
|
|||
vertical.setEnabled(false);
|
||||
vertical.setVisible(true);
|
||||
vertical.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (painterList.size() == 0)
|
||||
if (painterList.isEmpty())
|
||||
return;
|
||||
setOrigin(origin.x, -((ScrollBar) event.widget).getSelection());
|
||||
}
|
||||
|
@ -294,7 +292,7 @@ public class WaveformCanvas extends Canvas {
|
|||
* :<b> transform, image size, client area</b>.
|
||||
*/
|
||||
public void syncScrollBars() {
|
||||
if (painterList.size() == 0) {
|
||||
if (painterList.isEmpty()) {
|
||||
redraw();
|
||||
return;
|
||||
}
|
||||
|
@ -302,14 +300,14 @@ public class WaveformCanvas extends Canvas {
|
|||
long width = maxTime / scaleFactor;
|
||||
Rectangle clientArea=getClientArea();
|
||||
ScrollBar horizontal = getHorizontalBar();
|
||||
horizontal.setIncrement((int) (getClientArea().width / 100));
|
||||
horizontal.setIncrement(getClientArea().width / 100);
|
||||
horizontal.setPageIncrement(getClientArea().width);
|
||||
int clientWidthw = clientArea.width;
|
||||
if (width > clientWidthw) { /* image is wider than client area */
|
||||
horizontal.setMinimum(0);
|
||||
horizontal.setMaximum((int)width);
|
||||
horizontal.setEnabled(true);
|
||||
if (((int) -origin.x) > horizontal.getMaximum() - clientWidthw) {
|
||||
if (-origin.x > horizontal.getMaximum() - clientWidthw) {
|
||||
origin.x = -horizontal.getMaximum() + clientWidthw;
|
||||
}
|
||||
} else { /* image is narrower than client area */
|
||||
|
@ -319,18 +317,18 @@ public class WaveformCanvas extends Canvas {
|
|||
horizontal.setSelection(-origin.x);
|
||||
|
||||
ScrollBar vertical = getVerticalBar();
|
||||
vertical.setIncrement((int) (getClientArea().height / 100));
|
||||
vertical.setPageIncrement((int) (getClientArea().height));
|
||||
vertical.setIncrement(getClientArea().height / 100);
|
||||
vertical.setPageIncrement(getClientArea().height);
|
||||
int clientHeighth = clientArea.height;
|
||||
if (height > clientHeighth) { /* image is higher than client area */
|
||||
vertical.setMinimum(0);
|
||||
vertical.setMaximum(height);
|
||||
vertical.setEnabled(true);
|
||||
if (((int) -origin.y) > vertical.getMaximum() - clientHeighth) {
|
||||
if ( -origin.y > vertical.getMaximum() - clientHeighth) {
|
||||
origin.y = -vertical.getMaximum() + clientHeighth;
|
||||
}
|
||||
} else { /* image is less higher than client area */
|
||||
vertical.setMaximum((int) (clientHeighth));
|
||||
vertical.setMaximum(clientHeighth);
|
||||
vertical.setEnabled(false);
|
||||
}
|
||||
vertical.setThumb(clientHeighth);
|
||||
|
@ -345,10 +343,10 @@ public class WaveformCanvas extends Canvas {
|
|||
if(pt.x==0 || pt.y==0) return;
|
||||
Rectangle clientRect = getClientArea(); /* Canvas' painting area */
|
||||
GC thisGc = gc;
|
||||
Image d_backingImg = null;
|
||||
Image dBackingImg = null;
|
||||
if(doubleBuffering) {
|
||||
d_backingImg = new Image(getDisplay(), pt.x, pt.y);
|
||||
thisGc = new GC(d_backingImg);
|
||||
dBackingImg = new Image(getDisplay(), pt.x, pt.y);
|
||||
thisGc = new GC(dBackingImg);
|
||||
thisGc.setBackground(gc.getBackground());
|
||||
thisGc.setForeground(gc.getForeground());
|
||||
thisGc.setFont(gc.getFont());
|
||||
|
@ -356,7 +354,7 @@ public class WaveformCanvas extends Canvas {
|
|||
}
|
||||
Projection p = new Projection(thisGc);
|
||||
p.setTranslation(origin);
|
||||
if (painterList.size() > 0 ) {
|
||||
if (!painterList.isEmpty() ) {
|
||||
for (IPainter painter : painterList)
|
||||
painter.paintArea(p, clientRect);
|
||||
} else {
|
||||
|
@ -364,8 +362,8 @@ public class WaveformCanvas extends Canvas {
|
|||
initScrollBars();
|
||||
}
|
||||
if(doubleBuffering) {
|
||||
gc.drawImage(d_backingImg, 0, 0);
|
||||
d_backingImg.dispose();
|
||||
gc.drawImage(dBackingImg, 0, 0);
|
||||
if(dBackingImg!=null) dBackingImg.dispose();
|
||||
thisGc.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -376,7 +374,7 @@ public class WaveformCanvas extends Canvas {
|
|||
if (p instanceof TrackAreaPainter) {
|
||||
int y = point.y - origin.y;
|
||||
int x = point.x - origin.x;
|
||||
Entry<Integer, IWaveformPainter> entry = trackAreaPainter.getTrackVerticalOffset().floorEntry(y);
|
||||
Entry<Integer, IWaveformPainter> entry = trackAreaPainter.trackVerticalOffset.floorEntry(y);
|
||||
if (entry != null) {
|
||||
if (entry.getValue() instanceof StreamPainter) {
|
||||
ITx tx = ((StreamPainter) entry.getValue()).getClicked(new Point(x, y - entry.getKey()));
|
||||
|
@ -397,7 +395,7 @@ public class WaveformCanvas extends Canvas {
|
|||
public List<Object> getEntriesAtPosition(IWaveform iWaveform, int i) {
|
||||
LinkedList<Object> result=new LinkedList<>();
|
||||
int x = i - origin.x;
|
||||
for(IPainter p: wave2painterMap.values()){
|
||||
for(IWaveformPainter p: wave2painterMap.values()){
|
||||
if (p instanceof StreamPainter && ((StreamPainter)p).getStream()==iWaveform) {
|
||||
result.add(((StreamPainter) p).getClicked(new Point(x, styleProvider.getTrackHeight()/2)));
|
||||
}
|
||||
|
@ -442,10 +440,9 @@ public class WaveformCanvas extends Canvas {
|
|||
TrackEntry te = painter.getTrackEntry();
|
||||
if(te.waveform == waveform) {
|
||||
Point size = getSize();
|
||||
//size.x -= getVerticalBar().getSize().x + 2;
|
||||
size.y -=+rulerHeight;
|
||||
ScrollBar sb = getHorizontalBar();
|
||||
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())
|
||||
size.y-= getHorizontalBar().getSize().y;
|
||||
int top = te.vOffset;
|
||||
int bottom = top + styleProvider.getTrackHeight();
|
||||
|
|
|
@ -93,7 +93,7 @@ import com.minres.scviewer.database.ui.swt.Constants;
|
|||
|
||||
public class WaveformView implements IWaveformView {
|
||||
|
||||
private ListenerList<ISelectionChangedListener> selectionChangedListeners = new ListenerList<ISelectionChangedListener>();
|
||||
private ListenerList<ISelectionChangedListener> selectionChangedListeners = new ListenerList<>();
|
||||
|
||||
private PropertyChangeSupport pcs;
|
||||
|
||||
|
@ -109,9 +109,9 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
private Control namePaneHeader;
|
||||
|
||||
final private Canvas nameList;
|
||||
private final Canvas nameList;
|
||||
|
||||
final private Canvas valueList;
|
||||
private final Canvas valueList;
|
||||
|
||||
final WaveformCanvas waveformCanvas;
|
||||
|
||||
|
@ -170,7 +170,8 @@ public class WaveformView implements IWaveformView {
|
|||
};
|
||||
|
||||
class WaveformMouseListener implements PaintListener, Listener {
|
||||
Point start, end;
|
||||
Point start;
|
||||
Point end;
|
||||
List<Object> initialSelected;
|
||||
boolean down=false;
|
||||
|
||||
|
@ -181,9 +182,9 @@ public class WaveformView implements IWaveformView {
|
|||
gc.setAlpha(128);
|
||||
int minX = Math.min(start.x, end.x);
|
||||
int width = Math.max(start.x, end.x) - minX;
|
||||
int y_top = waveformCanvas.getRulerHeight();
|
||||
int y_bottom = waveformCanvas.getSize().y;
|
||||
gc.fillRectangle(minX, y_top, width,y_bottom);
|
||||
int yTop = waveformCanvas.getRulerHeight();
|
||||
int yBottom = waveformCanvas.getSize().y;
|
||||
gc.fillRectangle(minX, yTop, width,yBottom);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +201,7 @@ public class WaveformView implements IWaveformView {
|
|||
if(targetTimeRange==0) return;
|
||||
long relation = currentTimeRange/targetTimeRange;
|
||||
long i = 1;
|
||||
int level=0;//relation>0?0:0;
|
||||
int level=0;
|
||||
do {
|
||||
if(relation<0 ) {
|
||||
if(-relation<i) {
|
||||
|
@ -247,7 +248,8 @@ public class WaveformView implements IWaveformView {
|
|||
long time= waveformCanvas.getTimeForOffset(p.x);
|
||||
long scaling=5*waveformCanvas.getScaleFactor();
|
||||
for(Object o:waveformCanvas.getElementsAt(p)){
|
||||
Entry<Long, ?> floorEntry=null, ceilEntry=null;
|
||||
Entry<Long, IEvent[]> floorEntry=null;
|
||||
Entry<Long, IEvent[]> ceilEntry=null;
|
||||
if(o instanceof TrackEntry){
|
||||
TrackEntry entry = (TrackEntry) o;
|
||||
NavigableMap<Long, IEvent[]> map = entry.waveform.getEvents();
|
||||
|
@ -293,9 +295,6 @@ public class WaveformView implements IWaveformView {
|
|||
case SWT.MouseUp:
|
||||
mouseUp(new MouseEvent(e));
|
||||
break;
|
||||
//case SWT.MouseDoubleClick:
|
||||
//mouseDoubleClick(new MouseEvent(e));
|
||||
//break;
|
||||
case SWT.MouseMove:
|
||||
if(down) {
|
||||
end=new Point(e.x, e.y);
|
||||
|
@ -308,7 +307,7 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
protected WaveformMouseListener waveformMouseListener = new WaveformMouseListener();
|
||||
|
||||
public WaveformView(Composite parent, IWaveformStyleProvider styleProvider) {
|
||||
|
@ -316,7 +315,7 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
pcs=new PropertyChangeSupport(this);
|
||||
|
||||
trackVerticalOffset = new TreeMap<Integer, TrackEntry>();
|
||||
trackVerticalOffset = new TreeMap<>();
|
||||
tracksVerticalHeight=0;
|
||||
|
||||
streams = new ObservableList<>();
|
||||
|
@ -363,14 +362,11 @@ public class WaveformView implements IWaveformView {
|
|||
return new Point(bounds.width, bounds.height);
|
||||
}
|
||||
};
|
||||
nameList.addListener(SWT.Paint, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
if(!trackVerticalOffset.isEmpty()) {
|
||||
GC gc = event.gc;
|
||||
Rectangle rect = ((Canvas) event.widget).getClientArea();
|
||||
paintNames(gc, rect);
|
||||
}
|
||||
nameList.addListener(SWT.Paint, (Event event) -> {
|
||||
if(!trackVerticalOffset.isEmpty()) {
|
||||
GC gc = event.gc;
|
||||
Rectangle rect = ((Canvas) event.widget).getClientArea();
|
||||
paintNames(gc, rect);
|
||||
}
|
||||
});
|
||||
nameList.addMouseListener(nameValueMouseListener);
|
||||
|
@ -398,14 +394,11 @@ public class WaveformView implements IWaveformView {
|
|||
return new Point(bounds.width, bounds.height);
|
||||
}
|
||||
};
|
||||
valueList.addListener(SWT.Paint, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
if(!trackVerticalOffset.isEmpty()) {
|
||||
GC gc = event.gc;
|
||||
Rectangle rect = ((Canvas) event.widget).getClientArea();
|
||||
paintValues(gc, rect);
|
||||
}
|
||||
valueList.addListener(SWT.Paint, (Event event) -> {
|
||||
if(!trackVerticalOffset.isEmpty()) {
|
||||
GC gc = event.gc;
|
||||
Rectangle rect = ((Canvas) event.widget).getClientArea();
|
||||
paintValues(gc, rect);
|
||||
}
|
||||
});
|
||||
valueList.addMouseListener(nameValueMouseListener);
|
||||
|
@ -415,11 +408,11 @@ public class WaveformView implements IWaveformView {
|
|||
waveformCanvas.addPaintListener(waveformMouseListener);
|
||||
waveformCanvas.addListener(SWT.MouseDown,waveformMouseListener);
|
||||
waveformCanvas.addListener(SWT.MouseUp,waveformMouseListener);
|
||||
//waveformCanvas.addListener(SWT.MouseDoubleClick,waveformMouseListener);
|
||||
waveformCanvas.addListener(SWT.MouseMove,waveformMouseListener);
|
||||
waveformCanvas.addListener(SWT.MouseWheel, waveformMouseListener);
|
||||
|
||||
nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int y = ((ScrollBar) e.widget).getSelection();
|
||||
Point v = valueListScrolled.getOrigin();
|
||||
|
@ -429,6 +422,7 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
});
|
||||
valueListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int y = ((ScrollBar) e.widget).getSelection();
|
||||
nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y);
|
||||
|
@ -436,6 +430,7 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
});
|
||||
waveformCanvas.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int y = waveformCanvas.getVerticalBar().getSelection();
|
||||
nameListScrolled.setOrigin(nameListScrolled.getOrigin().x, y);
|
||||
|
@ -457,48 +452,40 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
|
||||
private void createTextPane(Composite namePane, String text) {
|
||||
GridLayout gl_namePane = new GridLayout(1, false);
|
||||
gl_namePane.verticalSpacing = 0;
|
||||
gl_namePane.marginWidth = 0;
|
||||
gl_namePane.horizontalSpacing = 0;
|
||||
gl_namePane.marginHeight = 0;
|
||||
namePane.setLayout(gl_namePane);
|
||||
GridLayout glNamePane = new GridLayout(1, false);
|
||||
glNamePane.verticalSpacing = 0;
|
||||
glNamePane.marginWidth = 0;
|
||||
glNamePane.horizontalSpacing = 0;
|
||||
glNamePane.marginHeight = 0;
|
||||
namePane.setLayout(glNamePane);
|
||||
|
||||
CLabel nameLabel = new CLabel(namePane, SWT.NONE);
|
||||
GridData gd_nameLabel = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
|
||||
gd_nameLabel.heightHint = waveformCanvas.getRulerHeight() - 2;
|
||||
nameLabel.setLayoutData(gd_nameLabel);
|
||||
GridData gdNameLabel = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
|
||||
gdNameLabel.heightHint = waveformCanvas.getRulerHeight() - 2;
|
||||
nameLabel.setLayoutData(gdNameLabel);
|
||||
nameLabel.setText(text);
|
||||
|
||||
Label nameSep = new Label(namePane, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
nameSep.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY));
|
||||
nameSep.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
|
||||
GridData gd_nameSep = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
|
||||
gd_nameSep.heightHint = 2;
|
||||
nameSep.setLayoutData(gd_nameSep);
|
||||
GridData gdNameSep = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
|
||||
gdNameSep.heightHint = 2;
|
||||
nameSep.setLayoutData(gdNameSep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent pce) {
|
||||
if ("size".equals(pce.getPropertyName()) || "content".equals(pce.getPropertyName())) {
|
||||
if(revealSelected) {
|
||||
waveformCanvas.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
waveformCanvas.getDisplay().asyncExec(() ->{
|
||||
update();
|
||||
currentWaveformSelection.stream().forEach(e -> waveformCanvas.reveal(e.waveform));
|
||||
valueList.redraw();
|
||||
nameList.redraw();
|
||||
}
|
||||
});
|
||||
revealSelected=false;
|
||||
} else
|
||||
waveformCanvas.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
update();
|
||||
}
|
||||
});
|
||||
waveformCanvas.getDisplay().asyncExec(WaveformView.this::update);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,7 +549,6 @@ public class WaveformView implements IWaveformView {
|
|||
if(bv.getWidth()==1)
|
||||
entry.currentValue="b'"+bv;
|
||||
else {
|
||||
// TODO: same code resides in SignalPainter, fix it
|
||||
switch(entry.valueDisplay) {
|
||||
case SIGNED:
|
||||
entry.currentValue=Long.toString(bv.toSignedValue());
|
||||
|
@ -597,15 +583,15 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
firstTx=entry.waveform.getEvents().lowerEntry(firstTx.getKey());
|
||||
}while(firstTx!=null && !isArrayFull(resultsList));
|
||||
entry.currentValue="";
|
||||
boolean separator=false;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(ITx o:resultsList){
|
||||
if(separator) entry.currentValue+="|";
|
||||
if(o!=null) entry.currentValue+=((ITx)o).getGenerator().getName();
|
||||
|
||||
if(separator) sb.append("|");
|
||||
if(o!=null) sb.append(o.getGenerator().getName());
|
||||
separator=true;
|
||||
}
|
||||
entry.currentValue=sb.toString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -680,7 +666,6 @@ public class WaveformView implements IWaveformView {
|
|||
if (currentTxSelection != null) {
|
||||
sel.add(currentTxSelection);
|
||||
}
|
||||
// sel.addAll(currentWaveformSelection.stream().map(e -> e.waveform).collect(Collectors.toList()));
|
||||
sel.addAll(currentWaveformSelection);
|
||||
return new StructuredSelection(sel.toArray());
|
||||
}
|
||||
|
@ -736,7 +721,7 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (currentTxSelection != null || currentWaveformSelection.size() > 0)
|
||||
if (currentTxSelection != null || !currentWaveformSelection.isEmpty())
|
||||
selectionChanged = true;
|
||||
currentTxSelection = null;
|
||||
currentWaveformSelection.clear();
|
||||
|
@ -864,13 +849,12 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
private ITxRelation selectTxToNavigateTo(Collection<ITxRelation> rel, RelationType relationType, boolean target) {
|
||||
ArrayList<ITxRelation> candidates = rel.stream().filter(r -> relationType.equals(r.getRelationType())).collect(Collectors.toCollection(ArrayList::new));
|
||||
//new RelSelectionDialog(waveformCanvas.getShell(), candidates, target).open();
|
||||
switch (candidates.size()) {
|
||||
case 0: return null;
|
||||
case 1: return candidates.get(0);
|
||||
default:
|
||||
ArrayList<ITxRelation> visibleCandidates = candidates.stream().filter(r -> streamsVisible(r)).collect(Collectors.toCollection(ArrayList::new));
|
||||
if(visibleCandidates.size()==0) {
|
||||
ArrayList<ITxRelation> visibleCandidates = candidates.stream().filter(this::streamsVisible).collect(Collectors.toCollection(ArrayList::new));
|
||||
if(visibleCandidates.isEmpty()) {
|
||||
return new RelSelectionDialog(waveformCanvas.getShell(), candidates, target).open();
|
||||
} else if(visibleCandidates.size()==1) {
|
||||
return visibleCandidates.size()==1?visibleCandidates.get(0):null;
|
||||
|
@ -895,9 +879,7 @@ public class WaveformView implements IWaveformView {
|
|||
TrackEntry sel = currentWaveformSelection.get(0);
|
||||
long time = getCursorTime();
|
||||
NavigableMap<Long, ?> map=null;
|
||||
if(sel.waveform.getType()==WaveformType.TRANSACTION){
|
||||
map=sel.waveform.getEvents();
|
||||
} else if(sel.waveform.getType()==WaveformType.SIGNAL){
|
||||
if(sel.waveform.getType()==WaveformType.TRANSACTION || sel.waveform.getType()==WaveformType.SIGNAL){
|
||||
map=sel.waveform.getEvents();
|
||||
}
|
||||
if(map!=null){
|
||||
|
@ -925,12 +907,12 @@ public class WaveformView implements IWaveformView {
|
|||
*/
|
||||
@Override
|
||||
public void deleteSelectedTracks() {
|
||||
List<TrackEntry> streams = getStreamList();
|
||||
List<TrackEntry> streamList = getStreamList();
|
||||
for (Object o : (IStructuredSelection)getSelection()) {
|
||||
if(o instanceof TrackEntry) {
|
||||
TrackEntry e = (TrackEntry) o;
|
||||
e.selected=false;
|
||||
streams.remove(e);
|
||||
streamList.remove(e);
|
||||
}
|
||||
}
|
||||
setSelection(new StructuredSelection());
|
||||
|
@ -941,7 +923,7 @@ public class WaveformView implements IWaveformView {
|
|||
*/
|
||||
@Override
|
||||
public void moveSelectedTrack(int i) {
|
||||
if(currentWaveformSelection.size()>0){
|
||||
if(!currentWaveformSelection.isEmpty()){
|
||||
int idx = streams.indexOf(currentWaveformSelection.get(0));
|
||||
for(Object o: currentWaveformSelection)
|
||||
streams.remove(o);
|
||||
|
@ -956,14 +938,14 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
|
||||
protected void paintNames(GC gc, Rectangle rect) {
|
||||
if (streams.size() > 0) {
|
||||
if (!streams.isEmpty()) {
|
||||
try {
|
||||
Integer firstKey = trackVerticalOffset.floorKey(rect.y);
|
||||
if (firstKey == null)
|
||||
firstKey = trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, styleProvider.getTrackHeight());
|
||||
if (lastKey == firstKey) {
|
||||
if (lastKey.equals(firstKey)) {
|
||||
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
||||
IWaveform w = trackEntry.waveform;
|
||||
if (w.getType()==WaveformType.TRANSACTION)
|
||||
|
@ -983,14 +965,14 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
|
||||
protected void paintValues(GC gc, Rectangle rect) {
|
||||
if (streams.size() > 0) {
|
||||
if (!streams.isEmpty()) {
|
||||
try {
|
||||
Integer firstKey = trackVerticalOffset.floorKey(rect.y);
|
||||
if (firstKey == null)
|
||||
firstKey = trackVerticalOffset.firstKey();
|
||||
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
|
||||
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, styleProvider.getTrackHeight());
|
||||
if (lastKey == firstKey) {
|
||||
if (lastKey.equals(firstKey)) {
|
||||
TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
|
||||
IWaveform w = trackEntry.waveform;
|
||||
if (w.getType()==WaveformType.TRANSACTION)
|
||||
|
@ -1131,13 +1113,14 @@ public class WaveformView implements IWaveformView {
|
|||
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
|
||||
dragSource.setTransfer(types);
|
||||
dragSource.addDragListener(new DragSourceAdapter() {
|
||||
@Override
|
||||
public void dragStart(DragSourceEvent event) {
|
||||
if (event.y < tracksVerticalHeight) {
|
||||
event.doit = true;
|
||||
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(currentWaveformSelection));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragSetData(DragSourceEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
|
||||
event.data =getSelection();
|
||||
|
@ -1153,10 +1136,11 @@ public class WaveformView implements IWaveformView {
|
|||
|
||||
dropTarget.addDropListener(new DropTargetAdapter() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void drop(DropTargetEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){
|
||||
ISelection s = LocalSelectionTransfer.getTransfer().getSelection();
|
||||
if(s!=null && s instanceof IStructuredSelection){
|
||||
if(s instanceof IStructuredSelection){
|
||||
IStructuredSelection sel = (IStructuredSelection) s;
|
||||
for(Object o: sel.toList())
|
||||
streams.remove(o);
|
||||
|
@ -1173,7 +1157,7 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAccept(DropTargetEvent event) {
|
||||
if (event.detail != DND.DROP_MOVE) {
|
||||
event.detail = DND.DROP_NONE;
|
||||
|
@ -1197,6 +1181,7 @@ public class WaveformView implements IWaveformView {
|
|||
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
|
||||
dragSource.setTransfer(types);
|
||||
dragSource.addDragListener(new DragSourceAdapter() {
|
||||
@Override
|
||||
public void dragStart(DragSourceEvent event) {
|
||||
event.doit = false;
|
||||
List<Object> clicked = waveformCanvas.getElementsAt(new Point(event.x, event.y));
|
||||
|
@ -1209,13 +1194,22 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragSetData(DragSourceEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
|
||||
event.data=waveformCanvas.getElementsAt(new Point(event.x, event.y));
|
||||
}
|
||||
}
|
||||
});
|
||||
// int style = SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
|
||||
// final StyledText text = new StyledText(waveformCanvas, style);
|
||||
// text.setText("Dragging");
|
||||
// dragSource.setDragSourceEffect(new DragSourceEffect(text) {
|
||||
// @Override
|
||||
// public void dragStart(DragSourceEvent event) {
|
||||
// event.image = waveformCanvas.getDisplay().getSystemImage(SWT.ICON_WARNING);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private void createWaveformDropTarget(final Canvas canvas) {
|
||||
|
@ -1223,10 +1217,11 @@ public class WaveformView implements IWaveformView {
|
|||
DropTarget dropTarget = new DropTarget(canvas, DND.DROP_MOVE);
|
||||
dropTarget.setTransfer(types);
|
||||
dropTarget.addDropListener(new DropTargetAdapter() {
|
||||
@Override
|
||||
public void drop(DropTargetEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){
|
||||
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
|
||||
if(sel!=null && sel instanceof IStructuredSelection &&
|
||||
if(sel instanceof IStructuredSelection &&
|
||||
((IStructuredSelection)sel).getFirstElement() instanceof CursorPainter){
|
||||
CursorPainter painter = (CursorPainter)((IStructuredSelection)sel).getFirstElement();
|
||||
painter.setDragging(false);
|
||||
|
@ -1234,17 +1229,17 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAccept(DropTargetEvent event) {
|
||||
Point offset = canvas.toControl(event.x, event.y);
|
||||
if (event.detail != DND.DROP_MOVE || offset.y > trackVerticalOffset.lastKey() + styleProvider.getTrackHeight()) {
|
||||
event.detail = DND.DROP_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragOver(DropTargetEvent event){
|
||||
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
|
||||
if(sel!=null && sel instanceof IStructuredSelection &&
|
||||
if(sel instanceof IStructuredSelection &&
|
||||
((IStructuredSelection)sel).getFirstElement() instanceof CursorPainter){
|
||||
updateWaveform(canvas, event, (CursorPainter) ((IStructuredSelection)sel).getFirstElement());
|
||||
}
|
||||
|
@ -1261,13 +1256,10 @@ public class WaveformView implements IWaveformView {
|
|||
pcs.firePropertyChange(MARKER_PROPERTY, oldVal, time);
|
||||
pcs.firePropertyChange(MARKER_PROPERTY+painter.id, oldVal, time);
|
||||
}
|
||||
canvas.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(!canvas.isDisposed()){
|
||||
canvas.redraw();
|
||||
updateValueList();
|
||||
}
|
||||
canvas.getDisplay().asyncExec(() -> {
|
||||
if(!canvas.isDisposed()){
|
||||
canvas.redraw();
|
||||
updateValueList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1325,8 +1317,8 @@ public class WaveformView implements IWaveformView {
|
|||
@Override
|
||||
public String getScaledTime(long time) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Double dTime=new Double(time);
|
||||
Double scaledTime = dTime/waveformCanvas.getScaleFactorPow10();
|
||||
double dTime=time;
|
||||
double scaledTime = dTime/waveformCanvas.getScaleFactorPow10();
|
||||
return sb.append(df.format(scaledTime)).append(waveformCanvas.getUnitStr()).toString();
|
||||
}
|
||||
|
||||
|
@ -1335,11 +1327,11 @@ public class WaveformView implements IWaveformView {
|
|||
*/
|
||||
@Override
|
||||
public String[] getZoomLevels(){
|
||||
String[] res = new String[Constants.unitMultiplier.length*Constants.unitString.length];
|
||||
String[] res = new String[Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length];
|
||||
int index=0;
|
||||
for(String unit:Constants.unitString){
|
||||
for(int factor:Constants.unitMultiplier){
|
||||
res[index++]= new Integer(factor).toString()+unit;
|
||||
for(String unit:Constants.UNIT_STRING){
|
||||
for(int factor:Constants.UNIT_MULTIPLIER){
|
||||
res[index++]= Integer.toString(factor)+unit;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
@ -1368,12 +1360,9 @@ public class WaveformView implements IWaveformView {
|
|||
}
|
||||
|
||||
public void asyncUpdate(Widget widget) {
|
||||
widget.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
waveformCanvas.redraw();
|
||||
updateValueList();
|
||||
}
|
||||
widget.getDisplay().asyncExec(() -> {
|
||||
waveformCanvas.redraw();
|
||||
updateValueList();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1093,7 +1093,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
|
||||
boolean foundZoom=false;
|
||||
//try to find existing zoomlevel where scaleFactor*clientAreaWidth >= maxTime, if one is found set it as new zoomlevel
|
||||
for (int level=0; level<Constants.unitMultiplier.length*Constants.unitString.length; level++){
|
||||
for (int level=0; level<Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length; level++){
|
||||
long scaleFactor = (long) Math.pow(10, level/2);
|
||||
if(level%2==1) scaleFactor*=3;
|
||||
if(scaleFactor*clientAreaWidth >= maxTime) {
|
||||
|
@ -1103,7 +1103,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
}
|
||||
}
|
||||
//if no zoom level is found, set biggest one available
|
||||
if(!foundZoom) setZoomLevel(Constants.unitMultiplier.length*Constants.unitString.length-1);
|
||||
if(!foundZoom) setZoomLevel(Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length-1);
|
||||
|
||||
updateAll();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue