X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FTreeCanvas.java;h=5d5b7ba3300e2441084288b3f0137450d321fa11;hb=a45774ee31d9f35d4eff46d54d7deab719afb092;hp=f0e7b62c18b4497115716641719c4e22ded0392c;hpb=e6ae1a0869ced674b7032826527ad229e8efa8db;p=jalview.git diff --git a/src/jalview/appletgui/TreeCanvas.java b/src/jalview/appletgui/TreeCanvas.java index f0e7b62..5d5b7ba 100755 --- a/src/jalview/appletgui/TreeCanvas.java +++ b/src/jalview/appletgui/TreeCanvas.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) - * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * This file is part of Jalview. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Jalview. If not, see . */ package jalview.appletgui; @@ -65,9 +64,11 @@ public class TreeCanvas extends Panel implements MouseListener, SequenceNode highlightNode; - public TreeCanvas(AlignViewport av, ScrollPane scroller) + AlignmentPanel ap; + public TreeCanvas(AlignmentPanel ap, ScrollPane scroller) { - this.av = av; + this.ap = ap; + this.av = ap.av; font = av.getFont(); scrollPane = scroller; addMouseListener(this); @@ -185,8 +186,7 @@ public class TreeCanvas extends Panel implements MouseListener, } String name = (markPlaceholders && node.isPlaceholder()) ? (PLACEHOLDER + node - .getName()) - : node.getName(); + .getName()) : node.getName(); FontMetrics fm = g.getFontMetrics(font); int charWidth = fm.stringWidth(name) + 3; int charHeight = fm.getHeight(); @@ -406,7 +406,7 @@ public class TreeCanvas extends Panel implements MouseListener, { repaint(); } - + int width = scrollPane.getSize().width; int height = scrollPane.getSize().height; if (!fitToWindow) @@ -436,9 +436,9 @@ public class TreeCanvas extends Panel implements MouseListener, g.fillRect(0, 0, width, height); labelLength = g.getFontMetrics(font).stringWidth(longestName) + 20; // 20 - // allows - // for - // scrollbar + // allows + // for + // scrollbar float wscale = (float) (width - labelLength - offx * 2) / tree.getMaxHeight(); @@ -510,6 +510,7 @@ public class TreeCanvas extends Panel implements MouseListener, PaintRefresher.Refresh(this, av.getSequenceSetId()); repaint(); + av.sendSelection(); } } @@ -552,6 +553,7 @@ public class TreeCanvas extends Panel implements MouseListener, treeSelectionChanged((Sequence) ob); PaintRefresher.Refresh(this, av.getSequenceSetId()); repaint(); + av.sendSelection(); return; } else if (!(ob instanceof SequenceNode)) @@ -586,12 +588,12 @@ public class TreeCanvas extends Panel implements MouseListener, 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)); + Color col = new Color((int) (Math.random() * 255), + (int) (Math.random() * 255), (int) (Math.random() * 255)); setColor((SequenceNode) tree.getGroups().elementAt(i), col.brighter()); - Vector l = tree.findLeaves((SequenceNode) tree.getGroups().elementAt( - i), new Vector()); + Vector l = tree.findLeaves( + (SequenceNode) tree.getGroups().elementAt(i), new Vector()); Vector sequences = new Vector(); for (int j = 0; j < l.size(); j++) @@ -610,8 +612,9 @@ public class TreeCanvas extends Panel implements MouseListener, { if (av.getGlobalColourScheme() instanceof UserColourScheme) { - cs = new UserColourScheme(((UserColourScheme) av - .getGlobalColourScheme()).getColours()); + cs = new UserColourScheme( + ((UserColourScheme) av.getGlobalColourScheme()) + .getColours()); } else @@ -620,9 +623,12 @@ public class TreeCanvas extends Panel implements MouseListener, .getWidth(), ColourSchemeProperty.getColourName(av .getGlobalColourScheme())); } - - cs.setThreshold(av.getGlobalColourScheme().getThreshold(), av - .getIgnoreGapsConsensus()); + // cs is null if shading is an annotationColourGradient + if (cs!=null) + { + cs.setThreshold(av.getGlobalColourScheme().getThreshold(), + av.getIgnoreGapsConsensus()); + } } SequenceGroup sg = new SequenceGroup(sequences, "", cs, true, true, @@ -634,8 +640,8 @@ public class TreeCanvas extends Panel implements MouseListener, && av.getGlobalColourScheme().conservationApplied()) { Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, sg.getSequences(null), sg - .getStartRes(), sg.getEndRes()); + ResidueProperties.propHash, 3, sg.getSequences(null), + sg.getStartRes(), sg.getEndRes()); c.calculate(); c.verdict(false, av.ConsPercGaps); @@ -648,7 +654,8 @@ public class TreeCanvas extends Panel implements MouseListener, av.alignment.addGroup(sg); } - + ap.updateAnnotation(); + } public void setShowDistances(boolean state)