}
@Override
- public Set<Long> getMatchingNodes()
+ public Set<Long> getMatchingNodesIds()
{
return treeView.getFoundNodes0();
}
treeView.setPreferredSize(preferredSize);
}
+
+ @Override
+ public void addToMatchingNodes(TreeNodeI matchedNode)
+ {
+ treeView.getFoundNodes0().add(matchedNode.getId());
+
+ }
}
.get(selectedSequence);
if (matchingNode != null)
{
- treeView.getMatchingNodes().add(matchingNode.getId());
+ treeView.addToMatchingNodes(matchingNode);
// if (!matchingNode.getBranchData().isHasBranchColor())
/**
* Partially refactored from TreeCanvas
*/
+ @Override
public void partitionTree(final int x)
{
TreeI tree = treeView.getTree();
if (matchingSequence != null)
{
long nodeId = nodeToMatch.getId();
- addOrRemoveInSet(treeView.getMatchingNodes(), nodeId);
+ addOrRemoveInSet(treeView.getMatchingNodesIds(), nodeId);
treeSelectionChanged(matchingSequence);
parentAvport.sendSelection();
if (matchingSequence != null)
{
long nodeId = childNode.getId();
- addOrRemoveInSet(treeView.getMatchingNodes(), nodeId);
+ addOrRemoveInSet(treeView.getMatchingNodesIds(), nodeId);
treeSelectionChanged(matchingSequence);
{
private final Phylogeny tree;
- // alternative to static maps in TreeNode
- // private Map<PhylogenyNode, TreeNodeI> originalNodes = new HashMap<>(500);
- // private Map<TreeNodeI, PhylogenyNode> wrappedNodes = new HashMap<>(500);
public Tree()
{
}
@Override
- public double getHeight(boolean adjustForCollapsedSubtrees)
+ public double getMaximumLength(boolean adjustForCollapsedSubtrees)
{
return tree.calculateHeight(adjustForCollapsedSubtrees);
}
public void associateNodesToSequences();
/**
- * See
- * {@link jalview.ext.treeviewer.TreeViewerBindingI#getAlignmentWithNodes()}
+ * @see jalview.ext.treeviewer.TreeViewerBindingI#getAlignmentWithNodes()
*
*
*/
public Map<SequenceI, TreeNodeI> getAlignmentWithNodes();
/**
- * See
- * {@link jalview.ext.treeviewer.TreeViewerBindingI#getNodesWithAlignment()}
+ * @see jalview.ext.treeviewer.TreeViewerBindingI#getNodesWithAlignment()
+ *
*
*
*/
* viewer. Note that this extends many interfaces shared with Swing frames but
* doesn't demand that an implementation actually is a Swing frame.
*
+ * Frames should be added to Jalview's desktop via
+ * {@link TreeViewerUtils#addTreeViewFrameToJalview(TreeFrameI)} to ensure that
+ * they are registered as an active tree view.
+ *
* @author kjvanderheide
*
*/
import java.util.List;
/**
- * Interface for a generic phylogenetic tree, this does not necessarily have to
- * be part of a tree panel.
+ * Interface for implementing a phylogenetic tree.
*
* @author kjvanderheide
*
public TreeNodeI[] getAllNodes();
+ /**
+ * Gets the node that has the maximum branch length from the root (or top
+ * level node if tree is unrooted).
+ *
+ * @return
+ */
public TreeNodeI getFurthestNode();
- public double getHeight(boolean adjustForCollapsedSubtrees);
+ /**
+ * Returns the longest total branch length from the root to a leaf node.
+ *
+ * @param adjustForCollapsedSubtrees
+ * true if nodes part of a collapsed (hidden) subtree should be
+ * considered.
+ * @return
+ */
+ public double getMaximumLength(boolean adjustForCollapsedSubtrees);
public List<SequenceI> getNodeSequences();
import java.awt.Color;
import java.util.List;
+/**
+ * Interface for implementing a tree node, these nodes might -but do not have
+ * to- be part of a {@link TreeI}.
+ *
+ * @author kjvanderheide
+ *
+ */
public interface TreeNodeI
{
public List<TreeNodeI> getAllDescendants();
+ /**
+ * Returns only the immediate descendants of this node, so any nodes whose
+ * parent is this node.
+ *
+ * @return
+ */
public List<TreeNodeI> getDirectChildren();
+ /**
+ * Gets just the nodes downwards from this node that are external/leafs.
+ *
+ * @return
+ */
public List<TreeNodeI> getExternalDescendants();
public long getId();
public float getYcoord();
+ /**
+ *
+ * @return True if the node is internal, false if it's external (a leaf).
+ */
public boolean isInternal();
public void setBranchColor(Color branchColor);
import javax.accessibility.Accessible;
+/**
+ * Interface for a panel that supports viewing a phylogenetic tree, should
+ * probably be part of a {@link TreeFrameI}. Does not necessarily have to be a
+ * Swing JPanel.
+ *
+ * Implementations must always contain a {@link TreeI}.
+ *
+ * @author kjvanderheide
+ *
+ */
public interface TreePanelI extends Accessible, MenuContainer
{
-
-
public void addMouseListener(MouseListener listener);
+ /**
+ * Look for a tree node at the specified coordinates inside the panel.
+ *
+ * @param x
+ * X coordinate on the panel to look at.
+ * @param y
+ * Y coordinate on the panel to look at.
+ * @return The tree node if one was found, otherwise null.
+ */
public abstract TreeNodeI findNode(int x, int y);
public int getHeight();
- public abstract Set<Long> getMatchingNodes();
+ public void addToMatchingNodes(TreeNodeI matchedNode);
+
+ public abstract Set<Long> getMatchingNodesIds();
public MouseListener[] getMouseListeners();
+ /**
+ * Gets the current partitioning threshold which is the ratio of the
+ * partitioning x coordinate to the total panel width.
+ *
+ * @return The partition threshold.
+ */
public float getPartitionThreshold();
public abstract TreeI getTree();
public int getWidth();
+ /**
+ * Method for triggering PaintRefresher refreshes with the actual tree panel
+ * using the sequence set id the panel was registered with.
+ *
+ * @see jalview.gui.PaintRefresher#Refresh(java.awt.Component, String,
+ * boolean, boolean)
+ * @param alignmentChanged
+ * @param validateSequences
+ */
public void notifyPaintRefresher(boolean alignmentChanged,
boolean validateSequences);
+ /**
+ * Method for triggering PaintRefresher refreshes with the actual tree panel
+ * using a new sequence set id.
+ *
+ * @see jalview.gui.PaintRefresher#Refresh(java.awt.Component, String,
+ * boolean, boolean)
+ * @param newSeqSetIdentifier
+ * @param alignmentChanged
+ * @param validateSequences
+ */
public void notifyPaintRefresher(String newSeqSetIdentifier,
boolean alignmentChanged, boolean validateSequences);
public abstract void paintToFile(Graphics2D pg, int width, int height);
+ /**
+ * Registers the actual tree viewing panel used with PaintRefresher, this
+ * method is necessary as panels cannot be registered at this interface level
+ * because there is no guarantee an implementation will be a Component.
+ *
+ * @see jalview.gui.PaintRefresher#Register(java.awt.Component, String)
+ * @param sequenceSetIdentifier
+ */
public void registerWithPaintRefresher(String sequenceSetIdentifier);
public void removeMouseListener(MouseListener listener);
public void setPreferredSize(Dimension preferredSize);
+ /**
+ *
+ * @param file
+ */
public abstract void setTreeFile(File file);
+ /**
+ *
+ * @return
+ */
public boolean showingSubTree();
}
import java.io.IOException;
+/**
+ *
+ * @author kjvanderheide
+ *
+ */
public interface TreeParserI
{
public String getName();
public Map<TreeNodeI, SequenceI> getNodesWithAlignment();
/**
+ * Triggers a tree partition from the specified x coordinate.
*
* @param x
- * coordinate that functions as the clustering threshold
+ *
*/
public void partitionTree(final int x);
+++ /dev/null
-package jalview.ext.treeviewer;
-
-public interface TreeViewerConfigI
-{
-
-}
import java.util.HashMap;
import java.util.Map;
+/**
+ * Static class containing generic methods for
+ *
+ * @author kjvanderheide
+ *
+ */
public final class TreeViewerUtils
{
+ /**
+ * All tree viewers should be added to this map so that Jalview saves them to
+ * its project.
+ */
private static Map<TreeFrameI, TreeViewerBindingI> activeViews = new HashMap<>();
+ /**
+ *
+ * @param treeFrame
+ * @return
+ */
public static TreeFrameI addTreeViewFrameToJalview(
final TreeFrameI treeFrame)
{
}
+ /**
+ *
+ * @param treeFrame
+ * @param jalviewAlignViewport
+ * @param alignMappedToNodes
+ * @param nodesMappedToAlign
+ * @return
+ */
public static TreeViewerBindingI associateNodesWithJalviewSequences(
final TreeFrameI treeFrame,
final AlignmentViewport jalviewAlignViewport,