From: amwaterhouse Date: Mon, 24 Jan 2005 17:26:15 +0000 (+0000) Subject: creates new groups when selecting branches of the tree X-Git-Tag: Release_2_0~729 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=26938f969a147044f626c5dfd278be4b474a6fe8;p=jalview.git creates new groups when selecting branches of the tree --- diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index 484e05a..c39e407 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -4,11 +4,11 @@ package jalview.gui; import jalview.analysis.*; import jalview.datamodel.*; import jalview.util.*; +import jalview.schemes.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; -import java.io.*; public class TreeCanvas extends JPanel implements MouseListener { @@ -247,18 +247,19 @@ public class TreeCanvas extends JPanel implements MouseListener } } - public void setColor(SequenceNode node, Color c) { - if (node == null) { + public void setColor(SequenceNode node, Color c) + { + if (node == null) return; - } - if (node.left() == null && node.right() == null) { + if (node.left() == null && node.right() == null) + { node.color = c; - if (node.element() instanceof SequenceI) { + if (node.element() instanceof SequenceI) ((SequenceI)node.element()).setColor(c); - } - } else { + } else + { node.color = c; setColor((SequenceNode)node.left(),c); setColor((SequenceNode)node.right(),c); @@ -357,15 +358,47 @@ public class TreeCanvas extends JPanel implements MouseListener tree.groupNodes(tree.getTopNode(),fthreshold); setColor(tree.getTopNode(),Color.black); - for (int i=0; i < tree.getGroups().size(); i++) { + av.sel.clear(); + av.alignment.deleteAllGroups(); + + for (int i=0; i < tree.getGroups().size(); i++) + { Color col = new Color((int)(Math.random()*255), (int)(Math.random()*255), (int)(Math.random()*255)); setColor((SequenceNode)tree.getGroups().elementAt(i),col.brighter()); - // l is vector of Objects - // Vector l = tree.findLeaves((SequenceNode)tree.getGroups().elementAt(i),new Vector()); + Vector l = tree.findLeaves((SequenceNode)tree.getGroups().elementAt(i),new Vector()); + SequenceGroup sg = null; + for (int j = 0; j < l.size(); j++) + { + SequenceNode sn = (SequenceNode) l.elementAt(j); + if(sg==null) + sg = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true,false,0,av.alignment.getWidth()); + + sg.addSequence( (Sequence) sn.element()); + } + + if (av.getGlobalColourScheme() instanceof ConservationColourScheme) + { + ConservationColourScheme ccs = (ConservationColourScheme) av.getGlobalColourScheme(); + Conservation c = new Conservation("Group", + ResidueProperties.propHash, 3, + sg.sequences, sg.getStartRes(), + sg.getEndRes()); + + c.calculate(); + c.verdict(false, 100); + ccs = new ConservationColourScheme(c, ccs.cs); + + sg.cs = ccs; + + } + + + + av.alignment.addGroup(sg); } }