X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fgui%2FAlignmentPanel.java;h=efefeafbada38512aa86f69d4377d8d6675873eb;hb=5bef7467be8daff113e68b204394dd02003ca731;hp=3316227642a9aad5bc030820c18e4d77110a4fe8;hpb=bb24cd9d9b542bde1408eeb29a38b1d7f3f5f699;p=jalview.git diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 3316227..efefeaf 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -1,25 +1,25 @@ /* - * 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.6) + * Copyright (C) 2010 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.gui; import java.beans.*; import java.io.*; +import java.util.Hashtable; import java.util.Vector; import java.awt.*; @@ -179,8 +179,8 @@ public class AlignmentPanel extends GAlignmentPanel implements AlignmentI al = av.getAlignment(); int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300); - int maxwidth = Math.max(20, Math.min(afwidth - 200, (int) 2 * afwidth - / 3)); + int maxwidth = Math.max(20, + Math.min(afwidth - 200, (int) 2 * afwidth / 3)); int i = 0; int idWidth = 0; String id; @@ -283,6 +283,8 @@ public class AlignmentPanel extends GAlignmentPanel implements } int start = r[0]; int end = r[1]; + // System.err.println("Seq : "+seqIndex+" Scroll to "+start+","+end); // + // DEBUG if (start < 0) { return false; @@ -400,6 +402,7 @@ public class AlignmentPanel extends GAlignmentPanel implements annotationSpaceFillerHolder.setPreferredSize(new Dimension( annotationSpaceFillerHolder.getWidth(), height)); annotationScroller.validate();// repaint(); + addNotify(); repaint(); } @@ -575,9 +578,7 @@ public class AlignmentPanel extends GAlignmentPanel implements { int x = hscroll.getValue(); av.setStartRes(x); - av - .setEndRes((x + (seqPanel.seqCanvas.getWidth() / av - .getCharWidth())) - 1); + av.setEndRes((x + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1); } if (evt.getSource() == vscroll) @@ -857,8 +858,8 @@ public class AlignmentPanel extends GAlignmentPanel implements } pg.setColor(currentColor); - pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth, av - .getCharHeight()); + pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth, + av.getCharHeight()); pg.setColor(currentTextColor); @@ -871,7 +872,9 @@ public class AlignmentPanel extends GAlignmentPanel implements - 4; } - pg.drawString(seq.getDisplayId(av.getShowJVSuffix()), xPos, + pg.drawString( + seq.getDisplayId(av.getShowJVSuffix()), + xPos, (((i - startSeq) * av.charHeight) + av.getCharHeight()) - (av.getCharHeight() / 5)); } @@ -1320,9 +1323,19 @@ public class AlignmentPanel extends GAlignmentPanel implements */ public void updateAnnotation() { + updateAnnotation(false); + } + + public void updateAnnotation(boolean applyGlobalSettings) + { + // TODO: this should be merged with other annotation update stuff - that + // sits on AlignViewport boolean updateCalcs = false; boolean conv = av.isShowGroupConservation(); boolean cons = av.isShowGroupConsensus(); + boolean showprf = av.isShowSequenceLogo(); + boolean showConsHist = av.isShowConsensusHistogram(); + boolean sortg = true; // remove old automatic annotation @@ -1332,36 +1345,50 @@ public class AlignmentPanel extends GAlignmentPanel implements // intersect alignment annotation with alignment groups AlignmentAnnotation[] aan = av.alignment.getAlignmentAnnotation(); - for (int an = 0; an < aan.length; an++) + Hashtable oldrfs = new Hashtable(); + if (aan != null) { - if (aan[an].autoCalculated && aan[an].groupRef != null) + for (int an = 0; an < aan.length; an++) { - av.alignment.deleteAnnotation(aan[an]); - aan[an] = null; + if (aan[an].autoCalculated && aan[an].groupRef != null) + { + oldrfs.put(aan[an].groupRef, aan[an].groupRef); + av.alignment.deleteAnnotation(aan[an]); + aan[an] = null; + } } } SequenceGroup sg; - for (int g = 0; g < gr.size(); g++) + if (gr != null) { - updateCalcs = false; - sg = (SequenceGroup) gr.elementAt(g); - - if (cons) - { - updateCalcs = true; - av.alignment.addAnnotation(sg.getConsensus(),0); - } - if (conv) + for (int g = 0; g < gr.size(); g++) { - updateCalcs = true; - av.alignment.addAnnotation(sg.getConservationRow(),0); - } - // refresh the annotation rows - if (updateCalcs) - { - sg.recalcConservation(); + updateCalcs = false; + sg = (SequenceGroup) gr.elementAt(g); + if (applyGlobalSettings || !oldrfs.containsKey(sg)) + { + // set defaults for this group's conservation/consensus + sg.setshowSequenceLogo(showprf); + sg.setShowConsensusHistogram(showConsHist); + } + if (conv) + { + updateCalcs = true; + av.alignment.addAnnotation(sg.getConservationRow(), 0); + } + if (cons) + { + updateCalcs = true; + av.alignment.addAnnotation(sg.getConsensus(), 0); + } + // refresh the annotation rows + if (updateCalcs) + { + sg.recalcConservation(); + } } } + oldrfs.clear(); adjustAnnotationHeight(); } }