fix display bug

This commit is contained in:
Eyck Jentzsch 2021-02-17 20:24:25 +00:00
parent 5604c3ee5e
commit 156abe63cd
7 changed files with 27 additions and 22 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ SCViewer_1.png
copyrightLog.txt copyrightLog.txt
/workspace /workspace
?*.launch ?*.launch
/.settings/

View File

@ -1,4 +0,0 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View File

@ -38,7 +38,7 @@ public class ArrowPainter implements IPainter {
private int yCtrlOffset = 30; private int yCtrlOffset = 30;
private WaveformCanvas waveCanvas; private final WaveformCanvas waveCanvas;
private ITx tx; private ITx tx;
@ -54,8 +54,6 @@ public class ArrowPainter implements IPainter {
long scaleFactor; long scaleFactor;
boolean deferUpdate;
public ArrowPainter(WaveformCanvas waveCanvas, RelationType relationType) { public ArrowPainter(WaveformCanvas waveCanvas, RelationType relationType) {
this.waveCanvas = waveCanvas; this.waveCanvas = waveCanvas;
highlightType=relationType; highlightType=relationType;
@ -90,15 +88,15 @@ public class ArrowPainter implements IPainter {
return res.isPresent()? res.get():0; return res.isPresent()? res.get():0;
} }
protected void calculateGeometries() { protected boolean calculateGeometries() {
deferUpdate = false;
iRect.clear(); iRect.clear();
oRect.clear(); oRect.clear();
IWaveformPainter painter = waveCanvas.wave2painterMap.get(tx.getStream()); IWaveformPainter painter = waveCanvas.wave2painterMap.get(tx.getStream());
if(painter == null)
painter = waveCanvas.wave2painterMap.get(tx.getGenerator());
if (painter == null) { // stream has been added but painter not yet if (painter == null) { // stream has been added but painter not yet
// created // created
deferUpdate = true; return true;
return;
} }
int laneHeight = painter.getHeight() / tx.getStream().getRowCount(); int laneHeight = painter.getHeight() / tx.getStream().getRowCount();
txRectangle = new Rectangle((int) (tx.getBeginTime() / scaleFactor), txRectangle = new Rectangle((int) (tx.getBeginTime() / scaleFactor),
@ -106,6 +104,7 @@ public class ArrowPainter implements IPainter {
(int) ((tx.getEndTime() - tx.getBeginTime()) / scaleFactor), laneHeight); (int) ((tx.getEndTime() - tx.getBeginTime()) / scaleFactor), laneHeight);
deriveGeom(tx.getIncomingRelations(), iRect, false); deriveGeom(tx.getIncomingRelations(), iRect, false);
deriveGeom(tx.getOutgoingRelations(), oRect, true); deriveGeom(tx.getOutgoingRelations(), oRect, true);
return false;
} }
protected void deriveGeom(Collection<ITxRelation> relations, List<LinkEntry> res, boolean useTarget) { protected void deriveGeom(Collection<ITxRelation> relations, List<LinkEntry> res, boolean useTarget) {
@ -160,11 +159,9 @@ public class ArrowPainter implements IPainter {
Color highliteColor = waveCanvas.styleProvider.getColor(WaveformColors.REL_ARROW_HIGHLITE); Color highliteColor = waveCanvas.styleProvider.getColor(WaveformColors.REL_ARROW_HIGHLITE);
if(tx==null) return; if(tx==null) return;
if (!deferUpdate) { scaleFactor = waveCanvas.getScaleFactor();
scaleFactor = waveCanvas.getScaleFactor(); if(calculateGeometries())
calculateGeometries(); return;
}
if(deferUpdate) return;
int correctionValue = (int)(selectionOffset); int correctionValue = (int)(selectionOffset);
Rectangle correctedTargetRectangle = new Rectangle(txRectangle.x+correctionValue, txRectangle.y, txRectangle.width, txRectangle.height); Rectangle correctedTargetRectangle = new Rectangle(txRectangle.x+correctionValue, txRectangle.y, txRectangle.width, txRectangle.height);
for (LinkEntry entry : iRect) { for (LinkEntry entry : iRect) {

View File

@ -19,7 +19,7 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.wb.swt.SWTResourceManager; import org.eclipse.wb.swt.SWTResourceManager;
public class RulerPainter implements IPainter { public class RulerPainter implements IPainter {
protected WaveformCanvas waveCanvas; protected final WaveformCanvas waveCanvas;
static final int RULER_TICK_MINOR = 10; static final int RULER_TICK_MINOR = 10;
static final int RULER_TICK_MAJOR = 100; static final int RULER_TICK_MAJOR = 100;

View File

@ -46,8 +46,16 @@ public class StreamPainter extends TrackPainter{
} }
public void paintArea(Projection proj, Rectangle area) { public void paintArea(Projection proj, Rectangle area) {
if(stream.getEvents().size()==0) return;
int trackHeight=trackEntry.height/stream.getRowCount(); int trackHeight=trackEntry.height/stream.getRowCount();
if(stream.getEvents().size()==0) {
proj.setFillRule(SWT.FILL_EVEN_ODD);
proj.setLineStyle(SWT.LINE_SOLID);
proj.setLineWidth(1);
proj.setForeground(this.waveCanvas.styleProvider.getColor(WaveformColors.LINE));
for( int y1=area.y+trackHeight/2; y1<area.y+trackEntry.height; y1+=trackHeight)
proj.drawLine(area.x, y1, area.x+area.width, y1);
return;
}
txBase=trackHeight/5; txBase=trackHeight/5;
txHeight=trackHeight*3/5; txHeight=trackHeight*3/5;
if(trackEntry.selected) { if(trackEntry.selected) {

View File

@ -179,10 +179,10 @@ public class WaveformCanvas extends Canvas {
public void setZoomLevel(int level, long centerTime) { public void setZoomLevel(int level, long centerTime) {
//FIXME: keep center if zoom-out and cursor is not in view //FIXME: keep center if zoom-out and cursor is not in view
long oldScaleFactor=scaleFactor;
if(level<0) level = 0; if(level<0) level = 0;
long xc=centerTime/this.scaleFactor; // cursor total x-offset
if(level<Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length){ if(level<Constants.UNIT_MULTIPLIER.length*Constants.UNIT_STRING.length){
this.scaleFactor = (long) Math.pow(10, level/2d); this.scaleFactor = (long) Math.pow(10, level>>1);
if(level%2==1) this.scaleFactor*=3; if(level%2==1) this.scaleFactor*=3;
ITx tx = arrowPainter.getTx(); ITx tx = arrowPainter.getTx();
arrowPainter.setTx(null); arrowPainter.setTx(null);
@ -192,7 +192,6 @@ public class WaveformCanvas extends Canvas {
* xcn = tc/newScaleFactor * xcn = tc/newScaleFactor
* t0n = (xcn-xoffs)*scaleFactor * t0n = (xcn-xoffs)*scaleFactor
*/ */
long xc=centerTime/oldScaleFactor; // cursor total x-offset
long xoffs=xc+origin.x; // cursor offset relative to left border long xoffs=xc+origin.x; // cursor offset relative to left border
long xcn=centerTime/scaleFactor; // new total x-offset long xcn=centerTime/scaleFactor; // new total x-offset
long originX=xcn-xoffs; long originX=xcn-xoffs;

View File

@ -337,7 +337,11 @@ public class FileBrowserDialog extends TrayDialog {
if(f instanceof File) { if(f instanceof File) {
if(matchers.isEmpty()) return true; if(matchers.isEmpty()) return true;
for (PathMatcher m : matchers) { for (PathMatcher m : matchers) {
try {
if(m.matches(((File)f).toPath())) return true; if(m.matches(((File)f).toPath())) return true;
} catch (Exception e) {
return false;
}
} }
} }
return false; return false;