X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPaintRefresher.java;h=1def794bd2bb46503c4b22903c06300925127b3d;hb=f5a39f4861d0f1ffdb3c5b542e00907b2cc18a73;hp=ea28568c0e65cfc4767aa084942de9522ea468cd;hpb=0b8d90322518b88f3d88babbbe4af03811aaa7b2;p=jalview.git diff --git a/src/jalview/gui/PaintRefresher.java b/src/jalview/gui/PaintRefresher.java index ea28568..1def794 100755 --- a/src/jalview/gui/PaintRefresher.java +++ b/src/jalview/gui/PaintRefresher.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, 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 @@ -33,7 +33,7 @@ import java.util.*; */ public class PaintRefresher { - static Hashtable components = new Hashtable(); + static Hashtable components; /** * DOCUMENT ME! @@ -41,60 +41,159 @@ public class PaintRefresher * @param comp DOCUMENT ME! * @param al DOCUMENT ME! */ - public static void Register(Component comp, AlignmentI al) + public static void Register(Component comp, String seqSetId) { - if (components.containsKey(al)) + if (components == null) + components = new Hashtable(); + + if (components.containsKey(seqSetId)) { - Vector comps = (Vector) components.get(al); - comps.addElement(comp); + Vector comps = (Vector) components.get(seqSetId); + if(!comps.contains(comp)) + { + comps.addElement(comp); + } } else { Vector vcoms = new Vector(); vcoms.addElement(comp); - components.put(al, vcoms); + components.put(seqSetId, vcoms); } } - /** - * DOCUMENT ME! - * - * @param al DOCUMENT ME! - */ - public static void Refresh(AlignmentI al) + public static void RemoveComponent(Component comp) { - Refresh(null, al); + if (components == null) + return; + + Enumeration en = components.keys(); + while(en.hasMoreElements()) + { + String id = en.nextElement().toString(); + Vector comps = (Vector) components.get(id); + comps.remove(comp); + if(comps.size()==0) + { + components.remove(id); + } + } } - /** - * DOCUMENT ME! - * - * @param c DOCUMENT ME! - * @param al DOCUMENT ME! - */ - public static void Refresh(Component c, AlignmentI al) + public static void Refresh(Component source, String id) { - Component temp; - Vector coms = (Vector) components.get(al); - if(coms==null) - return; + Refresh( source, id, false, false); + } + + public static void Refresh(Component source, + String id, + boolean alignmentChanged, + boolean validateSequences) + { + if (components == null) + return; + + Component comp; + Vector comps = (Vector) components.get(id); - Enumeration e = coms.elements(); + if(comps==null) + { + return; + } - while (e.hasMoreElements()) + Enumeration e = comps.elements(); + while (e.hasMoreElements()) + { + comp = (Component) e.nextElement(); + + if(comp==source) { - temp = (Component) e.nextElement(); + continue; + } - if (!temp.isValid()) - { - coms.removeElement(temp); - } - else if (temp == c) - { - continue; - } - else - temp.repaint(); + if (!comp.isValid()) + { + comps.removeElement(comp); + } + else if(validateSequences + && comp instanceof AlignmentPanel + && source instanceof AlignmentPanel ) + { + validateSequences( ((AlignmentPanel)source).av.alignment, + ((AlignmentPanel)comp).av.alignment); + } + + if(comp instanceof AlignmentPanel && alignmentChanged) + { + ((AlignmentPanel)comp).alignmentChanged(); + } + + comp.repaint(); + } + } + + static void validateSequences(AlignmentI source, AlignmentI comp) + { + SequenceI[] a1; + if(source.getHiddenSequences().getSize()>0) + a1 = source.getHiddenSequences().getFullAlignment().getSequencesArray(); + else + a1 = source.getSequencesArray(); + + SequenceI[] a2; + if (comp.getHiddenSequences().getSize() > 0) + a2 = comp.getHiddenSequences().getFullAlignment().getSequencesArray(); + else + a2 = comp.getSequencesArray(); + + int i, iSize=a1.length, j, jSize=a2.length; + boolean exists = false; + for(i=0; i 0) + a2 = comp.getHiddenSequences().getFullAlignment().getSequencesArray(); + else + a2 = comp.getSequencesArray(); + } + } + + iSize=a1.length; + jSize=a2.length; + + for(j=0; j