From bee4e181ec5e773444de9ac85ef4e9fc6ca99ed6 Mon Sep 17 00:00:00 2001 From: kiramt Date: Tue, 15 Aug 2017 11:48:33 +0100 Subject: [PATCH] JAL-2265 turn off NPE --- src/jalview/gui/SeqCanvas.java | 12 ++++++++++-- src/jalview/gui/SeqPanel.java | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index a134afa..edb41e6 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -820,8 +820,10 @@ public class SeqCanvas extends JComponent implements ViewportListenerI for (i = startSeq; i <= endSeq; i++) { + // position of start residue of group relative to startRes, in pixels sx = (group.getStartRes() - startRes) * charWidth; sy = offset + ((i - startSeq) * charHeight); + // width of group in pixels ex = (((group.getEndRes() + 1) - group.getStartRes()) * charWidth) - 1; if (sx + ex < 0 || sx > visWidth) @@ -870,11 +872,15 @@ public class SeqCanvas extends JComponent implements ViewportListenerI { if (inGroup) { + // if start position is visible, draw vertical line to left of + // group if (sx >= 0 && sx < visWidth) { g.drawLine(sx, oldY, sx, sy); } + // if end position is visible, draw vertical line to right of + // group if (sx + ex < visWidth) { g.drawLine(sx + ex, oldY, sx + ex, sy); @@ -882,8 +888,8 @@ public class SeqCanvas extends JComponent implements ViewportListenerI if (sx < 0) { - ex += sx; - sx = 0; + // ex += sx; + // sx = 0; } if (sx + ex > visWidth) @@ -896,12 +902,14 @@ public class SeqCanvas extends JComponent implements ViewportListenerI ex = (endRes - startRes + 1) * charWidth; } + // draw horizontal line at top of group if (top != -1) { g.drawLine(sx, top, sx + ex, top); top = -1; } + // draw horizontal line at bottom of group if (bottom != -1) { g.drawLine(sx, bottom, sx + ex, bottom); diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 26096e6..2daa157 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -1940,7 +1940,7 @@ public class SeqPanel extends JPanel implements MouseListener, scrollThread.setEvent(evt); } - seqCanvas.repaint(); + // seqCanvas.repaint(); } void scrollCanvas(MouseEvent evt) -- 1.7.10.2