X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=srcjar%2Ffr%2Forsay%2Flri%2Fvarna%2Fmodels%2Ftreealign%2FAlignedNode.java;fp=srcjar%2Ffr%2Forsay%2Flri%2Fvarna%2Fmodels%2Ftreealign%2FAlignedNode.java;h=9f428900a4a5dafccd634421994a39b6af21cbd8;hb=4898f0ae429e0c61ddba72ca46be89b34bb4df8b;hp=0000000000000000000000000000000000000000;hpb=5a6ac5b535856903629234ad43a71319a91ebee5;p=jalview.git diff --git a/srcjar/fr/orsay/lri/varna/models/treealign/AlignedNode.java b/srcjar/fr/orsay/lri/varna/models/treealign/AlignedNode.java new file mode 100644 index 0000000..9f42890 --- /dev/null +++ b/srcjar/fr/orsay/lri/varna/models/treealign/AlignedNode.java @@ -0,0 +1,48 @@ +package fr.orsay.lri.varna.models.treealign; + + +/** + * The type of node values in an alignment. + * Contains a reference to both original nodes. + * This class implements GraphvizDrawableNodeValue but it will only work + * if the original nodes implement it. + * @author Raphael Champeimont + * @param The type of values in the original first tree. + * @param The type of values in the original second tree. + */ +public class AlignedNode implements GraphvizDrawableNodeValue { + private Tree leftNode; + private Tree rightNode; + + public Tree getLeftNode() { + return leftNode; + } + + public void setLeftNode(Tree leftNode) { + this.leftNode = leftNode; + } + + public Tree getRightNode() { + return rightNode; + } + + public void setRightNode(Tree rightNode) { + this.rightNode = rightNode; + } + + private String maybeNodeToGraphvizNodeName(Tree tree) { + return (tree != null && tree.getValue() != null) ? tree.getValue().toGraphvizNodeName() : "_"; + } + + /** + * This method will work only if the left and right node + * already implement GraphvizDrawableNodeValue. + */ + @SuppressWarnings("unchecked") + public String toGraphvizNodeName() { + return "(" + maybeNodeToGraphvizNodeName((Tree) leftNode) + + "," + maybeNodeToGraphvizNodeName((Tree) rightNode) + ")"; + } + + +}