package jalview.gui;
import jalview.analysis.Conservation;
-import jalview.analysis.NJTree;
+import jalview.analysis.TreeModel;
import jalview.api.AlignViewportI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import java.awt.print.PrinterJob;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.List;
import java.util.Vector;
import javax.swing.JColorChooser;
/** DOCUMENT ME!! */
public static final String PLACEHOLDER = " * ";
- NJTree tree;
+ TreeModel tree;
JScrollPane scrollPane;
* @param tree
* DOCUMENT ME!
*/
- public void setTree(NJTree tree)
+ public void setTree(TreeModel tree)
{
this.tree = tree;
tree.findHeight(tree.getTopNode());
* DOCUMENT ME!
* @param chunk
* DOCUMENT ME!
- * @param scale
+ * @param wscale
* DOCUMENT ME!
* @param width
* DOCUMENT ME!
* DOCUMENT ME!
*/
public void drawNode(Graphics g, SequenceNode node, float chunk,
- float scale, int width, int offx, int offy)
+ double wscale, int width, int offx, int offy)
{
if (node == null)
{
if ((node.left() == null) && (node.right() == null))
{
// Drawing leaf node
- float height = node.height;
- float dist = node.dist;
+ double height = node.height;
+ double dist = node.dist;
- int xstart = (int) ((height - dist) * scale) + offx;
- int xend = (int) (height * scale) + offx;
+ int xstart = (int) ((height - dist) * wscale) + offx;
+ int xend = (int) (height * wscale) + offx;
int ypos = (int) (node.ycount * chunk) + offy;
}
else
{
- drawNode(g, (SequenceNode) node.left(), chunk, scale, width, offx,
+ drawNode(g, (SequenceNode) node.left(), chunk, wscale, width, offx,
offy);
- drawNode(g, (SequenceNode) node.right(), chunk, scale, width, offx,
+ drawNode(g, (SequenceNode) node.right(), chunk, wscale, width, offx,
offy);
- float height = node.height;
- float dist = node.dist;
+ double height = node.height;
+ double dist = node.dist;
- int xstart = (int) ((height - dist) * scale) + offx;
- int xend = (int) (height * scale) + offx;
+ int xstart = (int) ((height - dist) * wscale) + offx;
+ int xend = (int) (height * wscale) + offx;
int ypos = (int) (node.ycount * chunk) + offy;
g.setColor(node.color.darker());
Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5);
nodeHash.put(node, pos);
- g.drawLine((int) (height * scale) + offx, ystart,
- (int) (height * scale) + offx, yend);
+ g.drawLine((int) (height * wscale) + offx, ystart,
+ (int) (height * wscale) + offx, yend);
String nodeLabel = "";
SequenceNode top = tree.getTopNode();
- float wscale = (float) ((width * .8) - (offx * 2))
+ double wscale = ((width * .8) - (offx * 2))
/ tree.getMaxHeight();
if (top.count == 0)
* DOCUMENT ME!
* @param chunk
* DOCUMENT ME!
- * @param scale
+ * @param wscale
* DOCUMENT ME!
* @param width
* DOCUMENT ME!
* DOCUMENT ME!
*/
public void pickNode(Rectangle pickBox, SequenceNode node, float chunk,
- float scale, int width, int offx, int offy)
+ double wscale, int width, int offx, int offy)
{
if (node == null)
{
if ((node.left() == null) && (node.right() == null))
{
- float height = node.height;
- float dist = node.dist;
+ double height = node.height;
+ double dist = node.dist;
- int xstart = (int) ((height - dist) * scale) + offx;
- int xend = (int) (height * scale) + offx;
+ int xstart = (int) ((height - dist) * wscale) + offx;
+ int xend = (int) (height * wscale) + offx;
int ypos = (int) (node.ycount * chunk) + offy;
}
else
{
- pickNode(pickBox, (SequenceNode) node.left(), chunk, scale, width,
+ pickNode(pickBox, (SequenceNode) node.left(), chunk, wscale, width,
offx, offy);
- pickNode(pickBox, (SequenceNode) node.right(), chunk, scale, width,
+ pickNode(pickBox, (SequenceNode) node.right(), chunk, wscale, width,
offx, offy);
}
}
labelLength = fm.stringWidth(longestName) + 20; // 20 allows for scrollbar
- float wscale = (width - labelLength - (offx * 2)) / tree.getMaxHeight();
+ double wscale = (width - labelLength - (offx * 2))
+ / tree.getMaxHeight();
SequenceNode top = tree.getTopNode();
threshold = (float) (x - offx)
/ (float) (getWidth() - labelLength - (2 * offx));
- tree.getGroups().removeAllElements();
- tree.groupNodes(tree.getTopNode(), threshold);
+ List<SequenceNode> groups = tree.groupNodes(threshold);
setColor(tree.getTopNode(), Color.black);
AlignmentPanel[] aps = getAssociatedPanels();
aps[a].av.getCodingComplement().clearSequenceColours();
}
}
- colourGroups();
+ colourGroups(groups);
}
PaintRefresher.Refresh(tp, ap.av.getSequenceSetId());
}
- void colourGroups()
+ void colourGroups(List<SequenceNode> groups)
{
AlignmentPanel[] aps = getAssociatedPanels();
- for (int i = 0; i < tree.getGroups().size(); i++)
+ for (int i = 0; i < groups.size(); i++)
{
Color col = new Color((int) (Math.random() * 255),
(int) (Math.random() * 255), (int) (Math.random() * 255));
- setColor(tree.getGroups().elementAt(i), col.brighter());
+ setColor(groups.get(i), col.brighter());
- Vector<SequenceNode> l = tree.findLeaves(tree.getGroups()
- .elementAt(i));
+ Vector<SequenceNode> l = tree.findLeaves(groups.get(i));
Vector<SequenceI> sequences = new Vector<SequenceI>();
.getGlobalColourScheme()));
}
// cs is null if shading is an annotationColourGradient
- if (cs != null)
- {
- cs.setThreshold(av.getGlobalColourScheme().getThreshold(),
- av.isIgnoreGapsConsensus());
- }
+ // if (cs != null)
+ // {
+ // cs.setThreshold(av.getViewportColourScheme().getThreshold(),
+ // av.isIgnoreGapsConsensus());
+ // }
}
- sg.cs = cs;
+ sg.setColourScheme(cs);
+ sg.getGroupColourScheme().setThreshold(
+ av.getResidueShading().getThreshold(),
+ av.isIgnoreGapsConsensus());
// sg.recalcConservation();
sg.setName("JTreeGroup:" + sg.hashCode());
sg.setIdColour(col);
for (int a = 0; a < aps.length; a++)
{
if (aps[a].av.getGlobalColourScheme() != null
- && aps[a].av.getGlobalColourScheme().conservationApplied())
+ && aps[a].av.getResidueShading()
+ .conservationApplied())
{
Conservation c = new Conservation("Group", sg.getSequences(null),
sg.getStartRes(), sg.getEndRes());