X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FScalePanel.java;h=aedb15790680f89c891aa79e49da177313936e54;hb=2303177fbc4c86e4a63c1e8efa8c8bc50516b6a5;hp=41de58fbf7d816eab808702194d78feb7b5160fb;hpb=669bd979e7fbfeaff2a48d1c335cdb5cd2d32902;p=jalview.git diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 41de58f..aedb157 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -39,7 +39,6 @@ import java.awt.event.MouseMotionListener; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; /** @@ -107,7 +106,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, min = res; max = res; - if (SwingUtilities.isRightMouseButton(evt)) + if (evt.isPopupTrigger()) { rightMouseButtonPressed(evt, res); } @@ -493,25 +492,67 @@ public class ScalePanel extends JPanel implements MouseMotionListener, gg.setColor(Color.black); int scalestartx = (startx / 10) * 10; + + SequenceI refSeq = av.getAlignment().getSeqrep(); + int refSp = 0, refEp = -1, refStart = 0, refEnd = -1, refStartI = 0, refEndI = -1; + if (refSeq != null) + { + // find bounds and set origin appopriately + // locate first visible position for this sequence + int[] refbounds = av.getColumnSelection() + .locateVisibleBoundsOfSequence(refSeq); + + refSp = refbounds[0]; + refEp = refbounds[1]; + refStart = refbounds[2]; + refEnd = refbounds[3]; + refStartI = refbounds[4]; + refEndI = refbounds[5]; + scalestartx = refSp + ((scalestartx - refSp) / 10) * 10; + } + + int widthx = 1 + endx - startx; FontMetrics fm = gg.getFontMetrics(av.getFont()); int y = avCharHeight - fm.getDescent(); - if ((scalestartx % 10) == 0) + if (refSeq == null && scalestartx % 10 == 0) { scalestartx += 5; } String string; - int maxX = 0; - + int maxX = 0, refN, iadj; + // todo: add a 'reference origin column' to set column number relative to for (int i = scalestartx; i < endx; i += 5) { - if ((i % 10) == 0) + if (((i - refSp) % 10) == 0) { - string = String.valueOf(av.getColumnSelection() - .adjustForHiddenColumns(i)); + iadj = av.getColumnSelection().adjustForHiddenColumns(i) - 1; + if (refSeq == null) + { + string = String.valueOf(iadj + 1); + } + else + { + refN = refSeq.findPosition(iadj); + // TODO show bounds if position is a gap + // - ie L--R -> "1L|2R" for + // marker + if (iadj < refStartI) + { + string = String.valueOf(iadj - refStartI); + } + else if (iadj > refEndI) + { + string = "+" + String.valueOf(iadj - refEndI); + } + else + { + string = String.valueOf(refN) + refSeq.getCharAt(iadj); + } + } if ((i - startx - 1) * avCharWidth > maxX) { gg.drawString(string, (i - startx - 1) * avCharWidth, y);