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) + ")"; } }