From: kjvdheide Date: Thu, 9 Nov 2017 16:12:00 +0000 (+0000) Subject: JAL-2794 PaintRefresher support, Aptx node selection now shown on align X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=247e0ff054d4b1be0adeca43e513993fe18c3565;p=jalview.git JAL-2794 PaintRefresher support, Aptx node selection now shown on align --- diff --git a/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java b/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java index 9b654f0..aaf7ffb 100644 --- a/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java +++ b/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java @@ -57,7 +57,8 @@ public final class ArchaeopteryxInit MainFrame aptxApp = createBoundAptxFrame(aptxTrees, calculatedTree.getAvport()); bindNodesToJalviewSequences(aptxApp, calculatedTree.getAvport(), - aptxTreeBuilder.getAlignmentBoundNodes()); + aptxTreeBuilder.getAlignmentBoundNodes(), + aptxTreeBuilder.getNodesBoundAlignment()); return bindFrameToJalview(aptxApp); } @@ -76,10 +77,11 @@ public final class ArchaeopteryxInit private static void bindNodesToJalviewSequences(MainFrame aptxApp, AlignmentViewport jalviewAlignViewport, - Map alignMappedToNodes) + Map alignMappedToNodes, + Map nodesMappedToAlign) { new JalviewAptxBinding(aptxApp, jalviewAlignViewport, - alignMappedToNodes); + alignMappedToNodes, nodesMappedToAlign); } diff --git a/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java b/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java index c2b48ab..a3bff2d 100644 --- a/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java +++ b/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java @@ -4,6 +4,7 @@ import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenColumns; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.gui.PaintRefresher; import jalview.structure.SelectionSource; import jalview.structure.StructureSelectionManager; import jalview.viewmodel.AlignmentViewport; @@ -25,19 +26,23 @@ public class JalviewAptxBinding implements JalviewTreeViewerBindingI StructureSelectionManager ssm; - Map sequencesBelongingToNodes; + Map sequencesBoundToNodes; + Map nodesBoundToSequences; public JalviewAptxBinding(MainFrame archaeopteryx, AlignmentViewport jalviewAlignmentViewport, - Map alignMappedToNodes) + Map alignMappedToNodes, + Map nodesMappedToAlign) { parentAvport = jalviewAlignmentViewport; - sequencesBelongingToNodes = alignMappedToNodes; + sequencesBoundToNodes = alignMappedToNodes; + nodesBoundToSequences = nodesMappedToAlign; treeView = archaeopteryx.getMainPanel().getCurrentTreePanel(); ssm = parentAvport.getStructureSelectionManager(); ssm.addSelectionListener(this); treeView.addMouseListener(this); + PaintRefresher.Register(treeView, parentAvport.getSequenceSetId()); } @Override @@ -88,11 +93,14 @@ public class JalviewAptxBinding implements JalviewTreeViewerBindingI for (SequenceI sequence : seqsel.getSequences()) { - PhylogenyNode matchingNode = sequencesBelongingToNodes.get(sequence); - treeView.getFoundNodes0().add(matchingNode.getId()); + PhylogenyNode matchingNode = sequencesBoundToNodes.get(sequence); + if (matchingNode != null) + { + treeView.getFoundNodes0().add(matchingNode.getId()); + } } - treeView.repaint(); + PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId()); } @@ -105,22 +113,59 @@ public class JalviewAptxBinding implements JalviewTreeViewerBindingI final PhylogenyNode node = treeView.findNode(e.getX(), e.getY()); if (node != null && node.isExternal()) { + SequenceI matchingSequence = nodesBoundToSequences.get(node); if ((e.getModifiers() & InputEvent.SHIFT_MASK) != 0) // shift is pressed // (so multiple nodes // can be selected) { - System.out.println(treeView.getFoundNodes0().toString()); } + else + { + parentAvport.setSelectionGroup(null); // reset selection if shift isn't + // pressed + } + + treeSelectionChanged(matchingSequence); + parentAvport.sendSelection(); // not actually needed? + + PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId()); } - } + } + + /** + * Refactored from TreeCanvas + * + * @param sequence + */ + public void treeSelectionChanged(SequenceI sequence) + { + SequenceGroup selected = parentAvport.getSelectionGroup(); + if (selected == null) + { + selected = new SequenceGroup(); + parentAvport.setSelectionGroup(selected); + } + selected.setEndRes(parentAvport.getAlignment().getWidth() - 1); + selected.addOrRemove(sequence, true); + + } + public AlignmentViewport getParentAvport() + { + return parentAvport; + } + public void setParentAvport(AlignmentViewport parentAvport) + { + this.parentAvport = parentAvport; } +} +