From 3e82604b61ab50eea950f3ba2804c6bd75c204a6 Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Fri, 10 Nov 2017 14:17:18 +0000 Subject: [PATCH] JAL-2794 comments comments comments --- .../ext/archaeopteryx/ArchaeopteryxInit.java | 9 +++- .../archaeopteryx/ArchaeopteryxTreeConverter.java | 7 +++- .../ext/archaeopteryx/JalviewAptxBinding.java | 43 ++++++++++++++++---- .../archaeopteryx/JalviewTreeViewerBindingI.java | 3 +- 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java b/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java index 86f0020..744bf04 100644 --- a/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java +++ b/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java @@ -13,10 +13,17 @@ import org.forester.archaeopteryx.MainFrame; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyNode; +/** + * Static class for creating Archaeopteryx tree viewer instances from calculated + * trees and letting them be bound to Jalview. + * + * @author kjvanderheide + * + */ public final class ArchaeopteryxInit { /** - * This method should generally not be used as it does not bind the tree to + * Test method, should generally not be used as it does not bind the tree to * its alignment * * @param aptxTrees diff --git a/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java b/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java index 0bdd4e2..21a4e30 100644 --- a/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java +++ b/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java @@ -16,8 +16,11 @@ import org.forester.phylogeny.data.NodeData; import org.forester.phylogeny.data.Sequence; /** - * Note that this currently demands a 1:1 relationship between nodes and - * sequences + * Class for converting trees made in Jalview (through TreeBuilder) to trees + * compatible with Forester (Phylogeny objects). + * + * Note that this currently demands a 1:1 relationship between tree nodes and + * the sequences used for generating them. * * @author kjvanderheide * diff --git a/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java b/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java index 9466924..6a6b3f1 100644 --- a/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java +++ b/src/jalview/ext/archaeopteryx/JalviewAptxBinding.java @@ -18,23 +18,47 @@ import java.util.Map; import org.forester.archaeopteryx.MainFrame; import org.forester.phylogeny.PhylogenyNode; -public class JalviewAptxBinding implements JalviewTreeViewerBindingI +/** + * Class for binding the Archaeopteryx tree viewer to the Jalview alignment that + * it originates from, meaning that selecting sequences in the tree viewer also + * selects them in the alignment view and vice versa. + * + * @author kjvanderheide + * + */ +public final class JalviewAptxBinding implements JalviewTreeViewerBindingI { - org.forester.archaeopteryx.TreePanel treeView; + private org.forester.archaeopteryx.TreePanel treeView; - AlignmentViewport parentAvport; + private AlignmentViewport parentAvport; - final StructureSelectionManager ssm; + private final StructureSelectionManager ssm; - Map sequencesBoundToNodes; + private Map sequencesBoundToNodes; - Map nodesBoundToSequences; + private Map nodesBoundToSequences; + /** + * + * @param archaeopteryx + * + * @param jalviewAlignmentViewport + * alignment viewport from which the tree was calculated. + * + * @param alignMappedToNodes + * map with sequences used to calculate the tree and matching tree + * nodes as key, value pair respectively. + * + * @param nodesMappedToAlign + * map with tree nodes and matching sequences used to calculate the + * tree as key, value pair respectively. + */ public JalviewAptxBinding(final MainFrame archaeopteryx, final AlignmentViewport jalviewAlignmentViewport, final Map alignMappedToNodes, final Map nodesMappedToAlign) { + // deal with/prohibit null values here as that will cause problems parentAvport = jalviewAlignmentViewport; sequencesBoundToNodes = alignMappedToNodes; nodesBoundToSequences = nodesMappedToAlign; @@ -43,6 +67,7 @@ public class JalviewAptxBinding implements JalviewTreeViewerBindingI ssm.addSelectionListener(this); treeView.addMouseListener(this); PaintRefresher.Register(treeView, parentAvport.getSequenceSetId()); + } @Override @@ -128,8 +153,7 @@ public class JalviewAptxBinding implements JalviewTreeViewerBindingI else { parentAvport.setSelectionGroup(null); // reset selection if shift - // isn't - // pressed + // isn't pressed } treeSelectionChanged(matchingSequence); @@ -144,9 +168,10 @@ public class JalviewAptxBinding implements JalviewTreeViewerBindingI } /** - * Refactored from TreeCanvas + * Refactored from TreeCanvas. * * @param sequence + * of the node selected in the tree viewer. */ public void treeSelectionChanged(final SequenceI sequence) { diff --git a/src/jalview/ext/archaeopteryx/JalviewTreeViewerBindingI.java b/src/jalview/ext/archaeopteryx/JalviewTreeViewerBindingI.java index cb2f6ab..e9d6f81 100644 --- a/src/jalview/ext/archaeopteryx/JalviewTreeViewerBindingI.java +++ b/src/jalview/ext/archaeopteryx/JalviewTreeViewerBindingI.java @@ -28,7 +28,8 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; /** - * interface for binding a tree viewer to Jalview alignments + * Interface for binding a tree viewer to Jalview alignments. Assumes a tree + * viewer will both want to receive and send selection events * * @author kjvanderheide * -- 1.7.10.2