From 3cd893e800be2ae4548bf309b31a955947319a34 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 28 Jul 2006 16:06:33 +0000 Subject: [PATCH] findSeq in SeqPanel is used --- src/jalview/gui/IdPanel.java | 79 ++++------------------------------------- src/jalview/gui/SeqPanel.java | 12 +++---- 2 files changed, 10 insertions(+), 81 deletions(-) diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index f5e0f2f..47f43d5 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -69,15 +69,8 @@ public class IdPanel extends JPanel implements MouseListener, */ public void mouseMoved(MouseEvent e) { - int y = e.getY(); - - if (av.getWrapAlignment()) - { - y = getWrappedY(y); - } - - final int seq = av.getIndex(y); - if(seq!=-1) + int seq = Math.max(0, alignPanel.seqPanel.findSeq(e)); + if(seq>-1 && seq"); @@ -122,16 +115,6 @@ public class IdPanel extends JPanel implements MouseListener, } - int getWrappedY(int y) - { - int hgap = av.charHeight; - if (av.scaleAboveWrapped) - hgap += av.charHeight; - - return y - hgap; - } - - /** * DOCUMENT ME! * @@ -141,19 +124,7 @@ public class IdPanel extends JPanel implements MouseListener, { mouseDragging = true; - int y = e.getY(); - - if (av.getWrapAlignment()) - { - y = getWrappedY(y); - } - - int seq = av.getIndex(y); - - if (seq < 0) - { - return; - } + int seq = Math.max(0, alignPanel.seqPanel.findSeq(e)); if (seq < lastid) { @@ -183,17 +154,9 @@ public class IdPanel extends JPanel implements MouseListener, if (links == null || links.size() < 1) return; - int y = e.getY(); - - if (av.getWrapAlignment()) - { - y = getWrappedY(y); - } + int seq = alignPanel.seqPanel.findSeq(e); //DEFAULT LINK IS FIRST IN THE LINK LIST - int seq = av.getIndex(y); - if(seq==-1) - return; String id = av.getAlignment().getSequenceAt(seq).getName(); if (id.indexOf("|") > -1) @@ -269,49 +232,20 @@ public class IdPanel extends JPanel implements MouseListener, return; } - int y = e.getY(); - - if (av.getWrapAlignment()) - { - y = getWrappedY(y); - } - - int seq = av.getIndex(y); + int seq = alignPanel.seqPanel.findSeq(e); - if (seq == -1) - { - return; - } if (javax.swing.SwingUtilities.isRightMouseButton(e)) { jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(alignPanel, (Sequence) av.getAlignment().getSequenceAt(seq), Preferences.sequenceURLLinks); - pop.show(this, e.getX(), y); + pop.show(this, e.getX(), e.getY()); return; } - /* if (!e.isControlDown() && !e.isShiftDown() && - (av.alignment.findGroup(av.alignment.getSequenceAt(seq)) != null)) - { - System.out.println("no modifiers"); - SequenceGroup selection = new SequenceGroup(); - SequenceGroup sg = av.alignment.findGroup(av.alignment.getSequenceAt( - seq)); - selection.setStartRes(0); - selection.setEndRes(av.alignment.getWidth() - 1); - - for (int i = 0; i < sg.getSize(); i++) - { - selection.addSequence(sg.getSequenceAt(i), true); - } - - av.setSelectionGroup(selection); - return; - }*/ if ((av.getSelectionGroup() == null) || ((!e.isControlDown() && !e.isShiftDown()) && av.getSelectionGroup() != null)) @@ -322,7 +256,6 @@ public class IdPanel extends JPanel implements MouseListener, } - if (e.isShiftDown() && (lastid != -1)) { selectSeqs(lastid, seq); diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 9ea087e..d47d89d 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -147,7 +147,6 @@ public class SeqPanel extends JPanel implements MouseListener, int findSeq(MouseEvent evt) { - int seq = 0; int y = evt.getY(); @@ -162,11 +161,13 @@ public class SeqPanel extends JPanel implements MouseListener, y -= hgap; - seq = ( (y % cHeight) / av.getCharHeight()); + seq = Math.min( (y % cHeight) / av.getCharHeight(), + av.alignment.getHeight() -1); } else { - seq = (y / av.getCharHeight()) + av.getStartSeq(); + seq = Math.min( (y / av.getCharHeight()) + av.getStartSeq(), + av.alignment.getHeight() -1); } return seq; @@ -1373,11 +1374,6 @@ public class SeqPanel extends JPanel implements MouseListener, return; } - - if(y > av.alignment.getHeight()) - { - y = av.alignment.getHeight() -1; - } if(res> av.alignment.getWidth()) { res = av.alignment.getWidth()-1; -- 1.7.10.2