From: James Procter Date: Thu, 18 May 2023 11:29:25 +0000 (+0100) Subject: JAL-4134 properly specify BinaryNode as a typed generic container X-Git-Tag: Release_2_11_3_0~14^2~3^2^2~26 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1475dd24b86e27e83ad077c10ad8ad024175337d;p=jalview.git JAL-4134 properly specify BinaryNode as a typed generic container --- diff --git a/src/jalview/analysis/TreeModel.java b/src/jalview/analysis/TreeModel.java index dd56424..ad3e88c 100644 --- a/src/jalview/analysis/TreeModel.java +++ b/src/jalview/analysis/TreeModel.java @@ -409,8 +409,8 @@ public class TreeModel } else { - _groupNodes(groups, (SequenceNode) nd.left(), threshold); - _groupNodes(groups, (SequenceNode) nd.right(), threshold); + _groupNodes(groups, nd.left(), threshold); + _groupNodes(groups, nd.right(), threshold); } } diff --git a/src/jalview/datamodel/BinaryNode.java b/src/jalview/datamodel/BinaryNode.java index 5b55594..0ab69ea 100755 --- a/src/jalview/datamodel/BinaryNode.java +++ b/src/jalview/datamodel/BinaryNode.java @@ -23,22 +23,22 @@ package jalview.datamodel; import java.awt.Color; /** - * DOCUMENT ME! + * Represent a node in a binary tree * - * @author $author$ + * @author $mclamp (probably!)$ * @version $Revision$ */ -public class BinaryNode +public class BinaryNode { - Object element; + T element; String name; - BinaryNode left; + BinaryNode left; - BinaryNode right; + BinaryNode right; - BinaryNode parent; + BinaryNode parent; /** Bootstrap value */ public int bootstrap; @@ -58,7 +58,7 @@ public class BinaryNode /** DOCUMENT ME!! */ public Color color = Color.black; - /** DOCUMENT ME!! */ + /** if true, node is created to simulate polytomy between parent and its 3 or more children */ public boolean dummy = false; /** @@ -81,7 +81,7 @@ public class BinaryNode * @param name * DOCUMENT ME! */ - public BinaryNode(Object element, BinaryNode parent, String name, + public BinaryNode(T element, BinaryNode parent, String name, double dist) { this(); @@ -91,14 +91,14 @@ public class BinaryNode this.dist = dist; } - public BinaryNode(Object element, BinaryNode parent, String name, + public BinaryNode(T element, BinaryNode parent, String name, double dist, int bootstrap) { this(element, parent, name, dist); this.bootstrap = bootstrap; } - public BinaryNode(Object val, BinaryNode parent, String name, double dist, + public BinaryNode(T val, BinaryNode parent, String name, double dist, int bootstrap, boolean dummy) { this(val, parent, name, dist, bootstrap); @@ -110,7 +110,7 @@ public class BinaryNode * * @return DOCUMENT ME! */ - public Object element() + public T element() { return element; } @@ -123,7 +123,7 @@ public class BinaryNode * * @return DOCUMENT ME! */ - public Object setElement(Object v) + public T setElement(T v) { return element = v; } @@ -133,7 +133,7 @@ public class BinaryNode * * @return DOCUMENT ME! */ - public BinaryNode left() + public BinaryNode left() { return left; } @@ -146,7 +146,7 @@ public class BinaryNode * * @return DOCUMENT ME! */ - public BinaryNode setLeft(BinaryNode n) + public BinaryNode setLeft(BinaryNode n) { return left = n; } @@ -156,7 +156,7 @@ public class BinaryNode * * @return DOCUMENT ME! */ - public BinaryNode right() + public BinaryNode right() { return right; } @@ -169,7 +169,7 @@ public class BinaryNode * * @return DOCUMENT ME! */ - public BinaryNode setRight(BinaryNode n) + public BinaryNode setRight(BinaryNode n) { return right = n; } @@ -179,7 +179,7 @@ public class BinaryNode * * @return DOCUMENT ME! */ - public BinaryNode parent() + public BinaryNode parent() { return parent; } @@ -192,7 +192,7 @@ public class BinaryNode * * @return DOCUMENT ME! */ - public BinaryNode setParent(BinaryNode n) + public BinaryNode setParent(BinaryNode n) { return parent = n; } @@ -214,7 +214,7 @@ public class BinaryNode * setChild(null), or detach() for this. * */ - public void SetChildren(BinaryNode leftchild, BinaryNode rightchild) + public void SetChildren(BinaryNode leftchild, BinaryNode rightchild) { if (leftchild != null) { @@ -236,7 +236,7 @@ public class BinaryNode * * @return BinaryNode The detached node. */ - public BinaryNode detach() + public BinaryNode detach() { if (this.parent != null) { @@ -264,9 +264,9 @@ public class BinaryNode * * @return BinaryNode */ - public BinaryNode ascendLeft() + public BinaryNode ascendLeft() { - BinaryNode c = this; + BinaryNode c = this; do { @@ -283,9 +283,9 @@ public class BinaryNode * * @return BinaryNode */ - public BinaryNode ascendRight() + public BinaryNode ascendRight() { - BinaryNode c = this; + BinaryNode c = this; do { @@ -366,9 +366,9 @@ public class BinaryNode * ascends the tree but doesn't stop until a non-dummy node is discovered. * */ - public BinaryNode AscendTree() + public BinaryNode AscendTree() { - BinaryNode c = this; + BinaryNode c = this; do { diff --git a/src/jalview/datamodel/SequenceNode.java b/src/jalview/datamodel/SequenceNode.java index 010d4aa..89a6cb4 100755 --- a/src/jalview/datamodel/SequenceNode.java +++ b/src/jalview/datamodel/SequenceNode.java @@ -26,7 +26,7 @@ package jalview.datamodel; * @author $author$ * @version $Revision$ */ -public class SequenceNode extends BinaryNode +public class SequenceNode extends BinaryNode { private boolean placeholder = false; @@ -38,19 +38,19 @@ public class SequenceNode extends BinaryNode super(); } - public SequenceNode(SequenceI val, BinaryNode parent, String name, + public SequenceNode(SequenceI val, BinaryNode parent, String name, double dist, int bootstrap, boolean dummy) { super(val, parent, name, dist, bootstrap, dummy); } - public SequenceNode(SequenceI element, BinaryNode parent, String name, + public SequenceNode(SequenceI element, BinaryNode parent, String name, double dist, int bootstrap) { super(element, parent, name, dist, bootstrap); } - public SequenceNode(SequenceI element, BinaryNode parent, String name, + public SequenceNode(SequenceI element, BinaryNode parent, String name, double dist) { super(element, parent, name, dist); diff --git a/src/jalview/io/vamsas/Tree.java b/src/jalview/io/vamsas/Tree.java index c0d1774..2ad3573 100644 --- a/src/jalview/io/vamsas/Tree.java +++ b/src/jalview/io/vamsas/Tree.java @@ -358,7 +358,7 @@ public class Tree extends DatastoreItem } if (jvseq instanceof SequenceI) { - leaf.setElement(jvseq); + leaf.setElement((SequenceI)jvseq); leaf.setPlaceholder(false); } else