MainFrame aptxApp = createBoundAptxFrame(aptxTrees,
calculatedTree.getAvport());
bindNodesToJalviewSequences(aptxApp, calculatedTree.getAvport(),
- aptxTreeBuilder.getAlignmentBoundNodes());
+ aptxTreeBuilder.getAlignmentBoundNodes(),
+ aptxTreeBuilder.getNodesBoundAlignment());
return bindFrameToJalview(aptxApp);
}
private static void bindNodesToJalviewSequences(MainFrame aptxApp,
AlignmentViewport jalviewAlignViewport,
- Map<SequenceI, PhylogenyNode> alignMappedToNodes)
+ Map<SequenceI, PhylogenyNode> alignMappedToNodes,
+ Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
{
new JalviewAptxBinding(aptxApp, jalviewAlignViewport,
- alignMappedToNodes);
+ alignMappedToNodes, nodesMappedToAlign);
}
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;
StructureSelectionManager ssm;
- Map<SequenceI, PhylogenyNode> sequencesBelongingToNodes;
+ Map<SequenceI, PhylogenyNode> sequencesBoundToNodes;
+ Map<PhylogenyNode, SequenceI> nodesBoundToSequences;
public JalviewAptxBinding(MainFrame archaeopteryx,
AlignmentViewport jalviewAlignmentViewport,
- Map<SequenceI, PhylogenyNode> alignMappedToNodes)
+ Map<SequenceI, PhylogenyNode> alignMappedToNodes,
+ Map<PhylogenyNode, SequenceI> 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
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());
}
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;
}
+}
+