X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fgui%2FPaintRefresher.java;h=d28372050437191eada0e656bc64ea428e95eaf1;hb=cca1d315fd19ddcc7c67a5aba91dafa98be097cf;hp=6bec8fdd40fb68627f9f9cea0356bdd959d41aeb;hpb=588042b69abf8e60bcc950b24c283933c7dd422f;p=jalview.git diff --git a/src/jalview/gui/PaintRefresher.java b/src/jalview/gui/PaintRefresher.java index 6bec8fd..d283720 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 @@ -18,45 +18,201 @@ */ package jalview.gui; -import java.util.*; +import jalview.datamodel.*; import java.awt.*; +import java.util.*; + + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class PaintRefresher { - static Vector components = new Vector(); + static Hashtable components; - public static void Register(Component c) - { - if (!components.contains(c)) + /** + * DOCUMENT ME! + * + * @param comp DOCUMENT ME! + * @param al DOCUMENT ME! + */ + public static void Register(Component comp, String seqSetId) { - components.add(c); + if (components == null) + components = new Hashtable(); + + if (components.containsKey(seqSetId)) + { + Vector comps = (Vector) components.get(seqSetId); + if(!comps.contains(comp)) + { + comps.addElement(comp); + } + } + else + { + Vector vcoms = new Vector(); + vcoms.addElement(comp); + components.put(seqSetId, vcoms); + } } - else + + public static void RemoveComponent(Component comp) { - components.remove(c); + 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); + } + } } - } - public static void Refresh(Component c) - { - Component temp; - Enumeration e = components.elements(); + public static void Refresh(Component source, String id) + { + Refresh( source, id, false, false); + } - while (e.hasMoreElements()) + public static void Refresh(Component source, + String id, + boolean alignmentChanged, + boolean validateSequences) { - temp = (Component) e.nextElement(); + if (components == null) + return; + + Component comp; + Vector comps = (Vector) components.get(id); - if (!temp.isValid()) + if(comps==null) { - components.removeElement(temp); + return; } - else if (temp == c) + + Enumeration e = comps.elements(); + while (e.hasMoreElements()) { - continue; + comp = (Component) e.nextElement(); + + if(comp==source) + { + continue; + } + + 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(); - temp.repaint(); + 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; + + if(iSize == jSize) + return; + + 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