From 559b96a91b710f3f2e116790c9cf7e3aa6c76766 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 10 Aug 2006 13:40:59 +0000 Subject: [PATCH] Control and shift for col selection --- src/jalview/appletgui/ScalePanel.java | 80 +++++++++++++++++---------------- src/jalview/gui/ScalePanel.java | 64 ++++++++++++++------------ 2 files changed, 78 insertions(+), 66 deletions(-) diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index f72ea7b..5419d27 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -63,34 +63,18 @@ public class ScalePanel min = res; max = res; - if (reveal != null - && (evt.getModifiers() & InputEvent.BUTTON3_MASK) + if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { - - MenuItem item = new MenuItem("Reveal"); - item.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - av.showColumn(reveal[0]); - reveal = null; - ap.repaint(); - if (ap.overviewPanel != null) - ap.overviewPanel.updateOverviewImage(); - } - }); PopupMenu pop = new PopupMenu(); - pop.add(item); - - if (av.getColumnSelection().getHiddenColumns().size() > 1) + if (reveal != null) { - item = new MenuItem("Reveal All"); + MenuItem item = new MenuItem("Reveal"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - av.showAllHiddenColumns(); + av.showColumn(reveal[0]); reveal = null; ap.repaint(); if (ap.overviewPanel != null) @@ -98,16 +82,26 @@ public class ScalePanel } }); pop.add(item); - } - this.add(pop); - pop.show(this, evt.getX(), evt.getY()); - - } - else if (av.getColumnSelection().contains(res)) - { - if ( (evt.getModifiers() & InputEvent.BUTTON3_MASK) - == InputEvent.BUTTON3_MASK) + if (av.getColumnSelection().getHiddenColumns().size() > 1) + { + item = new MenuItem("Reveal All"); + item.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + av.showAllHiddenColumns(); + reveal = null; + ap.repaint(); + if (ap.overviewPanel != null) + ap.overviewPanel.updateOverviewImage(); + } + }); + pop.add(item); + } + pop.show(this, evt.getX(), evt.getY()); + } + else if (av.getColumnSelection().contains(res)) { MenuItem item = new MenuItem("Hide Columns"); item.addActionListener(new ActionListener() @@ -120,22 +114,19 @@ public class ScalePanel ap.overviewPanel.updateOverviewImage(); } }); - PopupMenu pop = new PopupMenu(); pop.add(item); - this.add(pop); pop.show(this, evt.getX(), evt.getY()); } - else - { - av.getColumnSelection().removeElement(res); - av.setSelectionGroup(null); - } } - else + else // LEFT MOUSE TO SELECT { + if (!evt.isControlDown() && !evt.isShiftDown()) + { + av.getColumnSelection().clear(); + } + av.getColumnSelection().addElement(res); SequenceGroup sg = new SequenceGroup(); - for (int i = 0; i < av.alignment.getSequences().size(); i++) { sg.addSequence(av.alignment.getSequenceAt(i), false); @@ -144,7 +135,20 @@ public class ScalePanel sg.setStartRes(res); sg.setEndRes(res); av.setSelectionGroup(sg); + + if(evt.isShiftDown()) + { + int min = Math.min(av.getColumnSelection().getMin(), res); + int max = Math.max(av.getColumnSelection().getMax(), res); + for (int i = min; i1) + if (av.getColumnSelection().getHiddenColumns().size() > 1) { item = new JMenuItem("Reveal All"); item.addActionListener(new ActionListener() @@ -100,22 +102,16 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList av.showAllHiddenColumns(); reveal = null; ap.repaint(); - if(ap.overviewPanel != null) + if (ap.overviewPanel != null) ap.overviewPanel.updateOverviewImage(); } }); pop.add(item); } - pop.show(this, evt.getX(), evt.getY()); - } - else - if (av.getColumnSelection().contains(res)) - { - if( SwingUtilities.isRightMouseButton(evt)) + else if (av.getColumnSelection().contains(res)) { - JPopupMenu pop = new JPopupMenu(); JMenuItem item = new JMenuItem("Hide Columns"); item.addActionListener(new ActionListener() { @@ -123,33 +119,45 @@ public class ScalePanel extends JPanel implements MouseMotionListener, MouseList { av.hideColumns(res, res); ap.repaint(); - if(ap.overviewPanel != null) + if (ap.overviewPanel != null) ap.overviewPanel.updateOverviewImage(); } }); pop.add(item); pop.show(this, evt.getX(), evt.getY()); - - } - else - { - av.getColumnSelection().removeElement(res); - av.setSelectionGroup(null); } } - else + else // LEFT MOUSE TO SELECT { - av.getColumnSelection().addElement(res); - SequenceGroup sg = new SequenceGroup(); + if (!evt.isControlDown() && !evt.isShiftDown()) + { + av.getColumnSelection().clear(); + } + + av.getColumnSelection().addElement(res); + SequenceGroup sg = new SequenceGroup(); + for (int i = 0; i < av.alignment.getSequences().size(); i++) + { + sg.addSequence(av.alignment.getSequenceAt(i), false); + } + + sg.setStartRes(res); + sg.setEndRes(res); + av.setSelectionGroup(sg); - for (int i = 0; i < av.alignment.getSequences().size(); i++) + if(evt.isShiftDown()) + { + int min = Math.min(av.getColumnSelection().getMin(), res); + int max = Math.max(av.getColumnSelection().getMax(), res); + for (int i = min; i