import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import org.forester.archaeopteryx.MainFrame;
+import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyNode;
/**
/**
* If a node is selected in the tree panel this method highlights the
- * corresponding sequence in the Jalview alignment view.
+ * corresponding sequence in the Jalview alignment view. If an internal node
+ * is selected all child sequences get highlighted as well.
*/
@Override
public void showNodeSelectionOnAlign(final MouseEvent e)
final PhylogenyNode node = treeView.findNode(e.getX(), e.getY());
if (node != null)
{
- SequenceI matchingSequence = nodesBoundToSequences.get(node);
- if (matchingSequence != null)
+ if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) // clear previous
+ // selection if shift
+ // IS NOT pressed
{
+ parentAvport.setSelectionGroup(null);
+ }
- if ((e.getModifiers() & InputEvent.SHIFT_MASK) != 0) // shift is pressed
- // (so multiple nodes
- // can be selected)
- {
- // something?
+ if (node.isInternal())
+ {
+ showMatchingChildSequences(node);
- }
- else
- {
- parentAvport.setSelectionGroup(null); // reset selection if shift
- // isn't pressed
- }
+ }
+ else
+ {
+ showMatchingSequence(node);
- treeSelectionChanged(matchingSequence);
- parentAvport.sendSelection(); // not actually needed?
- PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId());
+ }
+ }
+ }
- }
+
+
+
+ public void showMatchingSequence(final PhylogenyNode nodeToMatch)
+ {
+ SequenceI matchingSequence = nodesBoundToSequences.get(nodeToMatch);
+ if (matchingSequence != null)
+ {
+ treeSelectionChanged(matchingSequence);
+ parentAvport.sendSelection();
+ PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId());
}
+ }
+
+ public void showMatchingChildSequences(final PhylogenyNode parentNode)
+ {
+ final List<PhylogenyNode> childNodes = PhylogenyMethods
+ .getAllDescendants(parentNode);
+ for (PhylogenyNode childNode : childNodes)
+ {
+ SequenceI matchingSequence = nodesBoundToSequences.get(childNode);
+ if (matchingSequence != null)
+ {
+ treeSelectionChanged(matchingSequence);
+ }
+ }
+ parentAvport.sendSelection();
+ PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId());
}
/**