From: gmungoc Date: Wed, 31 Aug 2016 13:59:42 +0000 (+0100) Subject: JAL-2077 check for isPopupTrigger() in mousePressed as well as X-Git-Tag: Release_2_10_0~61 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=befb1682d3f7d181e61d62adf20e31d53caf2671;p=jalview.git JAL-2077 check for isPopupTrigger() in mousePressed as well as mouseClicked. --- diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index f21c5e7..b300b5b 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -788,39 +788,52 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, @Override public void mouseClicked(MouseEvent evt) { - if (highlightNode != null) + if (highlightNode == null) { - if (evt.isPopupTrigger()) - { - Color col = JColorChooser.showDialog(this, - MessageManager.getString("label.select_subtree_colour"), - highlightNode.color); - if (col != null) - { - setColor(highlightNode, col); - } - } - else if (evt.getClickCount() > 1) + return; + } + if (evt.isPopupTrigger()) + { + chooseSubtreeColour(); + } + else if (evt.getClickCount() > 1) + { + tree.swapNodes(highlightNode); + tree.reCount(tree.getTopNode()); + tree.findHeight(tree.getTopNode()); + } + else + { + Vector leaves = new Vector(); + tree.findLeaves(highlightNode, leaves); + + for (int i = 0; i < leaves.size(); i++) { - tree.swapNodes(highlightNode); - tree.reCount(tree.getTopNode()); - tree.findHeight(tree.getTopNode()); + SequenceI seq = (SequenceI) ((SequenceNode) leaves.elementAt(i)) + .element(); + treeSelectionChanged(seq); } - else - { - Vector leaves = new Vector(); - tree.findLeaves(highlightNode, leaves); + av.sendSelection(); + } - for (int i = 0; i < leaves.size(); i++) - { - SequenceI seq = (SequenceI) ((SequenceNode) leaves.elementAt(i)) - .element(); - treeSelectionChanged(seq); - } - av.sendSelection(); - } + PaintRefresher.Refresh(tp, av.getSequenceSetId()); + repaint(); + } - PaintRefresher.Refresh(tp, av.getSequenceSetId()); + /** + * Offer the user the option to choose a colour for the highlighted node and + * its children; this colour is also applied to the corresponding sequence ids + * in the alignment + */ + void chooseSubtreeColour() + { + Color col = JColorChooser.showDialog(this, + MessageManager.getString("label.select_subtree_colour"), + highlightNode.color); + if (col != null) + { + setColor(highlightNode, col); + PaintRefresher.Refresh(tp, ap.av.getSequenceSetId()); repaint(); } } @@ -866,6 +879,11 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, public void mousePressed(MouseEvent e) { av.setCurrentTree(tree); + if (highlightNode != null && e.isPopupTrigger()) + { + chooseSubtreeColour(); + return; + } int x = e.getX(); int y = e.getY(); @@ -993,17 +1011,14 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, .getCodingComplement(); if (codingComplement != null) { - if (codingComplement != null) + SequenceGroup mappedGroup = MappingUtils.mapSequenceGroup(sg, av, + codingComplement); + if (mappedGroup.getSequences().size() > 0) { - SequenceGroup mappedGroup = MappingUtils.mapSequenceGroup(sg, - av, codingComplement); - if (mappedGroup.getSequences().size() > 0) + codingComplement.getAlignment().addGroup(mappedGroup); + for (SequenceI seq : mappedGroup.getSequences()) { - codingComplement.getAlignment().addGroup(mappedGroup); - for (SequenceI seq : mappedGroup.getSequences()) - { - codingComplement.setSequenceColour(seq, col.brighter()); - } + codingComplement.setSequenceColour(seq, col.brighter()); } } } @@ -1022,11 +1037,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, { ((AlignViewport) codingComplement).getAlignPanel() .updateAnnotation(); - } - } - } /**