X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;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;hp=0000000000000000000000000000000000000000;hb=e95c5f895775891d55d9f23d5da64f8ce6bd07bb;hpb=74f21ca6ca8fa17d53708e457d191e15904f8310 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) + ")"; + } + + +}